我想使用MSBuild社區任務中的VersionTask來設置Revision計算類型。但是,我很難理解如何在我的csproj文件中實際連接任務。如何在csproj文件中使用Msbuild.Community.Tasks.Version
該項目具有規定的下列屬性的AssemblyInfo.cs中:
[assembly: AssemblyVersion("3.2.5.*")]
我想要做的是過度乘坐版本號與自己的自定義操作處理的產生。
我已經把定製版任務到的csproj文件,如下所示:
<UsingTask TaskName="MyCo.Build.Tasks.Version" AssemblyFile="$(SolutionDir)\..\Build\.build\MyCo.Build.Tasks.dll" />
實際的任務,然後調用如下:
<Target Name="BeforeBuild">
<Message Text="Setting Revision Number to $(BuildNumber)" />
<MyCo.Build.Tasks.Version RevisionType="BuildServerNumber" Revision="$(BuildNumber)" /></Target>
我可以看到目標BeforeBuild被調用,因爲的消息任務,但exe文件仍然有標準生成編號如下:文件版本:3.2.5.27547
我期待像3.2.5.1 11(作爲參數傳入MSBuild的內部版本號)。
由於Version任務覆蓋默認處理'*'值的版本,我不認爲有必要實際修改AssemblyInfo.cs文件。
我是否需要將Version任務的輸出值傳遞給MSBuild參數?我是否真的需要使用AssemblyVersion任務來更新文件中的值?
很顯然,我試圖避免不得不改變AssemblyInfo.cs,我只是想重寫版本號處理。
有人可以提醒嗎?
編輯:我剛剛在安裝程序的部分回答我的問題的chm文件中找到以下使用示例。
<Version BuildType="Automatic" RevisionType="Automatic" Major="1" Minor="3" >
<Output TaskParameter="Major" PropertyName="Major" />
<Output TaskParameter="Minor" PropertyName="Minor" />
<Output TaskParameter="Build" PropertyName="Build" />
<Output TaskParameter="Revision" PropertyName="Revision" />
</Version>
<Message Text="Version: $(Major).$(Minor).$(Build).$(Revision)"/>
然而,當我運行構建我可以輸出生成的程序集版本在消息的任務,但exe文件仍然有默認的修訂爲之前