生成事件不遵循多个命令行参数 [英] Build events not honoring multiple command-line arguments

查看:103
本文介绍了生成事件不遵循多个命令行参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Visual Studio 2010的C#.NET 4.0项目中,我具有以下作为构建后事件:

I have the following as my post-build event in a C# .NET 4.0 project in Visual Studio 2010:

call "$(SolutionDir)Publish\Publish.exe" "$(TargetDir)" "\\lithium\c\Photon"
call "$(SolutionDir)RemoteControl\RemoteControl.exe" start

问题在于,当执行Publish.exe时,仅传递了一个命令行参数,其中包含以下值:

The problem is that when Publish.exe is executed, there is only one command line argument being passed, which contains the following value:

C:\Users\...\bin\Release" \\lithium\c\Photon

注意:我用省略号替换了一些文件夹,否则这是确切的值

note: I replaced some folders with an ellipsis, otherwise this is the exact value

无论出于何种原因,它都会将两个参数组合为一个,并非常奇怪地解析引号.我已经调试了一段时间,并且在没有call的情况下尝试了它,并在Publish.exe的相对目录下进行了操作,例如call "$(SolutionDir)Publish\Publish.exe" hello world一样简单,并且始终将其粉碎为单个参数.这使我相信,这不是骗人的话.

For whatever reason, it's combining the two arguments into one, and parsing the quotes very strangely. I've been debugging this for awhile, and I've tried it without the call, with a relative directory to Publish.exe, with something as simple as call "$(SolutionDir)Publish\Publish.exe" hello world and it's always smashed into a single argument. This leads me to believe that it's not some quotation tomfoolery.

如果我从提示符处运行了这个完全相同的程序,它会完美运行.有人,请帮助我消除这种疯狂.

If I run this exact same program from the prompt, it works flawlessly. Someone, please help me cut through this madness.

推荐答案

在进行另一个项目时,我实际上设法复制了您的问题.我将多个args传递给powershell脚本,发现它们被视为一个参数.谷歌搜索找到此链接

While working on another project, I actually managed to replicate your problem. I was passing multiple args to a powershell script and found that they were being treated as a single argument. Googling found this link

http://davidfrette.wordpress.com/2011/01/20/creating-powershell-pre-build-and-post-build-events-for-visual-studio-projects/

哪个解决方案可以在第一个参数的末尾放置一个空格,即在您的示例中是

Which has the solution of putting a space at the end of the first parameter i.e. in your example it would be

call "$(SolutionDir)Publish\Publish.exe" "$(TargetDir) " "\\lithium\c\Photon"

这对我有用,因此希望它能解决您的问题.

This worked for me so hopefully it will fix your problem.

如果您有2个以上的参数,则需要在每个参数的末尾添加一个空格(最后一个除外).

If you have more than 2 args then you would need to add a space at the end of each except for the last one.

HTH

这篇关于生成事件不遵循多个命令行参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