开发者

Versioning an assembly info past the UInt16 barrier

开发者 https://www.devze.com 2023-03-08 09:58 出处:网络
In the past ive usually used the changeset or svn number to version the binary e.g. 1.1.123.3 where the large number is the changeset or rev from the source control system.

In the past ive usually used the changeset or svn number to version the binary e.g. 1.1.123.3 where the large number is the changeset or rev from the source control system. However, with the system im now using we are well past the uint barrier at something like 70000+ changesets so that causes an overflow and a compiler error when used as the asssembly version attribute or assembly file version attribute. See: http://msdn.microsoft.com/en-us/library/system.reflection.assemblyversionattribute.aspx

Any alternative strategies that still link binary to changeset?

Ive adapted my task to use the solution given:

<Target Name="Version">
    <!-- Changeset exceeds u16int so cannot be used in Versioninfo-->
    <Attrib   ReadOnly="false" Files="$(VersionFile)"/>
    <!--Assembly version must be made of uint16 this means that the version number must less than 65536-->
    <!-- current changest is way past this so i will make the number changset-50000 and add a number -->
    <!-- so 70000 becomes 20000.1 and 100001 becomes 1.2-->
    <PropertyGroup>
        <Version>$(Branch).$([MSBuild]::Subtract($(ChangeSet),$(Offset))).$(OffsetCount)</Version>
    </PropertyGroup>
    <AssemblyInfo CodeLanguage="CS"
         OutputFile="$(VersionFile)"
         AssemblyCompany="$(Company)"
         AssemblyProduct="$(Product)"
         AssemblyCopyright="$(Copyright)"
         AssemblyVersion="$(Version)"/>

    <Attrib   ReadOnly="true" Fil开发者_Python百科es="$(VersionFile)"/>
</Target>


You can rollover and restart from 0, so you revision will look like revision = 70000 % 50000.

Also you could use build as part of source control revision like build = 70000 / 50000.

So as result it would be x.x.1.20000 in this example.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号