Revert passing ExcludeRestorePackageImports during restore (#14274) - #14349
Merged
ViktorHofer merged 2 commits intoJul 14, 2026
Conversation
PR #14274 injected ExcludeRestorePackageImports=true into the implicit restore global properties (behind change wave 18.10) so that NuGet's restore re-invocation reused MSBuild's initial evaluation instead of forcing a second one. This breaks restore for projects that have a nonexistent <ProjectReference>. Once the top-level restore evaluation shares the same global property set that NuGet's inner _GenerateRestoreProjectPathWalk invocation uses, the walk runs in the same project instance and its unfiltered _RestoreProjectPathItems (raw ProjectReference paths, including missing ones) leaks into _GenerateRestoreGraph's _GenerateRestoreGraphProjectEntry MSBuild call, which does not set SkipNonexistentProjects and fails with MSB3202 instead of skipping the missing project. This regressed the dotnet/sdk test ItCanTestAMultiTFMProjectWithImplicitRestore (dotnet/sdk#55245). Revert the change, leaving a comment in ExecuteRestore documenting why the property must not be set here. Change wave 18.10 is retained because it is still used by the -getProperty/-getItem evaluation change (#14290). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 395f543d-fb00-4a06-95b1-a7738432a141
ViktorHofer
temporarily deployed
to
copilot-pat-pool
July 14, 2026 07:30 — with
GitHub Actions
Inactive
ViktorHofer
temporarily deployed
to
copilot-pat-pool
July 14, 2026 07:31 — with
GitHub Actions
Inactive
ViktorHofer
had a problem deploying
to
copilot-pat-pool
July 14, 2026 07:31 — with
GitHub Actions
Failure
ViktorHofer
temporarily deployed
to
copilot-pat-pool
July 14, 2026 07:32 — with
GitHub Actions
Inactive
Contributor
There was a problem hiding this comment.
Pull request overview
Reverts the /restore (and restore-only /t:Restore) behavior introduced in #14274 that injected ExcludeRestorePackageImports=true into restore global properties (behind change wave 18.10), after it was found to break restore in scenarios with a nonexistent <ProjectReference>.
Changes:
- Removed the
ExcludeRestorePackageImports=trueglobal-property injection fromXMake.ExecuteRestoreand replaced it with an explanatory comment documenting the failure mode. - Deleted the
MSBuildConstants.ExcludeRestorePackageImports*constants and removed the unit tests that validated the injected-property behavior. - Updated
ChangeWaves.mdto remove the 18.10 bullet that described the reverted feature.
Show a summary per file
| File | Description |
|---|---|
| src/MSBuild/XMake.cs | Stops injecting ExcludeRestorePackageImports during restore; adds rationale comment to prevent reintroduction. |
| src/MSBuild.UnitTests/XMake_Tests.cs | Removes tests that asserted the (now reverted) injected restore global property behavior. |
| src/Framework/MSBuildConstants.cs | Removes now-unused ExcludeRestorePackageImports* constants. |
| documentation/wiki/ChangeWaves.md | Removes the 18.10 changewave bullet describing the reverted restore behavior. |
Copilot's findings
- Files reviewed: 4/4 changed files
- Comments generated: 2
ViktorHofer
added a commit
to dotnet/sdk
that referenced
this pull request
Jul 14, 2026
Regressed by MSBuild #14274 (ExcludeRestorePackageImports during implicit restore), which fails with MSB3202 on multi-TFM projects that have a nonexistent <ProjectReference>. The MSBuild change is being reverted in dotnet/msbuild#14349. Re-enable tracked by #55263. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 395f543d-fb00-4a06-95b1-a7738432a141
- Add RestoreDoesNotInjectExcludeRestorePackageImports test asserting restore does not inject the property by default, guarding against silent reintroduction of the reverted #14274 behavior. - Remove a stray "arget)" typo left on the 18.10 -getProperty bullet. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 395f543d-fb00-4a06-95b1-a7738432a141
Member
Author
|
Thanks for the review — addressed both points in
|
JanProvaznik
approved these changes
Jul 14, 2026
ViktorHofer
deleted the
viktorhofer/revert-exclude-restore-package-imports
branch
July 14, 2026 08:46
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reverts the change from #14274, which injected
ExcludeRestorePackageImports=trueinto the implicit restore global properties (behind change wave 18.10) so that NuGet's restore re-invocation would reuse MSBuild's initial evaluation instead of forcing a second one.Why revert
The change breaks restore for projects that have a nonexistent
<ProjectReference>. Once the top-level restore evaluation shares the same global property set that NuGet's inner_GenerateRestoreProjectPathWalkinvocation uses, that walk runs in the same project instance and its unfiltered_RestoreProjectPathItems(which contains the rawProjectReferencepaths, including missing ones) leaks into_GenerateRestoreGraph's_GenerateRestoreGraphProjectEntryMSBuild call. That call does not setSkipNonexistentProjects, so it fails withMSB3202instead of skipping the missing project.This regressed the dotnet/sdk test
ItCanTestAMultiTFMProjectWithImplicitRestore— see dotnet/sdk#55245 for the full root-cause analysis and repro.Details
-restoreswitch /ExecuteRestore) path was affected; explicitdotnet restore/-t:Restorenever added the property.dotnet build -t:Restore /p:ExcludeRestorePackageImports=trueon a multi-TFM project with a danglingProjectReference: without the property restore succeeds (missing project skipped gracefully); with it,MSB3202.What this PR does
ExcludeRestorePackageImports=trueinjection inXMake.ExecuteRestore, replacing it with a comment documenting why the property must not be set there.ExcludeRestorePackageImports/ExcludeRestorePackageImportsValueconstants and the two related unit tests.18.10itself — it is still used by the-getProperty/-getItemevaluation change (Add opt-in partial (stop-after-pass) project evaluation #14290).