Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Support Legacy NuGet Versioning major.minor.build.revision[-prerelease] #709

Open
NightOwl888 opened this issue Jan 3, 2022 · 1 comment

Comments

@NightOwl888
Copy link

NightOwl888 commented Jan 3, 2022

From the discussion in #708.

I realize that this isn't supported by all package managers, but there are some use cases (patching a port) where it makes sense to have a 4-th version component, as well as the ability to have 4 component version numbers with a prerelease label.

image

Of course, this should be a non-default option. It isn't clear what to do for NPM version, but I would suggest either leaving it as a 3-component number or throwing an exception when this option is enabled.

This article demonstrates that the major.minor.build.revision[-prerelease] is a legacy format that historically has been supported by NuGet.

The change should update both FileVersion and AssemblyInformationalVersion to use 4 segments as well as NuGetPackageVersion.

NuGetPackageVersion: 0.5.0.1-beta-0001-gea31be2201
[assembly: AssemblyFileVersion("0.5.0.1")]
[assembly: AssemblyInformationalVersion("0.5.0.1-beta-0001+ea31be2201")]
[assembly: AssemblyVersion("0.4.1.0")]
@NightOwl888
Copy link
Author

For our temporary workaround for this feature, we ended up reworking the logic for forcing non-zero version numbers to automatically "bump" it to 4 components, but only if 4 components are provided. Otherwise, it will be 3 components.

https://github.com/NightOwl888/ICU4N/blob/feee8ab599f4664a9115ecf6ca5d05575b9403d9/.build/version.ps1#L48-L60

function Force-ThreeOrFourComponents([version]$version) {
    
    [int]$maj = [Math]::Max(0, $version.Major)
    [int]$min = [Math]::Max(0, $version.Minor)
    [int]$bld = [Math]::Max(0, $version.Build)
    [int]$rev = $version.Revision

    if ($rev -gt 0) {
        return New-Object System.Version -ArgumentList @($maj, $min, $bld, $rev)
    } else {
        return New-Object System.Version -ArgumentList @($maj, $min, $bld)
    }
}

The differences in comparison logic and defaulting are a bit subtle from the way NerdBank.GitVersioning currently does it, but this is what ultimately works to allow 4 components without requiring 4 components.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants