Skip to content

Comments

Allow Umbraco projects to work with the Razor cohosting editor#21861

Open
davidwengier wants to merge 2 commits intoumbraco:mainfrom
davidwengier:FixRazorCohostEditor
Open

Allow Umbraco projects to work with the Razor cohosting editor#21861
davidwengier wants to merge 2 commits intoumbraco:mainfrom
davidwengier:FixRazorCohostEditor

Conversation

@davidwengier
Copy link

@davidwengier davidwengier commented Feb 23, 2026

Hello Umbraco friends!

Apologies in advance, for not following good open source practice and just opening a PR blind. Feel free to close it with extreme prejudice, and someone else can post another with the same exact change, I won't mind :)

I work on the Razor tooling team at Microsoft and we have recently shipped a new editor in Visual Studio 2026 and the C# Extension for VS Code, which we refer to as the "cohost" editor. This editor relies on the Razor Source Generator in order to function, and unfortunately, we've had reports from some of our users, who are also your users, that breakpoints and other IDE functionality doesn't work in their projects any more. The root cause of this is that there are some things done in the Microsoft.NET.Sdk.Web and Microsoft.NET.Sdk.Razor SDKs that the IDE relies on, that are not done in your SDK.

This PR represents a polyfill to bridge that gap, and allow your users to continue to be our users, and have the full IDE functionality they expect. I am certainly not an Umbraco expert (or beginner!), so please let me know if this change needs to go somewhere else, but we have had confirmation that putting this little bit of MSBuild goo in a project file successfully unblocks people.

Issues that have been filed against us (hopefully in lieu of this PR resolving any specific issue on this repo):
https://developercommunity.visualstudio.com/t/Breakpoints-is-not-working-in-Razor-file/10978894
https://developercommunity.visualstudio.com/t/A-breakpoint-could-not-be-inserted-at-t/11047278 (with confirmation that the change works)

Fixes dotnet/razor#12331 (which is the first issue above, moved to our GitHub repo)

Thanks!
Dave

Copilot AI review requested due to automatic review settings February 23, 2026 06:52
@github-actions
Copy link

Hi there @davidwengier, thank you for this contribution! 👍

While we wait for one of the Core Collaborators team to have a look at your work, we wanted to let you know about that we have a checklist for some of the things we will consider during review:

  • It's clear what problem this is solving, there's a connected issue or a description of what the changes do and how to test them
  • The automated tests all pass (see "Checks" tab on this PR)
  • The level of security for this contribution is the same or improved
  • The level of performance for this contribution is the same or improved
  • Avoids creating breaking changes; note that behavioral changes might also be perceived as breaking
  • If this is a new feature, Umbraco HQ provided guidance on the implementation beforehand
  • 💡 The contribution looks original and the contributor is presumably allowed to share it

Don't worry if you got something wrong. We like to think of a pull request as the start of a conversation, we're happy to provide guidance on improving your contribution.

If you realize that you might want to make some changes then you can do that by adding new commits to the branch you created for this work and pushing new commits. They should then automatically show up as updates to this pull request.

Thanks, from your friendly Umbraco GitHub bot 🤖 🙂

Copy link
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

This pull request adds MSBuild configuration to enable Visual Studio 2026 and VS Code's Razor "cohost" editor to work correctly with Umbraco projects. The Razor cohost editor relies on the Razor source generator for IDE functionality like breakpoints, and requires certain MSBuild items to be configured that are normally provided by Microsoft.NET.Sdk.Web and Microsoft.NET.Sdk.Razor, but not by Umbraco's custom SDK.

Changes:

  • Adds design-time build configuration to make .cshtml files visible to the Razor source generator as AdditionalFiles
  • Exposes MSBuildProjectDirectory to the compiler for proper path computation
  • Includes opt-out mechanism via EnableCohostEditorCompatibility property

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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.

Breakpoints is not working in Razor files *.cshtml - Umbraco template

1 participant