I am using WIX tool fo开发者_C百科r creating installation file for our project.
I want to have the dynamic(incremental) build number. So can anyone please guide me.
Please dont provide solution like 1.0.0.* as this gives any dynamic number at end. I want it incremental like 1.0.0.1, 1.0.0.2, 1.0.0.3,.....
You can't do this with WiX natively.
What you can do however, is define your version as a variable. e.g.:
<Product Id="*"
UpgradeCode="$(var.Property_UpgradeCode)"
Name="!(loc.ApplicationName)"
Language="!(loc.Property_ProductLanguage)"
Version="$(var.version)"
Manufacturer="!(loc.ManufacturerName)" >
Then you can pass in the version number on the command line. Here's an example using 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>
Then you just handle the version number in the same way you do for your application :)
You can use the msbuild community tasks Version class eg
<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>
In the top section I'm setting values for the release types. Unfortunately these only seem to be documented in code.
CruisControl.Net is setting the ReleaseType externally.
If we have a ReleaseType of 'Internal' then the minor increment is not done but the build number is bumped and if it isnt then we increment the minor number and reset the build number.
The Version element will read the version from version.txt, in the form "1.0.1.3", do stuff to it and then read it into some variables that's what the output bit is about (I think!) for use in the bit that modifies the assembly info
The preprocessor supports the following functions:
<Product Version="$(fun.AutoVersion(1.0))"...</Product>
Gets an auto generated version number using the same scheme as .NET AssemblyVersion attribute. The parameters x.y specify the major and minor verion number, the build is set to the number of days since 1/1/2000 and revision to the number of seconds since midnight divided by 2. Both values are calculated using UTC.
https://wixtoolset.org/documentation/manual/v3/overview/preprocessor.html
精彩评论