Repository navigation
Fix error attribution for invalid TargetFramework and Version during restore - #7342
Merged
Merged
Conversation
nkolev92
force-pushed
the
dev-nkolev92-sna
branch
2 times, most recently
from
April 29, 2026 15:27
41f1ef7 to
48781d4
Compare
nkolev92
force-pushed
the
dev-nkolev92-sna
branch
2 times, most recently
from
May 13, 2026 18:28
588e107 to
9c2814d
Compare
nkolev92
force-pushed
the
dev-nkolev92-sna
branch
from
May 13, 2026 18:29
9c2814d to
4f2dca9
Compare
zivkan
reviewed
May 13, 2026
Member
Author
|
@zivkan Pushed some more changes. Tests should hopefully pass again. |
- Add usePackageSpecFactory parameter to all 6 new tests per review comment - Add environmentVariables parameter to RestoreProject/SolutionExpectFailure/Success helpers - Fix null PackagesPath crash in error specs by using string.Empty - Fix GetTargetFrameworkStrings to not split TargetFramework (singular) by semicolons, aligning with RestoreProjectAdapter.Prepare() behavior in the new path Co-authored-by: Copilot <[email protected]>
nkolev92
enabled auto-merge (squash)
May 18, 2026 15:49
jeffkl
reviewed
May 18, 2026
jeffkl
approved these changes
May 19, 2026
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.
Bug
Fixes: NuGet/Home#12470
Fixes: NuGet/Home#13772
Fixes: NuGet/Home#11230
Fixes: NuGet/Home#14605
Description
When PackageSpec creation fails because of invalid project data, restore can attribute the error to the wrong project (or the solution) and skip writing the failing project's assets file.
This change routes those failures through
AdditionalMessagesin both static graph and non-static graph restore so the generated NU1105 is attached to the project that actually failed.It also preserves invalid semicolon-delimited target framework strings long enough for downstream validation, which fixes cases like
net10.0;net8.0.Tests
Added integration tests in
DotnetRestoreTests.cs:ProjectReferencesProjectWithInvalidTargetFrameworkinvalid,net8.0;net472ProjectWithBadVersion1.0.badversionProjectWithInvalidNuGetVersion3.1.3a1SolutionWithProjectWithInvalidTargetFrameworkinvalid,net8.0;net472SolutionWithCPMBadPackageVersion1.0.badversionin Directory.Packages.propsCPMProjectWithSemicolonInTargetFrameworknet10.0;net8.0with CPM (#14605)All tests validate:
Strings.Error_ReadingProjectInformation,Strings.SpecValidationInvalidFramework)PR Checklist