问题描述
在解决方案目录中添加对程序集的引用时,有什么方法可以相对添加它,以便在检入和检出存储库时在项目中正确引用它?
扩展 Pavel Minaev 的原始评论 - Visual Studio 的 GUI 支持相对引用,并假设您的 .sln 是相对引用的根.因此,如果您有解决方案 C:\myProj\myProj.sln
,则您在 C:\myProj\
的子文件夹中添加的任何引用都会自动添加为相对引用.>
要在单独的目录中添加相对引用,例如 C:/myReferences/myDLL.dll
,请执行以下操作:
- 在解决方案资源管理器中右键单击项目并选择添加引用... ,在 Visual Studio GUI 中添加引用
- 找到此引用所在的 *.csproj 并在文本编辑器中打开它
编辑 <HintPath > 等于
现在引用 C:\myReferences\myDLL.dll
.
希望这会有所帮助.
When adding a reference to an assembly located within the solution directory, is there any way to add it relatively, so that when checked in and out of a repository it is referenced in projects correctly?
To expand upon Pavel Minaev's original comment - The GUI for Visual Studio supports relative references with the assumption that your .sln is the root of the relative reference. So if you have a solution C:\myProj\myProj.sln
, any references you add in subfolders of C:\myProj\
are automatically added as relative references.
To add a relative reference in a separate directory, such as C:/myReferences/myDLL.dll
, do the following:
- Add the reference in Visual Studio GUI by right-clicking the project in Solution Explorer and selecting Add Reference...
- Find the *.csproj where this reference exist and open it in a text editor
Edit the < HintPath > to be equal to
<HintPath>..\..\myReferences\myDLL.dll</HintPath>
This now references C:\myReferences\myDLL.dll
.
Hope this helps.
这篇关于Visual Studio:相对程序集引用路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!