Skip to content

Default BuildProjectReferences to false when NoBuild is true - #55259

Merged
baronfel merged 1 commit into
dotnet:mainfrom
baronfel:baronfel-default-p2p-no-build
Jul 14, 2026
Merged

Default BuildProjectReferences to false when NoBuild is true#55259
baronfel merged 1 commit into
dotnet:mainfrom
baronfel:baronfel-default-p2p-no-build

Conversation

@baronfel

Copy link
Copy Markdown
Member

Summary

  • Default BuildProjectReferences to false for SDK projects when NoBuild=true.
  • Prevent project-to-project reference resolution from invoking Build and triggering NETSDK1085 during no-build operations.
  • Preserve explicit BuildProjectReferences=true behavior.
  • Add regression coverage that exercises ResolveReferences on a prebuilt project-reference graph and verifies the explicit opt-in failure path.

Testing

  • Microsoft.NET.Build.Tests.GivenThatWeWantToReferenceAProject.It_does_not_build_project_references_when_no_build_is_requested

Fixes #55176

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 9679e9f0-85eb-4e9d-a521-c8373b344e5f
Copilot AI review requested due to automatic review settings July 13, 2026 14:24
@baronfel
baronfel requested a review from dsplaisted July 13, 2026 14:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the .NET SDK’s default MSBuild behavior so that when NoBuild=true is used, SDK-style projects will default BuildProjectReferences to false. This prevents project-to-project reference resolution from invoking Build on referenced projects (and thereby avoids triggering NETSDK1085) while preserving the opt-in behavior when BuildProjectReferences=true is explicitly set.

Changes:

  • Default BuildProjectReferences=false for SDK projects when NoBuild=true.
  • Add a regression test covering ResolveReferences under NoBuild=true, plus the explicit opt-in failure path (BuildProjectReferences=true) that should still produce NETSDK1085.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
test/Microsoft.NET.Build.Tests/GivenThatWeWantToReferenceAProject.cs Adds regression coverage ensuring ResolveReferences succeeds under NoBuild=true and still fails with NETSDK1085 when opting back into building project references.
src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.props Adds a defaulting rule: when NoBuild=true and BuildProjectReferences is unset, default it to false for SDK projects.

@baronfel

Copy link
Copy Markdown
Member Author

cc @ViktorHofer - if this gets in then we may not need NuGet/NuGet.Client#7541 because the evaluations should magically line up.

@ViktorHofer

Copy link
Copy Markdown
Member

if this gets in then we may not need NuGet/NuGet.Client#7541 because the evaluations should magically line up.

My understanding is that we still need NuGet/NuGet.Client#7541 as the global properties continue to differ, even after this change and therefore extra evaluations gets triggered.

@baronfel

Copy link
Copy Markdown
Member Author

Oh duh, of course you're right.

@baronfel
baronfel merged commit bd3e0e5 into dotnet:main Jul 14, 2026
29 checks passed
@baronfel
baronfel deleted the baronfel-default-p2p-no-build branch July 14, 2026 15:00
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 11.0-preview7 milestone Jul 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Default BuildProjectReferences=false when NoBuild=true (fixes NETSDK1085 during --no-build with P2P references)

3 participants