views:

497

answers:

2

I am trying to call MSBuild from a command line. Everything was working fine when I was using a path that had no spaces, but now I have a path that has spaces and the command is failing.

Command (works):

"C:\Windows\Microsoft.NET\Framework\v3.5\MSBuild.exe" 
/t:Rebuild "C:\Projects\myProject.csproj" 
/p:OutDir=c:\temp\deploy\funAndGames\Deployment\bin\ 
/p:WebProjectOutputDir=c:\temp\deploy\funAndGames\Deployment\ 
/p:Confguration=Release

I then added quotes and changed OutDir to OutPath (doesn't work):

"C:\Windows\Microsoft.NET\Framework\v3.5\MSBuild.exe" 
/t:Rebuild "C:\Projects\myProject.csproj" 
/p:OutPath="c:\temp\deploy\funAndGames\Deployment\bin\" 
/p:WebProjectOutputDir="c:\temp\deploy\funAndGames\Deployment\" 
/p:Confguration=Release

What I am aiming for is something like this (doesn't work):

"C:\Windows\Microsoft.NET\Framework\v3.5\MSBuild.exe" 
/t:Rebuild "C:\Projects\myProject.csproj" 
/p:OutPath="c:\temp\deploy\fun and games\Deployment\bin\" 
/p:WebProjectOutputDir="c:\temp\deploy\fun and games\Deployment\" 
/p:Confguration=Release

Any help on the syntax around OutDir/OutPath and WebProjectOutputDir with spaces? Is it possible? If it isn't does anyone know what the reason is (due to some Url's not having spaces type thing?)

A: 

"C:\Windows\Microsoft.NET\Framework\v3.5\MSBuild.exe" /t:Rebuild "C:\Projects\myProject.csproj"

/p:OutPath="c:\temp\deploy\funAndGames\Deployment\bin\"

/p:WebProjectOutputDir="c:\temp\deploy\fun and games\Deployment\"

/p:Confguration=Release

Try this.

Also try via VSStudio GUI. Then copy the settings & try with MS Build.

Ganesh R.
unfortunately that doesn't work
ChrisHDog
+6  A: 

Just found this out an answer to this old question. To handle spaces, you should use the escape character \ on all folders. Basically

/p:OutPath="c:\temp\deploy\fun and games\Deployment\bin\"

should be

/p:OutPath="c:\\temp\\deploy\\fun and games\\Deployment\\bin\"

and magically it works!

johnofcross
Excellent! Looks like MSBuild has some funky custom way to interpret the command line. Thanks for posting your result.
jpierson