2009-11-20 166 views
2

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

回答

0

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

http://msbuildtasks.tigris.org/

4

没有求助于自定义生成的任务,你可以尝试使用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得到了这个例子。

+0

尼斯......你可能要添加的命令行工具,你在道路,所以如果你移动到x64构建中,您不必更新编译文件。 –

0

查看CodePlex上的SDC Tasks Library。这是一组定制的MSBuild任务,包括签入和签出任务(请参阅随附文档中的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”。

0

我们的团队有几个小项目输出其他几个项目使用的DLL。我们发布的一部分是发布这些DLL。我为此使用了AfterDropBuild目标。希望我的构建脚本代码段中的注释足以清楚地表明我正在做什么。

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

相关问题