根据您复制并检查输出的文章:
<Copy SourceFiles="@(CompilationOutputs)" DestinationFolder="$(ReplicateSourceFolder)"/>
<Exec Command="$(TF) checkin /comment:"Checking in file from build" "$(ReplicateSourceFolder)" /recursive"/>
您不能在签入之前添加第二个复制行以使用元数据复制 xml 文件吗?
<Copy SourceFiles="%(CompilationOutputs.RootDir)%(CompilationOutputs.Directory)\%(CompilationOutputs.Filename).xml" DestinationFolder="$(ReplicateSourceFolder)"/>
这是另一个使用内联任务的选项,它构建另一个项目组,更改扩展名,以便它只添加实际存在的 doc 文件:
<Target Name="Test">
<ChangeExtension InputFiles="@(CompilationOutputs)" Extension=".xml">
<Output TaskParameter="OutputFiles" ItemName="DocFiles" />
</ChangeExtension>
<Copy SourceFiles="@(CompilationOutputs)" DestinationFolder="$(ReplicateSourceFolder)"/>
<Copy SourceFiles="@(DocFiles)" DestinationFolder="$(ReplicateSourceFolder)"/>
</Target>
<UsingTask TaskName="ChangeExtension" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
<ParameterGroup>
<InputFiles ParameterType="Microsoft.Build.Framework.ITaskItem[]" Required="true"/>
<Extension ParameterType="System.String" Required="true"/>
<OutputFiles ParameterType="Microsoft.Build.Framework.ITaskItem[]" Output="true"/>
</ParameterGroup>
<Task>
<Code Type="Fragment" Language="cs">
<![CDATA[
if (InputFiles.Length > 0)
{
List<TaskItem> results = new List<TaskItem>();
for (int i = 0; i < InputFiles.Length; i++)
{
ITaskItem item = InputFiles[i];
string path = item.GetMetadata("FullPath");
string docfile = Path.ChangeExtension(path, Extension);
if (File.Exists(docfile))
{
results.Add(new TaskItem(docfile));
}
}
OutputFiles = results.ToArray();
}
]]>
</Code>
</Task>
</UsingTask>