How To Disable Pre/Post Build Events When Using Team Build

3 בפברואר 2009

3 תגובות

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

הוסף תגובה
facebook linkedin twitter email

כתיבת תגובה

האימייל לא יוצג באתר. (*) שדות חובה מסומנים

3 תגובות

  1. Shahar22 במרץ 2009 ב 17:17

    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.

    להגיב
  2. Kenander4 בספטמבר 2009 ב 10:39

    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…

    להגיב
  3. George10 בספטמבר 2009 ב 2:01

    This solution seemed to be what worked for me.

    Do stuff locally להגיב