How do I create Visual Studio shortcut files

2019-01-21 21:31发布

问题:

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?

回答1:

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



回答2:

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:

(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?



回答3:

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