How To: Bypass Post-Build Steps in a Build Lab Environment

(Can you tell I’m going through my folder of interesting MSBuild questions today?)

Here’s another good question that came across our internal discussion alias last week:

Is there a quick and easy way to bypass the PostBuild steps in a project file that was created with VS.NET 2005? I am trying to set up a master build project that will be compiling a large number of other projects, some that contain PostBuild steps that are not appropriate for our master build. Is there something I can define that will then cause the PostBuild steps to be skipped?

I actually didn’t know the answer to this one off the top of my head, but since the entire build process is available for the world to see, it didn’t take much to figure it out. I cracked open the Microsoft.Common.Targets file in Visual Studio and looked at how the PostBuildStep is set up. Here’s an excerpt from the file:

<Target Name=”PostBuildEvent” Condition=”‘$(PostBuildEvent)’!=” and […]>

Notice how the condition is set up. In the build lab, you can simply pass /p:PostBuildEvent=”” on the command line to disable all the post build events in the included projects.

[ Author: Neil Enns ]

Comments (4)

  1. Keyboard Trampler says:

    simply pass /p:PostBuildEvent="" on the command line

    Command line to what? VCBuild doesnt like that….

  2. manjusha says:

    Can you help me achieving this same thing in case of NAnt builds?

  3. Alan says:

    manjusha I had the same issue and here is how I resolved the issue.

    Bypass post build events using nant you need to add the following to the nant msbuild tag.

    <property name="PostBuildEvent" value="" />

    Hope this help.

  4. Peter says:

    Another Question: How to run postevent without the source code compiling?