fix: NU1004 false positive when P2P has no compatible TFM in locked mode#7198
Closed
PHILLIPS71 wants to merge 2 commits intoNuGet:devfrom
Closed
fix: NU1004 false positive when P2P has no compatible TFM in locked mode#7198PHILLIPS71 wants to merge 2 commits intoNuGet:devfrom
PHILLIPS71 wants to merge 2 commits intoNuGet:devfrom
Conversation
Author
|
@dotnet-policy-service agree |
nkolev92
requested changes
Mar 11, 2026
| // When no compatible TFM is found, restore contributes no transitive dependencies | ||
| // for this P2P project. Non-empty deps in the lock file indicate a stale entry | ||
| // from when the P2P previously had a compatible TFM. | ||
| if (projectDependency.Dependencies.Count > 0) |
Member
There was a problem hiding this comment.
Hey @PHILLIPS71
Thanks for creating this PR.
I'm not sure I agree with your assessment that this is a false positive, but I'll check with some of my teammates as well.
I think it's fine if NU1004 is raised here.
The project dependencies have changed and that's all NU1004 is supposed to change.
Moreover, I'm not sure this actually tackles the problem in the linked issue, which is really about AssetTargetFallback not being applied through project refs when calculating.
Member
|
The follow-up is #7312. |
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#12010
Description
IsLockFileValidunconditionally invalidated the lock file (NU1004) whenever a P2P project had no compatible target framework.This was incorrect, restore itself produces zero transitive dependencies for such a P2P, so a lock file entry with empty deps is consistent with what restore would produce and should be accepted as valid.
The fix guards the invalidation on whether the lock file entry contains any dependencies:
PR Checklist