"Add as Link" for folders in Visual Studio projects

Viewed 68816

In Visual Studio, we can "Add as link" to add a link to a file in another project in the solution.

Is there any way to do this for entire folders, so that an entire folder in project A will be visible in project B, without the need to manually link to new items in that folder?

7 Answers

Even when there are so many solutions it took me a while to understand it. Here I will try to explain it a little bit more.

I needed link to the whole folder so my final result is:

<ItemGroup>
    <Content Include="..\Gym.Management.Api\TestFolder\**\*.*">
        <Link>TestFolder\%(RecursiveDir)%(FileName)%(Extension)</Link>
        <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </Content>
</ItemGroup>

where:

  1. ..\Gym.Management.Api\TestFolder\ represents path to the other project containing the folder I want to link
  2. TestFolder\ in <link> tag is the final(destination) folder in my current project where I want to link it

TIP: When you are not sure how to get the proper Include path then in your current project right click on project->click Add->Existing item->navigate to one of those files from folder you want to link-> instead of Add, press the dropdown arrow next to it->click Add as link. This link is inserted in your .csproj file and from there you can extract the Include path.

Related