3

How do I pass multiple ReferencePath in MSBuild in the command line. I'm currently using this

MSBuild /t:Rebuild "Solution1.sln" /p:ReferencePath="C:\My Library 1\obj\Debug; C:\My Library 2\obj\Debug"

MSBuild is returning an MSB1006 error. Take note that my reference paths have spaces in it.

6 Answers 6

2

Try escaping the semicolons as %3b

Try moving the quotes around the entire property expression, not just the values

/p:"Name=Value One;Value Two"
Sign up to request clarification or add additional context in comments.

3 Comments

Didn't work. It ignored ALL of the ReferencePath and used the reference path declared in the solution.
I still cannot, for the love of all things unholy, make it work!
How is this different from the code in the question?
2

I had the same problem. This worked for me:

msbuild {{slnPath}} /t:rebuild /p:OutDir={{outputpath}} /p:Configuration=Release

Specify /p for every parameter

Comments

1

This wasn't working in powershell

msbuild C:\temp\project.sln /p:referencepath="C:\Checkout\References
\CRM 2011;C:\Checkout\References\Log4Net\4.0\release"

but works fine from an old fashioned cmd prompt.

Comments

0

No matter what I do, I can't seem to make it work using MSBuild. I now use DEVENVE.EXE to compile my solution; it would read my user project settings where the ReferencePath is saved and use that to locate the correct version of the DLL I want to use.

1 Comment

If you are going to use visual studio to compile your code then you should call DEVENV.com and not DEVENV.exe. The exe will open up an instance of VS.
0

replacing the ';' with '3%B' seems to work in my setup with Nant and Jenkins

Comments

0

This worked for me, using MSBuild 2019 and setting the value below for command line arguments. This is in Jenkins 2.516.2 with all plugins up-to-date and MSBUILD plugin version 1.37.

/p:"ReferencePath=\"D:\data\jenkins\AdditionalAssemblies;D:\data\jenkins\AdditionalAssembliesVS2022\""

MSBuild requires quotes around the ReferencePath value if it contains a semicolon - otherwise, the bit behind the semicolon is treated as a separate parameter and MSBUILD reports an error like:

MSBUILD : error MSB1006: Property is not valid.
Switch: D:\data\jenkins\AdditionalAssembliesVS2022\

For some reason, Jenkins removes double as well as single quotes if they aren't escaped (and escaping them properly seems to be an adventure in itself). I'm not sure why or whether the ReferencePath parameter needs to be in quotes, after a lot of experimentation this is the first one that worked and I've already wasted too much time. What I don't understand is how there isn't proper documentation on how to do it, and it remained a mystery for decades (I, at least, wasn't able to find a solution).

For complete context, here's a screenshot of how I'm using it:

Shown is the MSBuild version selected (MSbuild 2019), project file name and command line arguments (which is the ReferencePath syntax given above)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.