Skip to content

GitVersion.MSBuild with Packable .NET 8 project does not get valid SemVer #4110

Description

@peter-friedland-t2i

Prerequisites

  • I have written a descriptive issue title
  • I have searched issues to ensure it has not already been reported

GitVersion package

GitVersion.MsBuild

GitVersion version

6.0.0

Operating system

Windows

What are you seeing?

I cannot build any more after updating to gitversion 6.0.0 using the corresponding msbuild task, because the build complains about an invalid package version (I had to translate german error message to english: System.ArgumentException: the PackageVersion character sequence "0.6.0-HYP-719_update_gitversion.1+27" is invalid. Seems like its using the FullSemVer rather than SemVer. See gitversion output:

{ "AssemblySemFileVer": "0.6.0.0", "AssemblySemVer": "0.6.0.0", "BranchName": "feature/HYP-719_update_gitversion", "BuildMetaData": 27, "CommitDate": "2024-07-23", "CommitsSinceVersionSource": 27, "EscapedBranchName": "feature-HYP-719-update-gitversion", "FullBuildMetaData": "27.Branch.feature-HYP-719-update-gitversion.Sha.e76a9b28e6258a87b32e44279fa902afb216134a", "FullSemVer": "0.6.0-HYP-719_update_gitversion.1+27", "InformationalVersion": "0.6.0-HYP-719_update_gitversion.1+27.Branch.feature-HYP-719-update-gitversion.Sha.e76a9b28e6258a87b32e44279fa902afb216134a", "Major": 0, "MajorMinorPatch": "0.6.0", "Minor": 6, "Patch": 0, "PreReleaseLabel": "HYP-719_update_gitversion", "PreReleaseLabelWithDash": "-HYP-719_update_gitversion", "PreReleaseNumber": 1, "PreReleaseTag": "HYP-719_update_gitversion.1", "PreReleaseTagWithDash": "-HYP-719_update_gitversion.1", "SemVer": "0.6.0-HYP-719_update_gitversion.1", "Sha": "e76a9b28e6258a87b32e44279fa902afb216134a", "ShortSha": "e76a9b2", "UncommittedChanges": 0, "VersionSourceSha": "0009dd4c353672803f36f7ea2e3a6ccd793d8203", "WeightedPreReleaseNumber": 30001 }

What is expected?

Build works and version of the build nuget package is 0.6.0-HYP-719_update_gitversion.1, not 0.6.0-HYP-719_update_gitversion.1+27 which is invalid.

Steps to Reproduce

  1. having a dotnet 8 class library project
  2. adding Gitversion.MSBuild 6.0.0
  3. add gitversion.yml as follows:
    mode: ContinuousDelivery branches: release: regex: ^release/.+|tag/.+rc\d+$ label: rc pull-request: label: pr ignore: sha: [] merge-message-formats: {}
  4. mark project as packable
  5. call dotnet pack

RepositoryFixture Test

No response

Output log or link to your CI build (if appropriate).

No response

Activity

  1. MoeHamdan commented on Jul 23, 2024

    @MoeHamdan

    In my case I am getting the below
    GitVersion = {
    FullSemVer: 0.0.1-TAS-42_moe.1+32
    LegacySemVer: [NULL]
    MajorMinorPatch: 0.0.1
    InformationalVersion: 0.0.1-TAS-42_moe.1+32.Branch.feature-TAS-42-moe.Sha.4c5956176653703fe32ed44fb6c1a6f0fdd28f1e
    Nuget v2 version: [NULL]
    PreReleaseLabel: TAS-42_moe
    BuildMetaData: 32
    }
    Version to use: 0.0.1.32-TAS-42_moe

    This is wrong it should be 0.1.0.32-TAS-42-moe, I have fall back to version 5.12.0 to get the correct version and my build starts working.

  2. peter-friedland-t2i commented on Jul 24, 2024

    @peter-friedland-t2i
    Author

    its also our solution to fall back at the moment, but there should be a fix otherwise no-one can build build nuget packages with V6, unless there is a workaround for the gitversion config :)

  3. gamblen commented on Jul 25, 2024

    @gamblen

    I am having a similar problem as FullSemVer has changed from v5.12.0, using it for tags on docker images and for nuget.

    Specifically feature branches.

    With version 5.12.0
    "FullSemVer": "1.6.0-MyFeature.27"

    With version 6.0.0
    "FullSemVer": "1.6.0-MyFeature.1+27"

    The addition of the 1+ causes docker build to abort and nuget to label as 1.6.0-MyFeature.1 which is overriding the first change in the feature branch.

    My config is

    assembly-versioning-scheme: MajorMinorPatchTag
    mode: ContinuousDeployment
    branches: {}
    ignore:
      sha: []
    merge-message-formats: {}
    
  4. vinnyrose commented on Jul 31, 2024

    @vinnyrose
    Contributor

    The issue is the underscores in the branch name. So, the workaround is to not use underscores in the branch name.

    Underscores used to be replaced by a dash but since underscores were added to the allowed characters in a branch name in 9ede034 to facilitate certain regex patterns, underscores are no longer replaced. Seems like a simple replace might fix it: vinnyrose/GitVersion@main...feature/underscore-label-fix

    ref: #3687

  5. arturcic commented on Jul 31, 2024

    @arturcic
    Member

    The issue is the underscores in the branch name. So, the workaround is to not use underscores in the branch name.

    Underscores used to be replaced by a dash but since underscores were added to the allowed characters in a branch name in 9ede034 to facilitate certain regex patterns, underscores are no longer replaced. Seems like a simple replace might fix it: vinnyrose/GitVersion@main...feature/underscore-label-fix

    ref: #3687

    @vinnyrose thank you for taking the time to understand the issue, please submit the PR and if the build succeeds I think it can be merged

  6. added this to the 6.x milestone on Jul 31, 2024
  7. modified the milestones: 6.x, 6.0.1 on Aug 5, 2024
  8. arturcic commented on Aug 5, 2024

    @arturcic
    Member

    🎉 This issue has been resolved in version 6.0.1 🎉
    The release is available on:

    Your GitReleaseManager bot 📦🚀

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions