0

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.

Ta01
  • 31,040
  • 13
  • 70
  • 99
Shimmy Weitzhandler
  • 101,809
  • 122
  • 424
  • 632

2 Answers2

2

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)

Lord of Scripts
  • 3,579
  • 5
  • 41
  • 62
2

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

"$(TargetDir)MyConsoleApp"
Shimmy Weitzhandler
  • 101,809
  • 122
  • 424
  • 632
jeroenh
  • 26,362
  • 10
  • 73
  • 104