Skip to content

Commit 4631b49

Browse files
authored
Document cohosting known issues and solutions (#12852)
2 parents ced03ad + 67d3614 commit 4631b49

1 file changed

Lines changed: 61 additions & 0 deletions

File tree

docs/CohostingTroubleshooting.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Troubleshooting the Cohosted Razor Editor in Visual Studio
2+
3+
This document covers known issues with the cohosted Razor editor in Visual Studio and their solutions.
4+
5+
Most issues with the cohosted editor stem from the Razor source generator not being enabled or not functioning correctly. When this happens, the editor may show no IntelliSense, report missing components, or appear to not recognize Razor files at all. Check the Output window under the **Razor Logger Output** category for diagnostic messages.
6+
7+
## Known Issues
8+
9+
### `UseRazorSourceGenerator` Set to False
10+
11+
If your project file disables the Razor source generator:
12+
13+
```xml
14+
<UseRazorSourceGenerator>false</UseRazorSourceGenerator>
15+
```
16+
17+
the cohosted editor will not function correctly. A message will be logged to the Output window under the **Razor Logger Output** category indicating that there are no additional files in the project.
18+
19+
**Solution:** Set `UseRazorSourceGenerator` to `true`:
20+
21+
```xml
22+
<UseRazorSourceGenerator>true</UseRazorSourceGenerator>
23+
```
24+
25+
If your CI or build pipeline requires the source generator to be disabled, you can condition it on design-time builds so the editor still works:
26+
27+
```xml
28+
<UseRazorSourceGenerator Condition="'$(DesignTimeBuild)' == 'true'">true</UseRazorSourceGenerator>
29+
```
30+
31+
### Projects Targeting .NET 5.0 or Below
32+
33+
If your project targets `net5.0` or an earlier framework, the Razor source generator is not enabled by default. These frameworks are [out of support](https://dotnet.microsoft.com/en-us/platform/support/policy/dotnet-core) and there are no plans to support them in the cohosted editor at this time.
34+
35+
**Workaround:** Install an older version of Visual Studio (which can be installed side-by-side with newer versions) to work with these projects.
36+
37+
### Projects Using the `MSBuild.SDK.SystemWeb` SDK
38+
39+
The community `MSBuild.SDK.SystemWeb` SDK has never been officially supported and previously worked by opting in to a legacy editor that has since been deprecated.
40+
41+
The only officially supported path for ASP.NET projects on .NET Framework is to use the classic `.csproj` format project files.
42+
43+
**Workarounds:**
44+
- For a potential fix to unblock the cohosting editor in these scenarios, see [dotnet/razor#12332](https://github.com/dotnet/razor/issues/12332).
45+
- Install an older version of Visual Studio (e.g., 2022) side-by-side with the current version.
46+
47+
### Projects Using Umbraco Templates
48+
49+
Some Umbraco templates do not add additional items and are missing other metadata that the Razor source generator requires, which prevents the cohosted editor from functioning correctly.
50+
51+
A fix has been contributed to the Umbraco templates ([Umbraco-CMS#21861](https://github.com/umbraco/Umbraco-CMS/pull/21861)) and is expected to ship in Umbraco 17.3.
52+
53+
See also [dotnet/razor#12331](https://github.com/dotnet/razor/issues/12331) for more details.
54+
55+
### Pinning to Specific .NET 8 SDK Versions via `global.json`
56+
57+
If your project uses a `global.json` that pins to a specific .NET 8 SDK version (e.g., `8.0.201`, and possibly others), the Razor source generator may not work because the SDK looks for an older filename.
58+
59+
This was fixed in subsequent .NET 8 SDK versions (e.g., `8.0.317` or `8.0.414`). The SDK versions known to exhibit this problem are all out of support.
60+
61+
**Solution:** Install a newer .NET 8 SDK and allow your project to roll forward. Given the affected versions are out of support, upgrading is advisable regardless.

0 commit comments

Comments
 (0)