views:

18

answers:

2

I have two projects in one Visual Studio 2008 solution. I'd like to use the primary output from one of the projects as an embedded resource in the other, but for the life of me I can't find any way to accomplish this.

If I simply add the output file as a resource, then it doesn't seem to change when its source project is rebuilt. I even have the project dependencies/build order set up properly and this does not seem to help.

Anyone have any hints for me?

Thanks!

+1  A: 

Set the output directory of the project that generates the resource to point to the resource directory in the project that uses it.

If that's not possible for some reason, use a post-build command (also available in the project settings) to copy the file there.

Matti Virkkunen
+1  A: 

When you add an existing file to a project, Visual Studio copies the file into the project's directory.
Any subsequent changes to the original file are ignored.

There are two workarounds:

  • Add a post-build action to the first project that copies its output file to the second project, and edit the dependencies so that the first project is always built first.

  • Add the output file to the second project as a link (Click the down arrow next to the Add button in the open dialog).
    This will reference the file from its original location without making any copies.

SLaks
Thanks for the suggestion. I'm a bit of a VS newbie, so I do have one question though: you say, "you need to add the output file as a link." What is a link?
Tom
@Tom: When you add the file, click the down arrow next to the Add button.
SLaks