Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does Visual Studio only allow one link per file in a project?

I would like to have a file in several different projects of a solution, however, Visual Studio only allows one link per solution to the file. Is there a way around this?

What is the issue of having several soft links to a single file within a VS project?

Update: I have added the link as described from the comments below, it seems that the issue is on a per project basis. There can not be multiple links to the same file within the project. When I attempt to add the link I receive the following error - "There is already a link to ''. A project cannot have more than one link to the same file."

like image 580
Eric Avatar asked Dec 06 '09 07:12

Eric


People also ask

How do I link two files in Visual Studio?

To add a file as a link, right click and choose Add > Existing Item… as before, but this time, don't click the Add button. Instead, click the little dropdown arrow next to the Add button and select Add as Link. Instead of copying the file into the project directory, Visual Studio will create a link to the original.

How do I share code between projects in Visual Studio?

If you select Start Collaboration session from the Session Details menu, an invitation link to your session will automatically be copied to your clipboard. You can share this link with anyone you'd like to collaborate with, as long as they also have VS Code and the Live Share Extension Pack downloaded.

What is Csproj file in Visual Studio?

Every Visual Studio project includes an MSBuild project file, with a file extension that reflects the type of project—for example, a C# project (. csproj), a Visual Basic.NET project (. vbproj), or a database project (. dbproj).


2 Answers

You could create several links to one file on ONE project, but manually and VS will not show it in project tree.

unload project and add for example links:

<Content Include="..\..\_Common\js\JQuery\jquery.js">
  <Link>Sites\OrgCatalogSite\Design\js\JQuery\jquery.js</Link>
  <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>


<Content Include="..\..\_Common\js\JQuery\jquery.js">
  <Link>Sites\TasksManagersSite\Design\js\JQuery\jquery.js</Link>
  <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
like image 179
Evgeny Avatar answered Oct 26 '22 00:10

Evgeny


I am using Visual Studio 2008 Professional, and it allows the same file from one project to be soft-linked to every other project, independently of the number of solution files you are using.

like image 30
Doc Brown Avatar answered Oct 25 '22 22:10

Doc Brown