DCSIMG
How To Disable Pre/Post Build Events When Using Team Build - SRL Group

SRL Group

This blog is about Team System, QA and Development methodologies and more...

VSTS Resources

Team System Bloggers

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

Comments

Team System News said:

The SRL Team Blog on How To Disable Pre/Post Build Events When Using Team Build , TF30224 error when

# February 13, 2009 4:47 PM

Shahar said:

Not as neat a solution but also works is to end the build event command with:

exit 0

This will make it always end with no error.

# March 22, 2009 5:17 PM

Kenander said:

When I'm adding a new post build event in visual studio's post-build event UI, a new propery group (with no conditions) is added to the solution, and again corrupts the build. Is there any solution to this problem, or to i have to manually edit the .csproj file in the future...

# September 4, 2009 10:39 AM

George said:

This solution seemed to be what worked for me.

<PropertyGroup Condition="$(IsDesktopBuild)=='true' Or $(IsDesktopBuild)==''">

   <PreBuildEvent>Do stuff locally</PreBuildEvent>

 </PropertyGroup>

 <PropertyGroup Condition="$(IsDesktopBuild)=='false'">

   <PreBuildEvent></PreBuildEvent>

 </PropertyGroup>

# September 10, 2009 2:01 AM

Nothing geeky... said:

As you might already know, VS 2011 Beta was announced a week back along with Win 8 consumer preview

# March 8, 2012 1:30 AM
Leave a Comment

(required) 

(required) 

(optional)

(required) 


Enter the numbers above: