In my build script run by TFS2008 I'm trying to copy all files from folder A to folder B recursively I've managed to do it using task:
<ItemGroup>
<MyFiles Include="$(SolutionRoot)\MyFiles\**" />
</ItemGroup>
<Target Name="CopyFiles">
<Message Text="Copy Files" />
<Copy SourceFiles="@(MyFiles)"
DestinationFolder="$(DeploymentFolder)\SomeFolder\%(RecursiveDir)" />
</Target>
I would like to raise a warning via TFS when MyFiles is empty.
So I have two questions:
How do I raise an warning via TFS?
How do I discover if the ItemGroup contains no files?
开发者_Python百科
1) Warning Task
http://msdn.microsoft.com/en-us/library/92775st5.aspx
2) Use the Msbuildhelpder.ItemCount
http://www.msbuildextensionpack.com/help/4.0.2.0/index.html
And here is an example build file that demonstrates its use:
<Project ToolsVersion="4.0" DefaultTargets="Default;UpdateMetadata" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<TPath>$(MSBuildProjectDirectory)\..\MSBuild.ExtensionPack.tasks</TPath>
<TPath Condition="Exists('$(MSBuildProjectDirectory)\..\..\Common\MSBuild.ExtensionPack.tasks')">$(MSBuildProjectDirectory)\..\..\Common\MSBuild.ExtensionPack.tasks</TPath>
</PropertyGroup>
<Import Project="$(TPath)"/>
<ItemGroup>
<MyFiles Include="$(SolutionRoot)\MyFiles\**" />
</ItemGroup>
<Target Name="Default">
<MSBuild.ExtensionPack.Framework.MsBuildHelper
TaskAction="GetItemCount"
InputItems1="@(MyFiles)">
<Output TaskParameter="ItemCount" PropertyName="MyCount"/>
</MSBuild.ExtensionPack.Framework.MsBuildHelper>
<Warning
Text=" No files in MyFiles collection."
Condition="'$(MyCount)' > '0'" />
</Target>
</Project>
精彩评论