Skip to content

[ISSUE]: 6.3.0 diag flag not working #4539

Description

@peschmae

Prerequisites

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

GitVersion package

GitVersion.CmdLine

GitVersion version

6.3.0

Operating system

macOS

What are you seeing?

When running gitversion with the /diag flag, no diag output is logged.

$ gitversion -diag
{
  "AssemblySemFileVer": "4.0.0.0",
  "AssemblySemVer": "4.0.0.0",
  "BranchName": "main",
  "BuildMetaData": null,
  "CommitDate": "2025-05-02",
  "CommitsSinceVersionSource": 55,
  "EscapedBranchName": "main",
  "FullBuildMetaData": "Branch.main.Sha.58ee094bf82d3d5fd265f49b86e9b39a499f723c",
  "FullSemVer": "4.0.0",
  "InformationalVersion": "4.0.0+Branch.main.Sha.58ee094bf82d3d5fd265f49b86e9b39a499f723c",
  "Major": 4,
  "MajorMinorPatch": "4.0.0",
  "Minor": 0,
  "Patch": 0,
  "PreReleaseLabel": "",
  "PreReleaseLabelWithDash": "",
  "PreReleaseNumber": null,
  "PreReleaseTag": "",
  "PreReleaseTagWithDash": "",
  "SemVer": "4.0.0",
  "Sha": "58ee094bf82d3d5fd265f49b86e9b39a499f723c",
  "ShortSha": "58ee094",
  "UncommittedChanges": 0,
  "VersionSourceSha": "819c687a914b4567faf9fa647bd9d0aa14df909e",
  "WeightedPreReleaseNumber": 60000
}

What is expected?

Diag output is shown exactly like in 6.2.0

$ gitversion-6.2.0 -diag
INFO [25-05-08 9:19:43:69] Please run `git log --graph --format="%h %cr %d" --decorate --date=relative --all --remotes=*` to see the git graph. This can help you troubleshoot any issues.

