简体   繁体   中英

Visual Studio Post Build Event if exists

I want to call a batch file in my post build step in Visual Studio. Locally the batch file exists, just the command

call "$(SolutionDir)PostBuildSen.bat" "$(TargetDir)" "$(TargetName)"

correctly calls and executes the batch file.

However when I want to check if the batch file exists first (since others will use the same Post Build Event), I get the error

:VCEnd" exited with code 255.

The command is

if exists "$(SolutionDir)PostBuildSen.bat" call "$(SolutionDir)PostBuildSen.bat" "$(TargetDir)" "$(TargetName)"

The Diagnostic output tells me

2> Done executing task "Exec" -- FAILED.

How do you handle this?

The Solution Directory contains a folder with an underscore, ie \\Dev_Main\\ and I have read that for the batch file that is to be called at least that doesn't work. However I am not sure if that is the issue with folders as well and how to cope with it. Also, since the call command works, I am not sure this is the problem.

Furthermore, if I replace the call with cmd /C , the exit code is 1 and the (minmal) output tells me

1>The filename, directory name, or volume label syntax is incorrect.

Also, I will add this as a custom command to a CMakeLists file later on, so the solution needs to work with that.

Thanks to Hans Passant's comment, I solved the problem. The query for the file needs to be if exist rather than if exists .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM