How to add a link to a project folder in Visual Studio

I’ve had a quick play with adding the contents of a folder from another project, i.e. I want to add links to all the files in another project’s folder. So for example; I have a project called ConsoleApplication1 and I want to ensure it always has links to the images in another project called ClassLibrary1 (yes nice names eh). So first create a folder with the same name, e.g. images, in ConsoleApplication1. Add a link to one of the files in ClassLibrary1\Images (Add existing item->add as link). Unload ConsoleApplication1 and Edit the project file. Locate the Content Include and replace it as follows;

<ItemGroup>
  <Content Include="..\ClassLibrary1\images\*.*">
    <Link>images\%(RecursiveDir)%(FileName)</Link>
  </Content>
</ItemGroup>

So whatever changes you make to ClassLibrary1\Images will automatically be reflected in ConsoleApplication\Images. It’s early days but it seems to run ok.

Advertisements
This entry was posted in Visual Studio. Bookmark the permalink.

4 Responses to How to add a link to a project folder in Visual Studio

  1. kinggudu says:

    You should also include the %(Extension) transform:

    images\%(RecursiveDir)%(FileName)%(Extension)

  2. Alex says:

    kinggudu
    thank you very much!

  3. How to include sub folders also along with files ??

    Thank you,

  4. How to include sub folders along with files

    Thank you.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s