views:

790

answers:

1

We have a process that runs prior to our nightly builds. If the process fails it generates a text file. All I need to do is check to see if the file exists, and if it does, cause a failing MSBuild.

I currently have tried the following:

<CreateProperty Condition="Exists('C:\Process\Fail.txt')"
      Value="false">
  <Output TaskParameter="Value" PropertyName="ProcessTestPassed"/>
</CreateProperty>
<Message Text="Process did not pass" Condition="Exists('C:\Process\Fail.txt')" ContinueOnError="false" />

<ReadLinesFromFile File="C:\Process\Fail.txt"                  Condition="'$(ProcessTestPassed)'=='false'" ContinueOnError="false" >
  <Output TaskParameter="Lines" ItemName="FileContents" />
</ReadLinesFromFile>
<Message Text="FileContents: $(FileContents)"  Condition="'$(ProcessTestPassed)'=='false'" ContinueOnError="false" />

Which gives a passing build with this output:

Task "CreateProperty"
Done executing task "CreateProperty".
Task "Message"
  QAWizardProTestPassed did not pass
Done executing task "Message".
Task "ReadLinesFromFile"
Done executing task "ReadLinesFromFile".
Task "Message"
  FileContents: 
Done executing task "Message".

I know the above is probably overkill, but I just need something working! What am I missing here?!

Thanks, Derek

A: 

As noted by @dprice in his comment, the best solution for this would be:

<Error Condition="Exists('C:\Process\Fail.txt')" Text="Process did not pass!" />
Bruno Lopes