Default BuildProjectReferences to false when NoBuild is true - #55259
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 9679e9f0-85eb-4e9d-a521-c8373b344e5f
There was a problem hiding this comment.
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=falsefor SDK projects whenNoBuild=true. - Add a regression test covering
ResolveReferencesunderNoBuild=true, plus the explicit opt-in failure path (BuildProjectReferences=true) that should still produceNETSDK1085.
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. |
|
cc @ViktorHofer - 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. |
|
Oh duh, of course you're right. |
Summary
BuildProjectReferencestofalsefor SDK projects whenNoBuild=true.Buildand triggering NETSDK1085 during no-build operations.BuildProjectReferences=truebehavior.ResolveReferenceson 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_requestedFixes #55176