预构建事件失败

发布于 2024-09-17 07:23:55 字数 693 浏览 10 评论 0原文

我将预构建事件设置为:

$(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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

流云如水 2024-09-24 07:23:55

TargetDir 变量在您的情况下包含空格。您需要在命令周围加上引号:

"$(TargetDir)MyConsoleApp"

The TargetDir variable contains spaces in your case. You need to put quotes around the command:

"$(TargetDir)MyConsoleApp"
静水深流 2024-09-24 07:23:55

不完全正确,我遇到了相同的错误,并且我的参数之间没有单个空格字符。我相信 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)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文