only call package restore targets on transitive projects - #15717
Open
brettfo wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Limits MSBuild project-reference traversal to dependency-discovery targets, avoiding unnecessary builds.
Changes:
- Configures
ProjectReferenceBuildTargets. - Adds sentinel-based regression coverage.
Show a summary per file
| File | Description |
|---|---|
SdkProjectDiscovery.cs |
Restricts targets invoked on referenced projects. |
DiscoveryWorkerTests.Project.cs |
Verifies referenced projects are not built. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 2
- Review effort level: Medium
brettfo
force-pushed
the
dev/brettfo/nuget-restore-build
branch
from
July 29, 2026 20:48
a7903e1 to
80a9230
Compare
Contributor
There was a problem hiding this comment.
Review details
Comments suppressed due to low confidence (1)
nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/SdkProjectDiscovery.cs:182
requiredTargetsis chosen from the starting project's style, but this global property is inherited by every referenced project. In a mixed graph, an SDK-style root therefore asks a legacy reference to runRestoreandGenerateBuildDependencyFile, even though this file's existing legacy branch documents that those targets are absent; the reverse direction restricts an SDK reference to onlyResolveProjectReferences. This can produce missing-target errors or incomplete dependency data. Please select the target set in the context of each referenced project—for example, invoke a discovery target from the injected targets file that conditionally depends on the appropriate SDK/legacy targets.
args.Add($"/p:ProjectReferenceBuildTargets=\"{string.Join(";", requiredTargets)}\"");
- Files reviewed: 2/2 changed files
- Comments generated: 0 new
- Review effort level: Medium
brettfo
marked this pull request as ready for review
July 29, 2026 21:20
brbayes-msft
approved these changes
Jul 30, 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.
When discovering project dependencies, we directly invoke the targets
Restore,ResolveProjectReferences, andGenerateBuildDependencyFile. When MSBuild traverses through<ProjectReference>elements, it will callBuildwhich indirectly calls the targets we care about. This extra call toBuildcan be slow and fill the log with unnecessary errors, although it doesn't prevent dependency discovery.The fix is to explicitly set what targets can be called on project references to the ones we want.