Question

As the tittle says I need a prebuild command CONDITION that executes an exe on build solution/project and passes when i use F5.

I found "$(ConfigurationName)" as a possible solution on some websites but it only works if you change each time the configuration type manually.

Anybody knows the trick??

Was it helpful?

Solution

I think what you actually want is a seperate build configuration or some condition that does not run the events when you are developping/debugging, right? Here are two ways I can think of:

  • create a new configuration, as a copy of the current one, and exclude the build events. It's good practice using property sheets, and if you did so, you will not have to change each configuration manually instead just change the property sheet. Then when developping/debugging, use the new configuration
  • make the buildevents conditional. The condition can be an environment variable, a custom project variable, something you specify in a batch file,... Suppose you use an environment variable named 'RUN_PREBUILD', then the build event commad line would be, for example: IF "%RUN_PREBUILD%" == "1" (echo not running postbuild) ELSE (/path/to/prebuild.command) Now to make this completely nice, assign two 'external tools' in VS, one that sets the variable to 0 and one that sets it to 1 (use setx to set environment variables). You can now add these commands to the toolbar, so the only thing you need to do is click a button to specify if prebuild should happen or not.

OTHER TIPS

F5 will only build the project if there are any changes in code. So I don't think you can issue a command that will always trigger an prebuild command when using F5.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top