Ask a questionAsk a question
 

AnswerUsing CompilationStatus as a condition in AfterDropBuild

  • Thursday, September 11, 2008 12:22 PMrizopoulos Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    I have a set of Exec tasks that I want to run in the AfterDropBuild target of a TFS 2008 build project.
    I want them to run only if compilation has succeeded (actually only if the build is successful up to that point (so partial success will not trigger them).

    So I want something like <Exec Condition="'$(CompilationStatus)'=='Succeeded'" Command="do_the_voodoo"/>

    $(CompilationStatus) returns 'Unknown' when evaluated in AfterDropBuild.
    How can I determine the compilation status in AfterDropBuild?

    Thanks in advance,
    V.-

Answers

  • Wednesday, September 17, 2008 3:05 AMHua ChenMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    Hello V,

     

       It is a warning. The VS doesn't find all the tasks. We can check in the TFSBuild.proj file and run it.

     

       More in GetBuildProperties Task.  It is declared at the Microsoft.TeamFoundation.Build.targets file.

     

      Here is an example of AfterDropBuild target.

     

       <Target Name="AfterDropBuild">

     

        <GetBuildProperties TeamFoundationServerUrl="$(TeamFoundationServerUrl)"
                             BuildUri="$(BuildUri)"
                             Condition=" '$(IsDesktopBuild)' != 'true' ">
          <Output TaskParameter="CompilationSuccess" PropertyName="LocalCompilationSuccess" />
        </GetBuildProperties>


        <Message Text="LocalCompilationSuccessEmbarrassed(LocalCompilationSuccess)"></Message>

     

      </Target>

     

       Please put the target at end of the TFSBuild.proj file before </Project> tag,

     

       Here is build log of the target.

     

       Target "AfterDropBuild" ***************************************************************

     

        Task "GetBuildProperties"


        GetBuildProperties TeamFoundationServerUrl="http://<ServerName>:8080/" BuildUri="vstfs:///Build/Build/218"

         Done executing task "GetBuildProperties".


        Task "Message"


        LocalCompilationSuccess:True

        Done executing task "Message". 

     

        Sorry the flag is True not true.

     

        Good luck.

All Replies

  • Friday, September 12, 2008 8:50 AMHua ChenMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

      Hello,

     

        You can get properties which indicate whether compile or test is ok at the AfterDropBuild target.

     

        <GetBuildProperties TeamFoundationServerUrl="$(TeamFoundationServerUrl)"
                            BuildUri="$(BuildUri)"
                            Condition=" '$(IsDesktopBuild)' != 'true' ">
          <Output TaskParameter="TestSuccess" PropertyName="LocalTestSuccess" />
         </GetBuildProperties>

     


         <GetBuildProperties TeamFoundationServerUrl="$(TeamFoundationServerUrl)"
                            BuildUri="$(BuildUri)"
                            Condition=" '$(IsDesktopBuild)' != 'true' ">
          <Output TaskParameter="CompilationSuccess" PropertyName="LocalCompilationSuccess" />
         </GetBuildProperties>
      

     

          Please check LocalCompilationSuccess property or the LocalTestSuccess property.

     

        Like While compile is ok invoke the do_the_voodoo,

     

       <Exec Condition="'$(LocalCompilationSuccess)'=='true'" Command="do_the_voodoo"/>

       While test is ok, invoke the do_the_voodoo,

     

        <Exec Condition="'$(LocalTestSuccess)'=='true'" Command="do_the_voodoo"/>


        Good luck.

     

  • Friday, September 12, 2008 10:56 AMrizopoulos Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Unfortunately GetBuildProperties is not available in AfterDropBuild.
    I get "The element 'Target' in namespace ... has invalid child element".
    Is there a file that I need to import in order for the XML to be valid?
    Cheers,
    V.-
  • Wednesday, September 17, 2008 3:05 AMHua ChenMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    Hello V,

     

       It is a warning. The VS doesn't find all the tasks. We can check in the TFSBuild.proj file and run it.

     

       More in GetBuildProperties Task.  It is declared at the Microsoft.TeamFoundation.Build.targets file.

     

      Here is an example of AfterDropBuild target.

     

       <Target Name="AfterDropBuild">

     

        <GetBuildProperties TeamFoundationServerUrl="$(TeamFoundationServerUrl)"
                             BuildUri="$(BuildUri)"
                             Condition=" '$(IsDesktopBuild)' != 'true' ">
          <Output TaskParameter="CompilationSuccess" PropertyName="LocalCompilationSuccess" />
        </GetBuildProperties>


        <Message Text="LocalCompilationSuccessEmbarrassed(LocalCompilationSuccess)"></Message>

     

      </Target>

     

       Please put the target at end of the TFSBuild.proj file before </Project> tag,

     

       Here is build log of the target.

     

       Target "AfterDropBuild" ***************************************************************

     

        Task "GetBuildProperties"


        GetBuildProperties TeamFoundationServerUrl="http://<ServerName>:8080/" BuildUri="vstfs:///Build/Build/218"

         Done executing task "GetBuildProperties".


        Task "Message"


        LocalCompilationSuccess:True

        Done executing task "Message". 

     

        Sorry the flag is True not true.

     

        Good luck.