Skip to content

Version string for both stable and pre-release NuGet builds  #283

@asbjornu

Description

@asbjornu

I don't think GitVersion supports this scenario, so I'll just describe it and hope someone can point me in the right direction if this is already possible. If not, this can be considered a feature request.

I'd love to have a single build configuration across all branches of a project that ends up in a NuGet package. Stable releases should only be built from master and have AssemblyInformationalVersion and NuGet version set to:

  • {major}.{minor}.{patch}.{buildmetadata}

All other branches (development, feature branches, etc.) should have AssemblyInformationalVersion and NuGet version set to:

  • {major}.{minor}.{patch}.{buildmetadata}-{branchname}

The -{branchname} part will ensure that NuGet treats the package as a prerelease. This conditional switching on whether the -{branchname} part should be included (which it shouldn't on master builds), makes it difficult to just pass a variable to the "NuGet Pack" build step or have it use AssemblyInformationalVersion.

It seems like I should be able to use the system.GitVersion.NuGetVersion variable, but it seems to lack both {buildmetadata} and {branchname} (for both master and feature branches), so that won't work. system.GitVersion.InformationalVersion won't work either, since it contains {fullbuildmetadata} for both master and feature branch builds (which would cause master branch builds to end up as prerelease packages in NuGet).

So, I'm wondering if the variable I'm after exists. If it doesn't, I'd highly appreciate if it was added.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions