views:

521

answers:

5

I have a question regarding the commandline options of msbuild. I am currently using msbuild to build projects using the existing solution files. These solution files have references to external dll which have different paths on each machine. I am currently writing a build script and passing the specific path to the project file via the /p: switch of msbuild.

My current build line is: msbuild test.sln /p:ReferencePath="c:\abc" /p:ReferencePath="c:\rca"

What i have noticed that Reference Path now contains only c:\rca and not c:\abc. this is causing problems for me since, the external dlls lie in two different directorys. I am allowed to keep multiple reference paths via visual studio, but not via the commandline.

Is there any known way by which i can do this

+3  A: 

I believe you can use this /p:ReferencePath="c:\abc;c:\rca"

At least that is what that link is hinting at, they are using %3B to encode the ";" within the build file.

froh42
A: 

Try seperating your pathes with a semi-colon (;)

Like this:

c:\abc;c:\rca

2-bits
A: 

You may be better off by synchronizing your libraries across machines. I have found that Visual Studio makes this easy. Simply add a solution folder, and add your libraries there. Then, in each project, reference the libraries from this common place. This way, each developer has them in the same place.

This will remove one of variables you have when trying to script out builds.

rifferte
+3  A: 

Although the correct syntax for providing more the one reference path is listed above, I would suggest solving the root cause which in my opinion is the different locations of your referenced assembly. I would suggest you put all thirdparty dependencies, apart from the framework assemblies in your source code repository for the following reasons:

  1. Relatitve paths are consistent across computers
  2. The source code is always in sink with the correct version of your thirdparty assembly (if you for instance need to build an old version of your software 2 years from now).
  3. Upgrading your thirdparty assembly is as easy as upgrading on one machine and then committing your changes to the repository. (In a previous project we even went as far as checking in the entire java runtime environment and were quite happy with the given setup.)
Bas Bossink
A: 

The command line options for setting the reference path will work just fine (assuming you escape the semi colon, it seems both %3B and &#59; will work). However, when the argument was passed in from nant (and I needed multiple paths), creating a 'Visual Studio Project User Options file' seemed to work better.

I just emit (echo) a file to the file system with the following format:

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"&gt;
<PropertyGroup>
    <ReferencePath>
        C:\abc;c:\rca
    </ReferencePath>
</PropertyGroup>

I give the *.user file an appropriate name (given a project file MyProject.csproj, my user file would be MyProject.csproj.user)

Mish Ochu