Using CompilationStatus as a condition in AfterDropBuild
- 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
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="LocalCompilationSuccess
(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:TrueDone executing task "Message".
Sorry the flag is True not true.
Good luck.
All Replies
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.- 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.- 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="LocalCompilationSuccess
(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:TrueDone executing task "Message".
Sorry the flag is True not true.
Good luck.


