How To Disable Pre/Post Build Events When Using Team Build
Some times you like to create Pre or Post build events in your project and you don’t like it to be executed when doing a build using the automation build system, so what can you do?
There is a property called “SkipPostBuild” in the build’s targets file, setting it to true will only result with skipping the Team Build post events and not the project post event.
In order to skip the project pre/post build events do the following:
Step 1: Open the proj file of the project in notepad or any text or XML editor.
Step 2: Find the “PropertyGroup” holding the property “PreBuildEvent” or “PostBuildEvent” looking like that:
<PropertyGroup>
<PostBuildEvent>Some text…</PostBuildEvent>
</PropertyGroup>
or…
<PropertyGroup>
<PreBuildEvent>Some text…</PreBuildEvent>
</PropertyGroup>
Modify the file with the following for Post Build Events:
You need to make an extra copy first and than add condition to each property group, see that when the condition of the property contains a value the inner property is empty means do nothing.
<PropertyGroup Condition=" ' $(TeamBuildConstants) ' == ' '>
<PostBuildEvent>Some text…</PostBuildEvent>
</PropertyGroup>
<PropertyGroup Condition=" ' $(TeamBuildConstants) ' == '_TEAM_BUILD_ '>
<PostBuildEvent></PostBuildEvent>
</PropertyGroup>
Modify the file with the following for Pre Build Events:
You need to make an extra copy first and than add condition to each property group, see that when the condition of the property contains a value the inner property is empty means do nothing.
<PropertyGroup Condition=" ' $(TeamBuildConstants) ' == ' '>
<PreBuildEvent>Some text…</PreBuildEvent>
</PropertyGroup>
<PropertyGroup Condition=" ' $(TeamBuildConstants) ' == '_TEAM_BUILD_ '>
<PreBuildEvent></PreBuildEvent>
</PropertyGroup>
Have Fun!!!