VS2008 post-build event batch file
I'm trying to execute a batch file to move a bunch of files around after a build so I've created a post-build event that looks like this:
$(ProjectDir)CopyPlugins.bat $(ConfigurationName)
The problem is that when Visual Studio tries to run the event I get the error that the process exited with code 9009
The problem 开发者_开发问答appears to be that VS puts the entire line in quotes so that the command it runs is:
"C:\Users\kdmurray\Visual Studio 2008\Projects\Runner\Runner\CopyPlugins.bat Debug"
Of course what I intended it to do was a very subtle variation, changing the location of the closing quotation mark.
"C:\Users\kdmurray\Visual Studio 2008\Projects\Runner\Runner\CopyPlugins.bat" Debug
Is there any way around this rather annoying "help" that VS provides?
Create two more batch files that just executes the first with different arguments.
CopyPlugins-debug.bat
Call CopyPlugins.bat debug
CopyPlugins-release.bat
Call CopyPlugins.bat release
And in VS post-build event
"$(ProjectDir)CopyPlugins-$(ConfigurationName).bat"
If you're trying to do complicated post-build copying it might be worth looking at the MSBuild Community Tasks project. It has a task that wraps RoboCopy.exe which might be a cleaner way to accomplish your task.
Generally I make a separate "build" project that is empty and does nothing but execute pre/post build steps. It works quite well.
I think you might just need quotes around the path to the batch script, i.e. your post-build event should be:
"$(ProjectDir)CopyPlugins.bat" $(ConfigurationName)
This worked for me for a C# project located in a directory with a space in its path.
Just type it like this
d:\foo\bar\myMainScript.bat "$(MY_VSPROPS_MACRO_VAR_00)"
This worked for me. Dont use CALL
function to call the batch file!!!.
Pass all the parameters into the main batch file and process things inside. If you have other batches or set of batches to be called, don't call them in the post build event, just call the other batch files from the main batch file.
精彩评论