Reputation: 19151
We're working with Visual Studio 2010, and have a bunch of projects in a solution. Whenever we add a reference to an external dll to a project, that reference will typically be added as a relative path, like:
<Reference Include="SomeReference">
<HintPath>
..\..\..\MyLibCatalog\SomeRef.dll</HintPath>
</Reference>
If we now show properties for the node representing the referenced dll (from the Solution Explorer), it will be displayed as for instance:
C:\MyLibCatalog\SomeRef.dll
In the project file however (right clicking the project node and selecting "Edit project file"), the real reference is still relative (something like ..\..\..\MyLibCatalog\SomeRef.dll
).
We build our system and run some tests in an external system, and for that to work properly, we need these references to be absolute, and not relative. At the moment, that means editing the project files manually each time we add a reference like this. Besides being an annoyance, this "fix" is easy to forget to do.
Thus, my question: Is there any way to make VS2010 add the HintPath as an absolute path from the beginning?
Upvotes: 2
Views: 1874
Reputation: 1858
Perhaps it is the way your using the relative paths. If you place your dependencies in a Dependencies folder in your source tree (as we do) then they are in your revision control system and you can check out your code on any system and always be sure that the binaries match the code.
If using absolute paths then you may have difficulty reproducing a build as how do you know which binaries it was build/tested against?
I recommend going for the relative paths.
Upvotes: 0
Reputation: 43609
The Solution Build Environment VS add-in available here http://workspacewhiz.com/OtherAddins.html might be a solution for you. Didn't try it with VS 2010, but sources are provided and I guess they can easily be tailored to your needs.
The Solution Build Environment add-in has a special symbol for expanding relative paths into an absolute form. The absolute expansion of the path is triggered by inserting an exclamation point at the beginning of the line.
RELPATH=c:\Windows\System32.. !ABSPATH=$(RELPATH) # c:\Windows
The Solution Build Environment add-in executes these transformations at solution open time and before the start of each build, resetting the build's environment variables accordingly.
Upvotes: 0