2009-11-20 168 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)"'/> 

相關問題