Home > Enterprise >  VersionRevision always 0 in Assembly version
VersionRevision always 0 in Assembly version

Time:10-27

Since we don't have any access to the pipeline and just using git because of restrictions, I thought of having the versioning this way:

1..<month&day>. e.g. 1.22.1026.903

Problem is the VersionRevision always return 0

<PropertyGroup>
        <VersionMajor>1</VersionMajor>
        <VersionMinor>$([System.Int64]::Parse($([System.DateTime]::UtcNow.Date.ToString("yy"))))</VersionMinor>
        <VersionPatch Condition="'$(VersionPatch)' == ''">$([System.Int64]::Parse($([System.DateTime]::UtcNow.Date.ToString("MMdd"))))</VersionPatch>
        <VersionRevision Condition="'$(VersionRevision)' == ''">$([System.Int64]::Parse($([System.DateTime]::UtcNow.Date.ToString("HHmm"))))</VersionRevision>
    </PropertyGroup>
    
    <PropertyGroup>
        <TargetFramework>netcoreapp3.1</TargetFramework>
        <Version>$(VersionMajor).$(VersionMinor).$(VersionPatch).$(VersionRevision)</Version>
        <Deterministic>False</Deterministic>-->
    </PropertyGroup>

Tested static with leading zeroes and it was fine.

<VersionRevision Condition="'$(VersionRevision)' == ''">$([System.Int64]::Parse("0903"))

CodePudding user response:

Using Date property returns a new DateTime with the same date, but the time is set to 00:00:00 thus the VersionRevision is 0000. So removing Date should solve the problem.

Also, as mentioned in the comment to the question, the Int64.Parse is redundant.

  • Related