【问题标题】:Visual Studio Build Tasks - TFS OperationsVisual Studio 构建任务 - TFS 操作
【发布时间】:2009-11-20 12:42:24
【问题描述】:

我正在寻找扩展一些后期构建任务以包括签出然后签入 DLL。我们正在使用 TFS,我知道有命令行工具可以做到这一点。我不知道如何将这些集成到我现有的后期构建任务中。现在我的后期构建任务很简单,并通过项目属性在 Visual Studio 中进行管理。最终我想将我的自定义构建任务分解为外部文件并调用它们,但这是另一个问题的主题;)

【问题讨论】:

    标签: visual-studio tfs msbuild


    【解决方案1】:

    不求助于自定义构建任务,您可以尝试使用Team Foundation Source Control Command-Line tool (tf.exe)。

    下面的例子展示了如何使用 tf.exe 从 TFS 中检出一个文件。

    <PropertyGroup>
        <TfCommand>
            &quot;C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\tf.exe&quot;
        </TfCommand>
    </PropertyGroup>
    
    <Target Name="AfterCompile">
        <Exec Command="$(TfCommand) get /force /noprompt &quot;$(SolutionRoot)\sources\example.cs&quot;"
            ContinueOnError="true" />
        <Exec Command="$(TfCommand) checkout &quot;$(SolutionRoot)\sources\example.cs&quot;"
            ContinueOnError="true"/>
    </Target>
    

    将其包含在您自己的 MSBuild 项目文件中。

    这个例子没有做任何有用的事情,你需要改变它以适应你的环境,但也许它会给你一个开始。

    我从tfsbuild.com得到这个例子。

    【讨论】:

    • 很好...您可能希望将命令行工具添加到您的 PATH 中,因此如果您移动到 ​​x64 构建框,则不必更新构建文件。
    【解决方案2】:

    您可以使用 Team Foundation Server client APITeamFoundationServer 是允许您连接到服务器、列出和操作 TFS 项目的基类。

    【讨论】:

      【解决方案3】:

      Msbuildtasks 有一些带有源代码(它的开源)的 msbuild 扩展。您可以使用它来创建自己的签入/签出功能。 (结合 Darin 的建议)

      http://msbuildtasks.tigris.org/

      【讨论】:

        【解决方案4】:

        看看 CodePlex 上的SDC Tasks Library。它是一组自定义 MSBuild 任务,其中包括 Checkin 和 Checkout 任务(请参阅随附文档中的 Microsoft.Sdc.Tasks.SourceTfs 命名空间)。您可以将这些任务合并到项目文件的“AfterBuild”目标中。

        <SourceTfs.Checkout Path="Path" TfsVersion="tfsVersion"
        WorkingDirectory="workingDirectory"/>
        
        <SourceTfs.Checkin Path="Path" Comments="Comments" TfsVersion="tfsVersion" 
        WorkingDirectory="workingDirectory" Override="overrideText"/>
        

        您可以根据需要将 TfsVersion 设置为“2005”或“2008”。

        【讨论】:

          【解决方案5】:

          我们的团队有几个小项目,它们输出被其他几个项目使用的 DLL。我们发布的一部分是发布这些 DLL。我为此使用 AfterDropBuild 目标。希望我的构建脚本 sn-p 中的 cmets 足够清晰,可以显示我在做什么。

          <!-- Get a reference to the new release address finalizer DLL and the existing published address finalizer DLL  -->
          <PropertyGroup>
            <ReleaseDLL>$(DropLocation)\$(BuildNumber)\Release\Address_Finalizer.dll</ReleaseDLL>
            <PublishedFolder>$(SolutionRoot)\3rd Party\bin\PG File Import</PublishedFolder>
            <PublishedDLL>$(PublishedFolder)\Address_Finalizer.dll</PublishedDLL>
          </PropertyGroup>
          
          <!-- Check out the published DLL -->
          <Exec WorkingDirectory="$(SolutionRoot)" Command='$(TfCommand) checkout /lock:checkout "$(PublishedDLL)"'/>
          
          <!-- Copy release to published -->
          <Copy SourceFiles="$(ReleaseDLL)" DestinationFolder="$(PublishedFolder)"/>
          
          <!-- Check in the published DLL -->
          <Exec WorkingDirectory="$(SolutionRoot)" Command='$(TfCommand) checkin /override:Automated /noprompt /comment:"$(VersionComment)" "$(PublishedDLL)"'/>
          

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 2019-04-24
            • 2019-01-15
            • 2017-07-30
            • 2018-07-04
            • 1970-01-01
            • 2015-08-15
            • 2016-05-24
            相关资源
            最近更新 更多