Question

In Visual Studio there is a way to have a file in another project that is a shortcut to the first so that it builds in both. How do I do that?

Was it helpful?

Solution

Right-click the project, select Add > Existing Item, and in the dialog drop down the Add button and select Add As Link.

Add As Link

OTHER TIPS

This is not a direct answer but an alternative that may be worth considering in some cases.

You can create a specific kind of project which can "include" a set of files in another project when it is added by reference. This is called a Shared Project which is one of the 'new project' options:

enter image description here

(Since at least Visual Studio 2015 - maybe earlier).

One advantage of this type of project over individual shortcuts is that it includes a set of things as a bundle. So if you have a large # of items, this may be easier and less error prone.

Also it uses the familiar "reference" metahphor in the context of the solution and in that way functions quite similarly to other project references; the difference is that in a shared project the items in the project are added into each referring project, but in a normal project the assemblies (DLLs) end up owning the reference at runtime. Shortcuts may be less familiar to other developers than the reference pattern.

More information: What is the difference between a Shared Project and a Class Library in Visual Studio 2015?

Are you talking about a solution with multiple projects? In that case answer would be using Project Dependencies (within Project menu).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top