How to set the reference path for a solution in Visual Studio?

I have a C # solution containing many projects. Each project references some DLLs in the specified folder. According to MSDN, we could add a reference path for the project in the project -> Properties -> Reference paths. It will generate a .csproj.user file in the project folder with the contents below:

<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. Is there an easy way to apply the same setting to all projects in a solution?

+4
source share
2 answers

I found a blog post explaining how to do this.

Open the package manager console (for example, View | Other Windows | package manager console) and use a script, for example, the following for relative paths:

 $path = [System.IO.Path]; foreach ($proj in get-project -all) {$proj.Properties.Item("ReferencePath").Value="$($path::GetDirectoryName($proj.filename))\..\libs"} 

or is it for one fixed project link for all projects:

 foreach ($proj in get-project -all) {$proj.Properties.Item("ReferencePath").Value=C:\lib"} 
+3
source

I don’t believe that it’s possible because projects can be loaded into many solutions, and if the reference path for the required libraries becomes a limited solution, you will receive either build errors or different behaviors depending on which solution you build in the project, if the solutions tell the project to look in different places for dependencies.

0
source

Source: https://habr.com/ru/post/1412303/


All Articles