[英]How to set the reference path for the solution in Visual Studio?
I have a C# solution contains many projects. 我有一个C#解决方案包含很多项目。 Each project references some dlls in a specified folder.
每个项目都引用指定文件夹中的一些dll。 According to MSDN we could add the reference path for a project in project -> Properties -> Reference Paths.
根据MSDN,我们可以在项目 - >属性 - >参考路径中添加项目的参考路径。 It will generate a .csproj.user file under the project folder with the content below:
它将在项目文件夹下生成一个.csproj.user文件,其中包含以下内容:
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ReferencePath>C:\References\bin\</ReferencePath>
</PropertyGroup>
</Project>
But this only works for one project alone. 但这仅适用于一个项目。 Is there a simple way to apply the same setting to all of the projects in the solution?
有没有一种简单的方法将相同的设置应用于解决方案中的所有项目?
I found a blog post explaining how to do this. 我找到了一篇博文,解释了如何做到这一点。
Open the Package Manager Console (eg View | Other Windows | Package Manager Console) and use a script such as the following for relative paths: 打开包管理器控制台(例如,查看|其他Windows |包管理器控制台),并使用以下脚本作为相对路径:
$path = [System.IO.Path]; foreach ($proj in get-project -all) {$proj.Properties.Item("ReferencePath").Value="$($path::GetDirectoryName($proj.filename))\..\libs"}
or this for a single fixed project reference for all projects: 或者对于所有项目的单个固定项目参考:
foreach ($proj in get-project -all) {$proj.Properties.Item("ReferencePath").Value=C:\lib"}
我不相信,可能是因为可以将项目加载到许多解决方案中,并且如果所需库的参考路径成为解决方案的范围,您最终会遇到构建错误或不同的行为,具体取决于您使用哪种解决方案如果解决方案告诉项目在不同的位置查找依赖项,则构建项目。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.