Skip to content

[repo-assist] Forward NoWarn/TreatWarningsAsErrors/WarningsAsErrors to PackTask - #4393

Merged
dsyme merged 1 commit into
masterfrom
repo-assist/fix-issue-3504-nowarn-pack-9fc6da6cd1edc004
Aug 29, 2026
Merged

dsyme merged 1 commit into
masterfrom
repo-assist/fix-issue-3504-nowarn-pack-9fc6da6cd1edc004

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

🤖 This is an automated pull request from Repo Assist, an AI assistant.

Closes #3504

Root cause

Paket.Restore.targets invokes MSBuild's PackTask for dotnet pack but never forwards the NoWarn, TreatWarningsAsErrors, or WarningsAsErrors properties, even though NuGet's PackTask.cs has exposed these parameters since NuGet.Client 4.7 (NuGet/NuGet.Client#2013). Consequently, warnings such as NU5105 (SemVer 2.0 pre-release version string) could not be suppressed via NoWarn when packing through Paket.

Fix

Forward $(NoWarn), $(TreatWarningsAsErrors), and $(WarningsAsErrors) MSBuild properties to the PackTask invocation guarded by UseMSBuild16_10_Pack — the current, actively used pack path for modern MSBuild/SDK versions. The older legacy PackTask invocations (UseMSBuild16_0_Pack, UseMSBuild15_9_Pack, UseMSBuild15_8_Pack, UseNuGet4_Pack) predate this NuGet.Client support and are intentionally left unchanged, matching the issue reporter's own caution about not blindly passing these to versions that may not support them.

Trade-offs

  • Only the newest pack path gets the fix; users on older MSBuild/NuGet.Client toolchains (rare today) won't get suppression support, but also won't risk passing unsupported task parameters.
  • Minimal, surgical change to a single embedded MSBuild targets file; no F# code changes.

Test Status

  • Validated the modified Paket.Restore.targets is well-formed XML (xml.dom.minidom parse succeeded).
  • Could not run a full dotnet build/pack integration test in this sandbox because dotnet paket restore requires network access to NuGet feeds that isn't available here. No existing automated integration test scenario covers dotnet pack warning suppression, so none could be extended without adding new test infrastructure, which is out of scope for this minimal fix.
  • Change is additive (new optional attributes on an existing task invocation) and does not alter existing behavior for projects that don't set NoWarn/TreatWarningsAsErrors/WarningsAsErrors.

Please review CI results after this PR is opened to confirm no regressions in the existing Windows/.NET and Linux build+test suites.

Generated by 🌈 Repo Assist, see workflow run. Learn more.
Comment /repo-assist to run again

Add this agentic workflow to your repo

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@ae8d551f07c7ed7619f8c58c7bb4c3ac89395d38

…est MSBuild pack path

Closes #3504

Root cause: Paket.Restore.targets invokes the MSBuild PackTask (via UseMSBuild16_10_Pack)
without forwarding NoWarn, TreatWarningsAsErrors, or WarningsAsErrors, even though the
underlying NuGet PackTask.cs has supported these parameters since NuGet.Client 4.7+.
As a result, warnings like NU5105 (SemVer 2.0 version string) could not be suppressed
via NoWarn when running 'dotnet pack' through Paket-managed restore/pack targets.

Fix: forward $(NoWarn), $(TreatWarningsAsErrors), and $(WarningsAsErrors) MSBuild
properties to the PackTask invocation guarded by UseMSBuild16_10_Pack (the modern,
actively used pack path). Older/legacy PackTask invocations (UseMSBuild16_0_Pack,
UseMSBuild15_9_Pack, UseMSBuild15_8_Pack, UseNuGet4_Pack) predate this NuGet.Client
support and are left unchanged to avoid passing unsupported parameters.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@dsyme
dsyme marked this pull request as ready for review August 29, 2026 12:11
@dsyme
dsyme merged commit b7e3bca into master Aug 29, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NoWarn, TreatWarningsAsErrors and WarningsAsErrors not used when calling dotnet pack

1 participant