How do I pass a property value containing a semicolon on the MSBuild command line when running it from PowerShell?
Wrap the parameter in single quotes:
... '/p:PackageSources="\\Server\NuGet;E:\NuGet"'
On PowerShell v3 try this:
msbuild .\Foo.sln --% /p:PackageSources="\\Server\NuGet;E:\NuGet"
Also using ascii value might help:
msbuild .\Foo.sln /p:PackageSources="\Server\NuGet%3BE:\NuGet"
VBScript function below can be used to escape property values passed to MSBuild.exe inside double quotes:
Function Escape(s) Escape = s Set objRegEx = CreateObject("VBScript.RegExp") objRegEx.Global = True objRegEx.Pattern = "(\\+)?""" Escape = objRegEx.Replace(Escape,"$1$1\""") objRegEx.Pattern = "(\\+)$" Escape = objRegEx.Replace(Escape,"$1$1") End Function
The following example demonstrates usage of Escape() function
Set objShell = WScript.CreateObject("WScript.Shell") objShell.Run "msbuild.exe echo.targets /p:Param1=""" & Escape("ParamValue1") & """,Param2=""" & Escape("ParamValue1") & """", 1, True