views:

265

answers:

2

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??

A: 

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.

Webleeuw
the idea is to only trigger the prebuild comand when i click build solution/project and dont trigger it when using F5(start debugging)
ase69s
A: 

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.
stijn
But in the end you have to be always tweaking something each time you want to do a debug/release, the good thing would be some condition or trick so it distinguises how you started the build...by build solution(Ctrl+Shift+B) or by debugging(F5)
ase69s
you can remap those key combinations to two simple macros: one to enable the condition and perform a build, another one to disable the condition, then build and run debugger
stijn