INFO [25-05-08 9:19:43:69] Working directory: <REPO_PATH>
INFO [25-05-08 9:19:43:70] Project root is: <REPO_PATH>
INFO [25-05-08 9:19:43:70] DotGit directory is: <REPO_PATH>/.git
INFO [25-05-08 9:19:43:70] Branch from build environment:
INFO [25-05-08 9:19:43:77] Using latest commit on specified branch
INFO [25-05-08 9:19:43:80] Getting tagged semantic versions. TagPrefix:  and Format: Strict
INFO [25-05-08 9:19:43:84] Running against branch: main ('58ee094' - chore: promote external-secrets v1beta1 to v1)
INFO [25-05-08 9:19:43:84] -< Begin: Fetching the base versions for version calculation... >-
  INFO [25-05-08 9:19:43:84] -< Begin: Calculating base versions for 'main' >-
    INFO [25-05-08 9:19:43:84] -< Begin: [Using 'ConfiguredNextVersionVersionStrategy' strategy] >-
    INFO [25-05-08 9:19:43:84] -< End: [Using 'ConfiguredNextVersionVersionStrategy' strategy] (Took: 0.29ms) >-
    INFO [25-05-08 9:19:43:84] -< Begin: [Using 'MainlineVersionStrategy' strategy] >-
    INFO [25-05-08 9:19:43:85] -< End: [Using 'MainlineVersionStrategy' strategy] (Took: 0.23ms) >-
    INFO [25-05-08 9:19:43:85] -< Begin: [Using 'MergeMessageVersionStrategy' strategy] >-
    INFO [25-05-08 9:19:43:87] -< End: [Using 'MergeMessageVersionStrategy' strategy] (Took: 23.71ms) >-
    INFO [25-05-08 9:19:43:87] -< Begin: [Using 'TaggedCommitVersionStrategy' strategy] >-
      INFO [25-05-08 9:19:43:87] -< Begin: Getting tagged semantic versions on branch 'refs/heads/main'. TagPrefix:  and Format: Strict >-
      INFO [25-05-08 9:19:43:87] -< End: Getting tagged semantic versions on branch 'refs/heads/main'. TagPrefix:  and Format: Strict (Took: 0.85ms) >-
      INFO [25-05-08 9:19:43:90] Git tag '3.1.1': Version increment '3.1.1' +semver 'Major' with label '' based on commit '819c687'.
      INFO [25-05-08 9:19:43:90] Git tag '3.1.0': Version increment '3.1.0' +semver 'Major' with label '' based on commit '88ae521'.
      INFO [25-05-08 9:19:43:90] Git tag '3.0.1': Version increment '3.0.1' +semver 'Major' with label '' based on commit '860266f'.
      INFO [25-05-08 9:19:43:90] Git tag '3.0.0': Version increment '3.0.0' +semver 'Major' with label '' based on commit '917fcee'.
      INFO [25-05-08 9:19:43:90] The tag '2.2.0' is skipped because it provides a lower base version than other tags.
      INFO [25-05-08 9:19:43:90] The tag '2.1.0' is skipped because it provides a lower base version than other tags.
      INFO [25-05-08 9:19:43:90] The tag '2.0.0' is skipped because it provides a lower base version than other tags.
      INFO [25-05-08 9:19:43:90] The tag '1.3.0' is skipped because it provides a lower base version than other tags.
      INFO [25-05-08 9:19:43:90] The tag '1.2.1' is skipped because it provides a lower base version than other tags.
      INFO [25-05-08 9:19:43:90] The tag '1.2.0' is skipped because it provides a lower base version than other tags.
      INFO [25-05-08 9:19:43:90] The tag '1.1.0' is skipped because it provides a lower base version than other tags.
      INFO [25-05-08 9:19:43:90] The tag '1.0.0' is skipped because it provides a lower base version than other tags.
    INFO [25-05-08 9:19:43:90] -< End: [Using 'TaggedCommitVersionStrategy' strategy] (Took: 32.17ms) >-
    INFO [25-05-08 9:19:43:90] -< Begin: [Using 'TrackReleaseBranchesVersionStrategy' strategy] >-
    INFO [25-05-08 9:19:43:90] -< End: [Using 'TrackReleaseBranchesVersionStrategy' strategy] (Took: 0.22ms) >-
    INFO [25-05-08 9:19:43:90] -< Begin: [Using 'VersionInBranchNameVersionStrategy' strategy] >-
    INFO [25-05-08 9:19:43:90] -< End: [Using 'VersionInBranchNameVersionStrategy' strategy] (Took: 0.28ms) >-
  INFO [25-05-08 9:19:43:90] -< End: Calculating base versions for 'main' (Took: 58.04ms) >-
INFO [25-05-08 9:19:43:90] -< End: Fetching the base versions for version calculation... (Took: 59.11ms) >-
INFO [25-05-08 9:19:43:90] -------------------------------------------------------
INFO [25-05-08 9:19:43:90] Found multiple base versions which will produce the same SemVer (4.0.0-1), taking latest source for commit counting (Git tag '3.1.1')
INFO [25-05-08 9:19:43:90] Base version used: Git tag '3.1.1': Take '3.1.1' based on commit '819c687'.
INFO [25-05-08 9:19:43:90] -------------------------------------------------------
INFO [25-05-08 9:19:43:90] -< Begin: Using continuous deployment workflow to calculate the incremented version. >-
  INFO [25-05-08 9:19:43:90] 55 commits found between '819c687' - chore(chart): Bump chart version to 3.1.1 and '58ee094' - chore: promote external-secrets v1beta1 to v1
INFO [25-05-08 9:19:43:90] -< End: Using continuous deployment workflow to calculate the incremented version. (Took: 1.50ms) >-
Set Build Number for 'LocalBuild'.

Set Output Variables for 'LocalBuild'.
{
  "AssemblySemFileVer": "4.0.0.0",
  "AssemblySemVer": "4.0.0.0",
  "BranchName": "main",
  "BuildMetaData": null,
  "CommitDate": "2025-05-02",
  "CommitsSinceVersionSource": 55,
  "EscapedBranchName": "main",
  "FullBuildMetaData": "Branch.main.Sha.58ee094bf82d3d5fd265f49b86e9b39a499f723c",
  "FullSemVer": "4.0.0",
  "InformationalVersion": "4.0.0+Branch.main.Sha.58ee094bf82d3d5fd265f49b86e9b39a499f723c",
  "Major": 4,
  "MajorMinorPatch": "4.0.0",
  "Minor": 0,
  "Patch": 0,
  "PreReleaseLabel": "",
  "PreReleaseLabelWithDash": "",
  "PreReleaseNumber": null,
  "PreReleaseTag": "",
  "PreReleaseTagWithDash": "",
  "SemVer": "4.0.0",
  "Sha": "58ee094bf82d3d5fd265f49b86e9b39a499f723c",
  "ShortSha": "58ee094",
  "UncommittedChanges": 0,
  "VersionSourceSha": "819c687a914b4567faf9fa647bd9d0aa14df909e",
  "WeightedPreReleaseNumber": 60000
}

Steps to Reproduce

  1. Run gitversion /diag using 6.3.0 release => no output
  2. Run gitversion /diag using 6.2.0 release => diag output

RepositoryFixture Test

No response

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

Activity

  1. MTomBosch commented on May 8, 2025

    @MTomBosch

    As a workaround just use the log file cli arg together with /verbosity Verbose. The log file then contains the same content.

  2. adzyk commented on Jul 15, 2025

    @adzyk

    command:

    gitversion /diag /verbosity Verbose 
    

    not contains diagnostic messages

    $ gitversion /diag /verbosity Verbose
    {
      "AssemblySemFileVer": "0.2.0.0",
      "AssemblySemVer": "0.2.0.0",
      "BranchName": "master",
      "BuildMetaData": null,
      "CommitDate": "2025-07-15",
      "CommitsSinceVersionSource": 51,
      "EscapedBranchName": "master",
      "FullBuildMetaData": "Branch.master.Sha.f9e27e9f43d693331f26a9894df2299d351afac7",
      "FullSemVer": "0.2.0",
      "InformationalVersion": "0.2.0+Branch.master.Sha.f9e27e9f43d693331f26a9894df2299d351afac7",
      "Major": 0,
      "MajorMinorPatch": "0.2.0",
      "Minor": 2,
      "Patch": 0,
      "PreReleaseLabel": "",
      "PreReleaseLabelWithDash": "",
      "PreReleaseNumber": null,
      "PreReleaseTag": "",
      "PreReleaseTagWithDash": "",
      "SemVer": "0.2.0",
      "Sha": "f9e27e9f43d693331f26a9894df2299d351afac7",
      "ShortSha": "f9e27e9",
      "UncommittedChanges": 114,
      "VersionSourceSha": "2a60b2da2c27bd44578a2d5298a51a01e65cef13",
      "WeightedPreReleaseNumber": 60000
    }
    $ gitversion /version
    6.3.0+Branch.main.Sha.74ac886dbb8f9bf037a0a7cc19f5f04f03e691c9
    
  3. fteotini commented on Jul 18, 2025

    @fteotini

    Can confirm the issue

  4. otac0n commented on Aug 16, 2025

    @otac0n

    Still an issue in 6.4.0

  5. asbjornu commented on Aug 16, 2025

    @asbjornu
    Member

    In normal working conditions, the expected output from GitVersion is a full and valid JSON document. Writing log messages to stdout would break this.

    I’m not sure what we can do about this without a complete rearchitecture of the CLI as planned for v7, which will involve major breaking changes.

  6. otac0n commented on Aug 19, 2025

    @otac0n

    @asbjornu can you please answer these two question?

    1. What was the reason for the breaking change from 6.2 -> 6.3?
    2. Why is it still documented as a feature when running dotnet-gitversion -? then?

    /diag Runs GitVersion with additional diagnostic information
    (requires git.exe to be installed)

  7. reenx commented on Aug 21, 2025

    @reenx

    With
    "gitversion -output file -verbosity Diagnostic"
    the output is still only the json object with versions. I do not see any diagnostic information.
    We regularly use the diagnostic information to figure out why a wrong version is calculated. I understand your statement about writing log messages to stdout. But this is existing behaviour. And behaviour that we rely on.
    If it is changed fine. But then update the documentation and supply guidence on how we can get this information. The verbose flag does not work at all. Am I missing an option?

  8. asbjornu commented on Sep 18, 2025

    @asbjornu
    Member
    1. What was the reason for the breaking change from 6.2 -> 6.3?

    @otac0n, sorry, I was not aware that this was a breaking change in 6.2 (I assumed it was introduced in 6.0). That definitely requires investigation and correction of some sort!

    1. Why is it still documented as a feature when running dotnet-gitversion -? then?>

    Good question. Seems like an oversight. Pull requests fixing this (preferably with a test to protect against further regressions) are more than welcome! 🙏🏼

  9. D3-LucaPiombino commented on Oct 28, 2025

    @D3-LucaPiombino

    With "gitversion -output file -verbosity Diagnostic" the output is still only the json object with versions. I do not see any diagnostic information. We regularly use the diagnostic information to figure out why a wrong version is calculated. I understand your statement about writing log messages to stdout. But this is existing behaviour. And behaviour that we rely on. If it is changed fine. But then update the documentation and supply guidence on how we can get this information. The verbose flag does not work at all. Am I missing an option?

    Yep, we also rely heavily on this for the same reason.

    Today as a workaround we need to run gitversion twice (one time with /diag and another with the normal output) as sometimes it's not easy to repro an issue and we always want to have the logs for convenience.

  10. added this to the 6.x milestone on Nov 7, 2025
  11. HHobeck commented on Nov 7, 2025

    @HHobeck
    Contributor

    Okay great. Thank you for reporting this issue. @peschmae and others: Could you please find the root cause and create a pull request?

  12. davidjenni commented on Nov 26, 2025

    @davidjenni
    Contributor

    @HHobeck @peschmae @arturcic there is a possible work around to bring back the diagnostic spew to stdout:

    dotnet gitversion -l console -diag

    But the order of arguments matter, placing -diag before -l will swallow that argument and its value (see #4763).

    The behavior changes that -diag is ignored past version 6.2.0 is an unintended consequence of commit 49f7ff8 (Removes build server output type when running in diag mode.)_

    Assuming my fix for 4763 (PR #4762) is accepted, there are at least 2 options for this issue:

    1. accept that -diag by itself will no longer create stdout spew automatically; require -l console to explicitly mix diag spew and JSON
      -> cmd line help and documentation should be updated
    2. restore the 6.2.0 behavior and add the ConsoleAppender in GitVersionExecutor.cs IFF the user has not set explicitly a different log file

    Depending on the outcome of this discussion, I can create a separate PR. Pls advise.

  13. davidjenni commented on Nov 26, 2025

    @davidjenni
    Contributor

    Personally, I'm in favor of option 1) above, since mixing diagnostic spew and JSON in stdout is... weird. Explicitly opting in via -l console is preferred.

  14. linked a pull request that will close this issueFix diag switch #4762on Nov 26, 2025
  15. removed a link to a pull requestFix diag switch #4762on Nov 26, 2025
  16. arturcic commented on Nov 26, 2025

    @arturcic
    Member

    @davidjenni Agree with option 1, please submit a PR with the update

  17. gittools-bot commented on Nov 27, 2025

    @gittools-bot
    Contributor

    🎉 This issue has been resolved in version 6.5.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