fix: NU1004 false positive when P2P has no compatible TFM in locked mode#7198
fix: NU1004 false positive when P2P has no compatible TFM in locked mode#7198PHILLIPS71 wants to merge 2 commits intoNuGet:devfrom
Conversation
|
@dotnet-policy-service agree |
| // 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) |
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.
|
This PR has been automatically marked as stale because it has no activity for 7 days. It will be closed if no further activity occurs within another 30 days of this comment. If it is closed, you may reopen it anytime when you're ready again, as long as you don't delete the branch. |
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