从 TFS Team Build 脚本获取 XML 文档文件

发布于 2024-10-07 12:46:43 字数 692 浏览 6 评论 0原文

我在 TFS 环境中基于 http://geekswithblogs.net/jakob/archive/2009/03/05/implementing-dependency-replication-with-tfs-team-build.aspx

这使用 CompilationOutputs 项目组来获取构建的 DLL 文件并将它们分支/合并到依赖项目中。我的问题是,CompilationOutputs 项组仅包含 DLL,并且我还想包含 XML 文档文件,以便在使用这些库时可以获得智能感知文档提示。是否有包含这些的不同项目组或不同的方法?我是否需要手动查找 xml 文件并将它们添加到项目组中?

我们现在使用的是 TFS 2010,所以如果有新的东西,我们可以尝试利用它(尽管如果我不必将整个方案转换为使用工作流程流程,那就太好了...)

I have a dependency replication scheme setup in our TFS environment based on http://geekswithblogs.net/jakob/archive/2009/03/05/implementing-dependency-replication-with-tfs-team-build.aspx.

This uses the CompilationOutputs item group to get the built DLL files and branch/merge them into dependent projects. My problem is that the CompilationOutputs item group only contains the DLLs, and I'd like to also include the XML documentation files, so I can get intellisense documentation tips when using these libraries. Is there a different item group that contains these, or a different approach? Do I need to manually find the xml files and add them to an item group?

We're on TFS 2010 now, so if there's something new there, we can try to take advantage of it (though it'd be nice if I didn't have to convert this whole scheme to use a Workflow process...)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

谁把谁当真 2024-10-14 12:46:44

根据您复制并签入输出的文章:

<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)"/>

这是使用内联任务的另一个选项,该任务构建另一个项目组,更改扩展名,以便仅添加实际存在的文档文件:

 <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>

According to the article you copy and checkin the outputs:

<Copy SourceFiles="@(CompilationOutputs)" DestinationFolder="$(ReplicateSourceFolder)"/>
<Exec Command="$(TF) checkin /comment:"Checking in file from build" "$(ReplicateSourceFolder)" /recursive"/>

Couldn't you add a second copy line before the checkin to copy the xml files using the metadata?

<Copy SourceFiles="%(CompilationOutputs.RootDir)%(CompilationOutputs.Directory)\%(CompilationOutputs.Filename).xml" DestinationFolder="$(ReplicateSourceFolder)"/>

Here is another option using an inline task that builds another item group changing the extension so that it only adds doc files that actually exist:

 <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>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文