如何在 MSBuild WebProjectOutputDir 中留有空格?
我正在尝试从命令行调用 MSBuild。 当我使用没有空格的路径时,一切工作正常,但现在我有一个有空格的路径,并且命令失败。
命令(有效):
"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:Configuration=Release
然后我添加了引号并将 OutDir 更改为 OutPath(不起作用):
"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:Configuration=Release
我的目标是这样的(不起作用):
"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:Configuration=Release
有关 OutDir/OutPath 和 WebProjectOutputDir 与空格的语法的任何帮助? 是否可以? 如果不是,有人知道原因是什么(由于某些网址没有空格类型吗?)
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:Configuration=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:Configuration=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:Configuration=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?)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
刚刚找到了这个老问题的答案。
要处理空格,您应该在所有文件夹上使用转义字符 \。 基本上
应该是这样
,而且它神奇地起作用了!
Just found this out an answer to this old question.
To handle spaces, you should use the escape character \ on all folders. Basically
should be
and magically it works!
尝试添加
"
前任:
Try add
"
ex:
如果您将 \ 切换到 /,同时使用引号,Msbuild 似乎也可以使用 OutDir 中的空格:
Msbuild also seems to work with spaces in the OutDir if you switch \ to /, while using quotes:
对我来说,工作解决方案是:
/p:SQLCMD="\"C:\Program Files\Microsoft SQL Server\100\Tools\Binn\SQLCMD.EXE\""
换句话说:将所有字符串放入引号中(外部引号不会作为值传递给 MSBuild)。
MSBuild 中此属性的值为:“C:\Program Files\Microsoft SQL Server\100\Tools\Binn\SQLCMD.EXE”(带引号)。
For me the working solution is:
/p:SQLCMD="\"C:\Program Files\Microsoft SQL Server\100\Tools\Binn\SQLCMD.EXE\""
In other words: Putting all the string into quotes (the external quotes aren't passed as value to MSBuild).
The value inside MSBuild for this property is: "C:\Program Files\Microsoft SQL Server\100\Tools\Binn\SQLCMD.EXE" (with the quotes).
尝试这个。
也可以尝试通过 VSStudio GUI。 然后复制设置& 尝试使用 MS Build。
Try this.
Also try via VSStudio GUI. Then copy the settings & try with MS Build.
如果开关中有多个参数,则无法通过修复路径来真正“避免”问题。 您可以做的是将开关的参数放在“ some_parameters1 some_parameters2 ”之间。
就像:
当然,很大程度上取决于开关的语法,但这对我和我的团队有用。
If you have multiple parameters in a switch you can't really 'avoid' the problem by fixing the path. What you can do is put your parameters of the switch between " some_parameters1 some_parameters2 ".
Something like:
Of course a lot depends of the syntax of the switches but that works for me and my team.
要在使用 .proj 文件并且您的路径包含在 $(DeployFolder) 和 $(NuGetExe) 等属性中时执行此操作,您可以使用“"” 像这样:
To do this when using a .proj file and your path is included in properties like $(DeployFolder) and $(NuGetExe), you can use """ like this: