2013-12-17 21 views
0

一個預生成事件我有Visual Studio中的C#/ ASP.NET MVC項目2013最佳實踐自動化SVN結賬與MSBuild的

什麼是自動化的SVN結帳作爲預構建的最佳途徑事件與MSBuild。我有兩個選項工作,但我不知道什麼被認爲是最好的。

第一種方式是在的csproj文件:

<Target Name="BeforeBuild"> 
    <Exec ContinueOnError="false" Command="svn co --username my_username --password my_password https://my.repository $(MSBuildProjectDirectory)\my\subdirectory" /> 
</Target> 

二是右擊工程 - >屬性 - >生成事件 - >預生成事件命令行:

svn co --username my_username --password my_password https://my.repository $(ProjectDir)\my\subdirectory

回答

0

我偏向第一個。

的預生成命令將文本添加到相應的字段在項目屬性面板中就解決這個標記:

<PropertyGroup> 
    <PreBuildEvent>svn co --username my_username --password my_password https://my.repository $(ProjectDir)\Clients\LostGarden</PreBuildEvent> 
    </PropertyGroup> 

的@(PreBuildEvent)的ItemGroup會再Microsoft.Common.Targets進行處理:

<PropertyGroup> 
    <PreBuildEventDependsOn></PreBuildEventDependsOn> 
    </PropertyGroup> 
    <Target 
     Name="PreBuildEvent" 
     Condition="'$(PreBuildEvent)'!=''" 
     DependsOnTargets="$(PreBuildEventDependsOn)"> 

    <Exec WorkingDirectory="$(OutDir)" Command="$(PreBuildEvent)" /> 

    </Target> 

下一步將是你定義的輸入和輸出爲您BeforeBuild目標允許它建立逐步使SVN電話:)