tags:

views:

809

answers:

4

I am using msbuild to build a C++ project and I want to suppress the 'Post-Build Event'. I have tried the following properties with no success:

/property:PostBuildEvent=
/property:VCPostBuildEventTool=

Neither will make any difference and the post build events are still executed.

Does anyone know how to suppress these (and potentially other) events using msbuild?

A: 

Have you tried setting the build event to something other than blank? If you overwrite it with something superfluous, like a "dir" or something, does it still execute the original post-build steps?

It's not the most elegant solution, but it might work.

Paul Fedory
I tried this with no success.
Rob
A: 

Ack, it looks like msbuild actually calls vcbuild which isn't as flexible, so I think I'm stuck.

Rob
A: 

If you are able to modify the post-build events, you could do this with an environment variable, say SKIP_POST_BUILD_EVENTS. You can then set that environment variable before calling msbuild, and check whether the variable exists in the post-build event before executing whatever code is there.

Sunlight
+2  A: 

I just figured out how to do this. There's 2 steps involved:

First, if you're not starting the msbuild process using a batch file already, create a batch file that calls the msbuild process. Then add a variable in the batch file before you call the msbuild process. Something like this:

set ISFULLBUILD=True
msbuild TFSBuild.proj >> BuildOutput.txt

Then, you need to modify your post build event to only do something if the variable is not set, or has the wrong value:

IF NOT '%ISFULLBUILD%'=='True' copy /y $(TargetFileName) "..\..\..\..\..\..\Binaries\$(ConfigurationName)\"

In this case - the TargetFileName (Whatever.dll) will only get copied when you're building from Visual Studio. But, when you build using your new batch file - it will NOT execute the command after the IF statement.

leftend