Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Store project reference paths in .csproj, not user file?

I altered a bunch of project files in our solution, to add a reference path to all of them. I didn't realize that Reference Paths are stored in the .user file for the project. Is there a way to store those in the .csproj file, so they can be checked into source control?

like image 315
Jonas Avatar asked Apr 26 '10 22:04

Jonas


People also ask

How do I add a reference path in Visual Studio?

If you're using Visual Basic, select the References page, and then click the Reference Paths button. In the Reference Paths dialog box, type the path of the folder that contains the item you want to reference in the Folder field, and then click the Add Folder button.

How do I add a project reference in Csproj?

You can also right-click the project node and select Add > Project Reference. If you see a References node in Solution Explorer, you can use the right-click context menu to choose Add Reference. Or, right-click the project node and select Add > Reference.

How do I add a project reference code in Visual Studio?

In visual studio, in the solution explorer, expand the project that will reference this other library. You will see "References", right click and choose "Add". Then choose browse on the left.


2 Answers

You can edit the project file by hand and add <ReferencePath> inside the <PropertyGroup> tags.

The syntax in my case was

<ReferencePath>$(Codez)\z.Libraries\AutoCAD\2015;
$(Codez)\z.Libraries\AutoCAD\2015\inc-win32;
$(Codez)\z.Libraries\AutoCAD\2015\inc-x64</ReferencePath> 

where $Codez is an Environment variable I set myself and it obviously supports multiple paths. This is in VS2013.

like image 169
CAD bloke Avatar answered Oct 05 '22 23:10

CAD bloke


You might try adding the reference as a HintPath, like this:

<Reference Include="MyReference, Version=2.0.3.2, Culture=neutral, processorArchitecture=MSIL">     
  <HintPath>..\..\lib\Whatever\MyReference.dll</HintPath>
</Reference>
like image 32
Neil Avatar answered Oct 05 '22 23:10

Neil