Skip to content

Allow referencing virtual projects#13389

Merged
jjonescz merged 2 commits intodotnet:mainfrom
jjonescz:virtual-proj-ref
Mar 25, 2026
Merged

Allow referencing virtual projects#13389
jjonescz merged 2 commits intodotnet:mainfrom
jjonescz:virtual-proj-ref

Conversation

@jjonescz
Copy link
Copy Markdown
Member

Part of dotnet/sdk#53478.

@jjonescz jjonescz marked this pull request as ready for review March 16, 2026 14:16
Copilot AI review requested due to automatic review settings March 16, 2026 14:16
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Enables ProjectReference to work with virtual (in-memory) projects when _BuildNonexistentProjectsByDefault is enabled, supporting SDK scenarios like file-based apps that synthesize projects into the ProjectRootElementCache.

Changes:

  • Update _SplitProjectReferencesByFileExistence to treat all ProjectReference items as “existent” when _BuildNonexistentProjectsByDefault=true.
  • Add unit tests validating both the split behavior and end-to-end ResolveProjectReferences behavior with in-memory projects.
  • Extend the spec to document ProjectReference behavior and virtual project limitations (notably out-of-proc node isolation).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
src/Tasks/Microsoft.Common.CurrentVersion.targets Bypasses Exists() classification for project references when building nonexistent projects by default, enabling virtual references.
src/Build.UnitTests/BackEnd/MSBuild_Tests.cs Adds coverage for virtual ProjectReference behavior (split + end-to-end build).
documentation/specs/build-nonexistent-projects-by-default.md Documents new ProjectReference behavior and clarifies constraints for virtual projects.

You can also share your feedback on Copilot code review. Take the survey.

@jjonescz
Copy link
Copy Markdown
Member Author

jjonescz commented Mar 23, 2026

@dotnet/msbuild for a review of this simple change that would allow us to implement #:ref support for file-based apps; thanks!

@baronfel
Copy link
Copy Markdown
Member

I really like this conceptually, because it's been pretty frustrating having to whack-a-mole support for file-based apps in other hosts.

@jjonescz jjonescz merged commit 0f7f8dd into dotnet:main Mar 25, 2026
10 checks passed
@jjonescz jjonescz deleted the virtual-proj-ref branch March 25, 2026 20:42
dfederm pushed a commit to dfederm/msbuild that referenced this pull request Apr 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants