Repository navigation
[ISSUE]: 6.3.0 diag flag not working #4539
Description
Activity
As a workaround just use the log file cli arg together with /verbosity Verbose. The log file then contains the same content.
Reacted by Mathias Petermann and Josh Sandersoncommand:
gitversion /diag /verbosity Verbosenot 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.74ac886dbb8f9bf037a0a7cc19f5f04f03e691c9Can confirm the issue
Still an issue in 6.4.0
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.
@asbjornu can you please answer these two question?
- What was the reason for the breaking change from 6.2 -> 6.3?
- 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)Reacted by Mathias PetermannWith
"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?- 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!
- 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! 🙏🏼
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.
Okay great. Thank you for reporting this issue. @peschmae and others: Could you please find the root cause and create a pull request?
@HHobeck @peschmae @arturcic there is a possible work around to bring back the diagnostic spew to stdout:
dotnet gitversion -l console -diagBut the order of arguments matter, placing
-diagbefore-lwill swallow that argument and its value (see #4763).The behavior changes that
-diagis 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:
- accept that
-diagby itself will no longer create stdout spew automatically; require-l consoleto explicitly mix diag spew and JSON
-> cmd line help and documentation should be updated - restore the 6.2.0 behavior and add the
ConsoleAppenderin 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.
- accept that
Personally, I'm in favor of option 1) above, since mixing diagnostic spew and JSON in stdout is... weird. Explicitly opting in via
-l consoleis preferred.@davidjenni Agree with option 1, please submit a PR with the update
Reacted by David JENNI🎉 This issue has been resolved in version 6.5.1 🎉
The release is available on:Your GitReleaseManager bot 📦🚀
Prerequisites
GitVersion package
GitVersion.CmdLine
GitVersion version
6.3.0
Operating system
macOS
What are you seeing?
When running gitversion with the
/diagflag, no diag output is logged.What is expected?
Diag output is shown exactly like in 6.2.0
Steps to Reproduce
gitversion /diagusing 6.3.0 release => no outputgitversion /diagusing 6.2.0 release => diag outputRepositoryFixture Test
No response
Output log or link to your CI build (if appropriate).