I have a post-build event set up in Visual Studio 2010. The problem I am having is that the event doesn't run when I use Run (F5) to start debugging--it only seems to run if I explicitly Build (F6).
This seems to happen even when source files have changed (so it must build in order to run).
Is there a setting that controls this behavior?
Postbuilds are only run after building. So when your build artifacts are up to date, it will not build and postbuilds will not run.
If it even won't run when it has to build, check the following:
In Visual Studio look at Tools -> Options -> Projects and Solutions -> Build an Run.
Is the option "Only build startup projects and dependencies on Run" checked?
Try to uncheck that option.
What is the value of the option "On Run, when projects are out of date"?
It should be "Prompt to build" or "Always build" to be sure to trigger a build when pressing F5.
It only runs after a successful build. That why it's called a Post-Build Event.
Maybe what you're trying to accomplish can be done in a different way. Could you please give more details? What are you trying to do? What do you want to run before every debug session, and why?
See Visual Studio: Run C++ project Post-Build Event even if project is up-to-date
Use Custom Build Step with a non existing file as output to always run your step.
Check if the command is correct. A simple example would be:
copy "$(SolutionDir)$(ProjectName)\test.txt" ".\test.txt"
i've developed a simple VisualStudio AddIn, which intercepts the start command and does a rebuild of the solution, before it is actually starting the project.
Maybe it is useful for someone else:
https://skydrive.live.com/redir.aspx?id=3dc36fae9ccfb71f&resid=3DC36FAE9CCFB71F!112&parid=root
(BuildAndRunAddin.zip)