How can I check core compile of the Build was successful?
-
Sunday, July 29, 2007 6:24 AM
Hello,
I am using the AfterDropBuild target to do custom actions like copy the compiled output to an IIS mapped folder.
This looks something like this:
Code Snippet<
Target Name="AfterDropBuild"><
MakeDir Directories="$(SourceLocation)\ServicesWeb\log" /><!--
copy all published files to the IIS folder --><
CreateItem Include="$(BinariesRoot)\Debug\_PublishedWebsites\ServicesWeb\**\*.*" ><
Output ItemName="FilesToCopyPublished" TaskParameter="Include" /></
CreateItem><
Copy SourceFiles="@(FilesToCopyPublished)" DestinationFiles="@(FilesToCopyPublished->'$(SourceLocation) \ServicesWeb\%(RecursiveDir)%(Filename)%(Extension)')" /></
Target>Now I am thinking about the worst case - having a solution in the source control which is not compileable.
If this would be the case my IIS Website would not run anymore, because the AfterDropBuild will be fired and bad files are copied into the directory.
So - How can I check, that the core compile of the Team Build was succesful and stop the AfterDropBuild target?
Thanks a lot for your answers,
Peter
Answers
-
Wednesday, August 01, 2007 1:44 PM
Hi Peter,
Sorry, this may be the case if you are using the Whidbey (2005) version of Team Build. BuildBreak should be set correctly in our Orcas release. If BuildBreak does not work, you should be able to override BeforeOnBuildBreak and add your own custom property to check. In the example below, I create a property called BuildFailed and set it to true.
Code Snippet<
Target Name="BeforeOnBuildBreak"><CreateProperty Value="true">
<Output TaskParameter="Value" PropertyName="BuildFailed" />
</CreateProperty>
</Target>
<Target Name="AfterDropBuild" Condition=" '$(BuildFailed)'!='true' ">
...
</Target>
Let me know if this works for you.
Thanks,
Jon
All Replies
-
Monday, July 30, 2007 12:44 PM
Hi Peter,
You can add a condition to your target that verifies $(BuildBreak) is not true. This is a property we set when core compilation does not succeed.
<
Target Name="AfterDropBuild" Condition=" '$(BuildBreak)'!='true' ">...
</
Target>Similarly, you could choose to add the condition to the individual tasks you call. For example,
<
Target Name="AfterDropBuild"><Message Text="Build was successful" Condition=" '$(BuildBreak)'!='true' " />
</
Target>Thanks,
Jon
-
Monday, July 30, 2007 3:27 PM
Hello Jon,
thanks a lot - I was searching a long time for this condition and now I can work with it.
Addition:
I have tested the Condition '$(BuildBreak)'!='true' with a solution which has multiple project files to compile. One project in the middle of the compile order has thrown an error and the following projects in the solution compiles with no error.
Will the following project override the BuildBreak property with "true"?
Best regards,
Peter
-
Tuesday, July 31, 2007 4:00 PM
Yes, if one of the projects in a solution fails to compile the value of $(BuildBreak) will be true when AfterDropBuild is executed.
Thanks,
Jon
-
Wednesday, August 01, 2007 1:03 PM
Hello Jon,
I am running into trouble again, because the BuildBreak doesn´t work.
With the following Target AfterDropBuild in my TFSBuild.proj:
<
Target Name="AfterDropBuild" Condition=" '$(BuildBreak)'!='true' " ><
Message Text="BuildBreak has the value: '$(BuildBreak)'" Importance="high" /></
Target>And a solution with a project which is forced by me to throw an compile error, I´ll get a message in the Build log:
.....
Target AfterDropBuild:
BuildBreak has the value: ''
Target CreateWorkItem:.....
So the AfterDropBuild target won´t listen to the condition:
Can you please tell me what I am doing wrong?
Thanks a lot,
Peter
-
Wednesday, August 01, 2007 1:44 PM
Hi Peter,
Sorry, this may be the case if you are using the Whidbey (2005) version of Team Build. BuildBreak should be set correctly in our Orcas release. If BuildBreak does not work, you should be able to override BeforeOnBuildBreak and add your own custom property to check. In the example below, I create a property called BuildFailed and set it to true.
Code Snippet<
Target Name="BeforeOnBuildBreak"><CreateProperty Value="true">
<Output TaskParameter="Value" PropertyName="BuildFailed" />
</CreateProperty>
</Target>
<Target Name="AfterDropBuild" Condition=" '$(BuildFailed)'!='true' ">
...
</Target>
Let me know if this works for you.
Thanks,
Jon
-
Wednesday, August 01, 2007 2:07 PM
Jippie, now it works.
Thanks a lot John

