Skip to content

Honor MSBuild diagnostic severity settings for NBGV1001 - #1559

Draft
AArnott with Copilot wants to merge 3 commits into
mainfrom
copilot/fix-nbgv1001-warning
Draft

AArnott with Copilot wants to merge 3 commits into
mainfrom
copilot/fix-nbgv1001-warning

Conversation

Copilot AI commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

C# Doctor reports NBGV1001 despite project-local suppression or downgrade settings because cached version computation runs in a separate project without those settings.

  • Severity propagation: Forward NoWarn and MSBuildWarningsAsMessages/AsErrors/NotAsErrors to the cached project, preserving semicolon-delimited lists.
  • Suppression: Honor NoWarn when emitting NBGV1001 without changing placeholder values.
  • Coverage and documentation: Cover regular and design-time builds in both computation modes, including exact case-insensitive code matching; document the opt-out.

Suppress the warning in a project or Directory.Build.props:

<PropertyGroup>
  <NoWarn>$(NoWarn);NBGV1001</NoWarn>
</PropertyGroup>

Use MSBuildWarningsAsMessages instead to retain the diagnostic as a message.

Co-authored-by: AArnott <3548+AArnott@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix opt-out issue for NBGV1001 in C# Doctor Honor MSBuild diagnostic severity settings for NBGV1001 Oct 9, 2026
Copilot AI requested a review from AArnott October 9, 2026 13:03

@AArnott AArnott left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread src/Nerdbank.GitVersioning.Tasks/GetBuildVersion.cs
Comment thread src/Nerdbank.GitVersioning.Tasks/GetBuildVersion.cs
Comment thread src/Nerdbank.GitVersioning.Tasks/build/MSBuildTargetCaching.targets Outdated
Co-authored-by: AArnott <3548+AArnott@users.noreply.github.com>

Copilot AI commented Oct 10, 2026

Copy link
Copy Markdown
Contributor Author

@copilot

Addressed in 73287a7. Forwarded severity lists now contain only canonical NBGV1001 or empty; tests verify different project lists still compute the version once. Comma/mixed NoWarn lists also work without C# targets.

I kept task-side suppression: Microsoft’s NuGet tasks explicitly filter NoWarn; TaskLoggingHelper has no generic suppression API. MSBuild handles downgrade/promotion.

Release build and cloud tests passed (1,374 passed, 13 skipped); CodeQL found no alerts.

Copilot AI requested a review from AArnott October 10, 2026 21:45

@AArnott AArnott left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

message: "Git information is unavailable because the git engine is disabled. Git-related MSBuild properties and ThisAssembly members contain placeholder values.");
if (this.NoWarn?.Contains(UnavailableGitWarningCode, StringComparer.OrdinalIgnoreCase) != true)
{
this.Log.LogWarning(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where do we honor MSBuildWarningsAsMessages?

Copilot AI commented Oct 11, 2026

Copy link
Copy Markdown
Contributor Author

@copilot

MSBuild handles the downgrade when GetBuildVersion calls Log.LogWarning with code NBGV1001; no task-side MSBuildWarningsAsMessages check is needed.

MSBuildTargetCaching.targets lines 15–21 filter and forward that property, and line 36 passes it to PrivateP2PCaching.proj. In-project mode already has the property. PlaceholderWarningHonorsProjectSeverity covers both modes and regular/design-time builds, asserting no warning and a retained BuildMessageEventArgs (lines 71–83).

The screenshot identifies PrivateP2PCaching.proj, which is why forwarding the setting to that project is essential.

Copilot AI requested a review from AArnott October 11, 2026 23:25

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Question] NBGV1001 opt-out with vscode's C# Doctor

2 participants