Skip to content

Document NU1503 NuGet restore warnings on dotnet restore#47843

Open
yeelam-gordon wants to merge 1 commit into
mainfrom
user/yeelam/investigate-restore-warnings
Open

Document NU1503 NuGet restore warnings on dotnet restore#47843
yeelam-gordon wants to merge 1 commit into
mainfrom
user/yeelam/investigate-restore-warnings

Conversation

@yeelam-gordon
Copy link
Copy Markdown
Contributor

Summary

Investigates the ~112 warnings emitted during dotnet restore on the PowerToys solution and documents the canonical no-warning restore path. No code/build behavior changes - documentation only.

Investigation

Running dotnet restore PowerToys.slnx produces 112 NU1503 warnings of the form:

warning NU1503: Skipping restore for project '...vcxproj'. The project file may be invalid or missing targets required for restore.

Verified that:

  • All 112 warnings are NU1503 and all reference .vcxproj files.
  • They originate from native C++ projects that do not consume PackageReference items - the dotnet restore engine does not know how to restore them.
  • Running msbuild /t:restore PowerToys.slnx (which is what tools/build/build-essentials.cmd does internally) emits 0 NU1503 warnings. The Microsoft.Cpp SDK handles vcxproj restore correctly.
  • Suppression via per-project <NoWarn>NU1503</NoWarn> in Directory.Build.props does not work because NU1503 is emitted at the solution-level NuGet restore engine before per-project targets are evaluated. Tested - no reduction in warning count.
  • Adding an empty <Target Name=""Restore"" /> in Directory.Build.targets also does not help for the same reason.

Conclusion

The warnings only appear to developers who run dotnet restore directly. PowerToys CI and the canonical build scripts already use msbuild and produce a clean restore. The pragmatic and correct fix is documentation that guides contributors to the supported restore path.

Change

Adds a "NuGet restore caveats" section to tools/build/BUILD-GUIDELINES.md explaining:

  • The NU1503 warnings are informational and benign.
  • Why they appear with dotnet restore but not with msbuild /t:restore.
  • The two warning-free restore commands (build-essentials.cmd or direct msbuild /t:restore).

Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com

Investigation findings:

* 'dotnet restore PowerToys.slnx' emits 112 NU1503 warnings (one per .vcxproj that lacks PackageReference items).

* 'msbuild /t:restore PowerToys.slnx' emits 0 NU1503 warnings - msbuild handles native projects through the Microsoft.Cpp SDK.

* PowerToys CI and the canonical tools/build/build-essentials.cmd script already use msbuild, so the warnings are only visible to developers who run 'dotnet restore' directly.

* Suppression via per-project NoWarn does not work because NU1503 is emitted at solution-level by the NuGet restore engine before per-project targets are evaluated. The pragmatic fix is documentation, advising contributors to use the script wrappers.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.

1 participant