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.

4 thoughts on “How to add a link to a project folder in Visual Studio

  1. kinggudu's avatar kinggudu November 25, 2011 / 5:20 pm

    You should also include the %(Extension) transform:

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

  2. Alex's avatar Alex July 17, 2012 / 10:11 am

    kinggudu
    thank you very much!

  3. Krishna Thota's avatar Krishna Thota November 10, 2014 / 2:51 am

    How to include sub folders also along with files ??

    Thank you,

  4. Krishna Thota's avatar Krishna Thota November 10, 2014 / 2:53 am

    How to include sub folders along with files

    Thank you.

Leave a reply to Alex Cancel reply