Pre-build event fails
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 recogni开发者_运维百科zed 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.
The TargetDir variable contains spaces in your case. You need to put quotes around the command:
"$(TargetDir)MyConsoleApp"
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)
精彩评论