Ask a questionAsk a question
 

AnswerBuild failed due to TF.exe Partial success

  • Thursday, March 27, 2008 10:51 AMValery Letroye Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Hi,

     

    We are facing the following issue:

     

    One of our build scripts is updating some AssemblyInfo.cs files and checking them in TFS using the TF.exe command line. However, it sometimes happens that none of these files is actually changed. In such a case, the "TF.exe checkin" command will return a code 1 (I.e.: a Partial Success. With the message "The following changes were not checked in because the items were not modified.") and the complete build process fails...

     

    How could we avoid a build failure when TF.exe return the code 1 ? Or how could we prevent TF.exe to return the code 1 when some files are not checked-in because there are not modified ?

     

    Thx a lot in advance for any solution or advice !

     

    V.

     

     

     

Answers

  • Thursday, March 27, 2008 2:01 PMPatrick CarnahanMSFTUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    You can use the IgnoreExitCode property of the exec task to have it complete successfully regardless of the error code returned from the process. You may then read the ExitCode output property of the task to make a determination as to whether or not you should fail -- I imagine you would want to fail if the exit code is not 0 or 1.

     

    See the following msdn article for help on the exec task.

     

    Patrick

All Replies

  • Thursday, March 27, 2008 2:01 PMPatrick CarnahanMSFTUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    You can use the IgnoreExitCode property of the exec task to have it complete successfully regardless of the error code returned from the process. You may then read the ExitCode output property of the task to make a determination as to whether or not you should fail -- I imagine you would want to fail if the exit code is not 0 or 1.

     

    See the following msdn article for help on the exec task.

     

    Patrick

  • Friday, March 28, 2008 12:38 PMValery Letroye Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

     

    Thanks a lot !!

     

    I was reading this blog to understand the TF return codes : http://blogs.msdn.com/richardb/archive/2007/09/25/tf-checkin-exit-codes.aspx

     

    And following your advice I used this peace of script (in the AfterCompile target) :

    Code Snippet

    <Exec

       Command="$(TF) checkin blablabla"

       IgnoreExitCode="true">

      <Output TaskParameter="ExitCode" PropertyName="TFExitCode"/>

    </Exec>

     

    <!-- Set the Status to Failed if Checking really fails. -->

    <SetBuildProperties

       TeamFoundationServerUrl="$(TeamFoundationServerUrl)"

       BuildUri="$(BuildUri)"

       Status="Failed"

       Condition=" ('$(TFExitCode)' != '0') and ('$(TFExitCode)' != '1') " />

     

    <!-- Create and assign the Bug if the Checkin failed. -->

    <CreateNewWorkItem

      BuildNumber="$(BuildNumber)"

      BuildURI="$(BuildURI)"

      Description="This work item was created by Team Build on a Checkin failure

                   of '$(BuildDefinition)'.&lt;BR&gt;$(BuildlogFile)

                   &lt;BR&gt;$(TestResultsFolder)"

      TeamProject="$(TeamProject)"

      TeamFoundationServerUrl="$(TeamFoundationServerUrl)"

      Title="Checkin failure after the build version $(BuildNumber)

             of '$(BuildDefinition)'"

      WorkItemFieldValues="$(WorkItemFieldValues)"

      WorkItemType="Bug"

      Condition=" ('$(TFExitCode)' != '0') and ('$(TFExitCode)' != '1') "

      ContinueOnError="true" />

     

     

    That's working fine !

     

    V.