Reputation: 18227
I am having a task to find whether the clearcase folder has any changes or not.
<Target Name="CheckChanges" Returns="ItemsFromFile">
<Exec Command="cleartool find "$(FolderPath)" -version "{brtype($(StreamName)) && created_since($(FromDate))}" -print >> Changes.log" />
<ReadLinesFromFile
File="Changes.log" >
<Output
TaskParameter="Lines"
ItemName="ItemsFromFile"/>
</ReadLinesFromFile>
</Target>
<Target Name="Build">
<!-- This target should be executed only when Changes.log file has contents -->
<Target>
If the $(FolderPath) has changes then the contents will be available in Changes.log.
What i would like to do is if the changes.log file contains some lines then run another task Build should run.
How to execute a target based on condition that the file has contents?
Upvotes: 1
Views: 68
Reputation: 1328602
What i would like to do is if the
changes.log
file contains some lines then run another task Build should run.
The issue is that you are redirecting the result of your cleartool find
with '>>
'.
The first execution of the job will initialize the Changes.log
file, and you could setup another job which test for the existence of that file (see MSBuild conditions) with a non-zero size in order to run. (As bit like "verify the existence of a folder using the msbuild extension pack?")
But the second execution would simply add lines (if there are changes), or keep the Changes.log
file unchanged.
That means "Changes.log
" would still "have content" even though the cleartool find
didn't find any changes.
Using '>
' instead of '>>
' would solve that, since it would generate an empty Changes.log
file if the cleartool find
doesn't detect any change, or generate a non-empty file if changes are detected.
Upvotes: 1