预构建事件失败
我将预构建事件设置为:
$(TargetDir)MyConsoleApp
但是当我运行应用程序时,我得到以下输出:
------ Build started: Project: BlahBlahBlah, Configuration: Debug x86 ------
'd:\users\user\documents\visual' is not recognized as an internal or external
command, operable program or batch file.
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(902,9):
error MSB3073: The command "d:\users\user\documents\visual studio 2010\Projects\
BlahBlahBlah\BlahBlahBlah\bin\Debug\MyConsoleApp" exited with code 9009.
========== Build: 0 succeeded, 1 failed, 1 up-to-date, 0 skipped ==========
指定目标处的文件 MyConsoleApp 确实存在,并且可以从 Windows 资源管理器正常运行。
I set a prebuild event to:
$(TargetDir)MyConsoleApp
But when I run the application I get the following output:
------ Build started: Project: BlahBlahBlah, Configuration: Debug x86 ------
'd:\users\user\documents\visual' is not recognized as an internal or external
command, operable program or batch file.
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(902,9):
error MSB3073: The command "d:\users\user\documents\visual studio 2010\Projects\
BlahBlahBlah\BlahBlahBlah\bin\Debug\MyConsoleApp" exited with code 9009.
========== Build: 0 succeeded, 1 failed, 1 up-to-date, 0 skipped ==========
The file MyConsoleApp at the specified target DOES exist and runs properly from windows explorer.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
TargetDir 变量在您的情况下包含空格。您需要在命令周围加上引号:
The TargetDir variable contains spaces in your case. You need to put quotes around the command:
不完全正确,我遇到了相同的错误,并且我的参数之间没有单个空格字符。我相信 Visual Studio 只是被这些事情难住了,并且想知道为什么它在这方面没有得到改进。
无论如何,我通过创建一个批处理文件,然后使用批处理文件位置参数从 Post BUild 事件调用该批处理文件来解决这个问题:
MyPostBuildCommands.bat $(SolutionDir) $(ProjectDir) $(OutDir)
Not entirely true, I was getting the same error and my parameters did not have a single whitespace character in between. I believe Visual Studio simply gets stumped with these kind of things and wonder why it hasn't been improved in that respect.
In any case, I worked around it by creating a Batch file and then calling that batch file from the Post BUild event with batch file positional parameters:
MyPostBuildCommands.bat $(SolutionDir) $(ProjectDir) $(OutDir)