2010-06-21 113 views
3

我正在使用WIX工具爲我們的項目創建安裝文件。使用WIX自動增加內部版本號

我想擁有動態(增量)內部版本號。所以任何人都可以請指導我。

請不要提供像1.0.0。*這樣的解決方案,因爲這樣會在最後給出任何動態數字。我希望它增量像1.0.0.1,1.0.0.2,1.0.0.3,.....

+0

您是否已經使用持續集成工具?如果是這樣,如果你告訴我們哪一個會更容易;如果不是,那麼你可能首先要考慮這一點。 TeamCity在處理內部版本號方面非常有效。 – pdr 2010-06-21 10:10:09

回答

1

你不能用WiX本身做到這一點。

然而,你可以做的是將你的版本定義爲一個變量。例如:

<Product Id="*" 
     UpgradeCode="$(var.Property_UpgradeCode)" 
     Name="!(loc.ApplicationName)" 
     Language="!(loc.Property_ProductLanguage)" 
     Version="$(var.version)" 
     Manufacturer="!(loc.ManufacturerName)" > 

然後,您可以在命令行上傳遞版本號。下面是使用Nant

<candle 
      out="${dir.obj}\" 
      rebuild="true" 
      extensions="WixUIExtension;WixNetFxExtension"> 
      <defines> 
       <define name="ProcessorArchitecture" value="${release.platform}" /> 
       <define name="SourceDir" value="${dir.source}" /> 
       <define name="version" value="${version}" /> 
       <define name="releasetype" value="${release.type}" /> 
       <define name="Language" value="${language}" /> 
      </defines> 

      <sources> 
       <include name="*.wxs" /> 
      </sources> 
     </candle> 

然後你只處理在您的應用程序:)

1

的方式相同的版本號可以使用msbuild community tasks版本類爲例 如

<PropertyGroup>

<MinorIncrement Condition=" '$(ReleaseType)' == 'Internal' ">None</MinorIncrement> 
    <MinorIncrement Condition=" '$(MinorIncrement)' == '' ">Increment</MinorIncrement> 
    <BuildIncrement>Increment</BuildIncrement> 
    <BuildIncrement Condition=" '$(MinorIncrement)' == 'Increment' ">Reset</BuildIncrement> 
</PropertyGroup> 

<Target Name="BumpVersion"> 
    <Version VersionFile="version.txt" MinorType="$(MinorIncrement)" BuildType="$(BuildIncrement)"> 
     <Output TaskParameter="Major" PropertyName="Major"/> 
     <Output TaskParameter="Minor" PropertyName="Minor"/> 
     <Output TaskParameter="Build" PropertyName="Build"/> 
     <Output TaskParameter="Revision" PropertyName="Revision"/> 
    </Version> 

    <AssemblyInfo CodeLanguage="CS" OutputFile="VersionInfo.cs" AssemblyVersion="$(Major).$(Minor).$(Build).$(Revision)" AssemblyFileVersion="$(Major).$(Minor).$(Build).$(Revision)"/> 
    <Message Text="Version: $(Major).$(Minor).$(Build).$(Revision)"/> 
</Target> 

在上面的部分,我設置了發佈類型的值。不幸的是,這些似乎只是在代碼中記錄。

CruisControl.Net在外部設置ReleaseType。

如果我們有一個ReleaseType爲'Internal',那麼次增量沒有完成,但內部版本號被碰撞,如果沒有,那麼我們增加次要號碼並重置內部版本號。

Version元素將從version.txt中以「1.0.1.3」的形式讀取版本,然後將其讀入一些變量,這些變量就是輸出位的內容(我想!)以供使用在修改程序集信息的位上