-
Notifications
You must be signed in to change notification settings - Fork 10.3k
RazorSourceGenerator fails with net10.0 Preview 3 #61439
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
For anyone arriving here with the same error, this is a regression from the Preview 2 release. {
"sdk": {
"version": "10.0.100-preview.2.25164.34",
"allowPrerelease": true,
"rollForward": "disable"
}
} This will tell dotnet to use the Preview 2 SDK, even though all the libraries are still Preview 3 spec. |
Does it build correctly with preview 3 using the CLI and it's just a Visual Studio issue, or is it broken with both? |
As with VS, "Broken with both" I would say. (I'm testing against my solution and not against the default VS templates, but I've no reason to expect the behaviour will be different). This all works fine in P2, so the issue is a regression, or more likely a breaking change in P3 that is not accounted for in the RazorSourceGenerator. |
This issue might be one for dotnet/razor rather than here. Someone on the aspnetcore team can move it if that's the case. |
@richardhauer the way I solved this issue was to grab the nightly build for the preview 4 SDK (10.0.100-preview.4.25211.22) This meant I started to get this error Which I solved by setting the VSDebugger_ValidateDotnetDebugLibSignatures environment variable I created a .bat file in the root folder of my BlazorApp solution and added these 2 lines, I use this to start VS2022 preview, which prevented the above error when running the project
You also need to add a NuGet.Config file to the root of your solution
|
Seems that the latest VS Preview release fixes this issue, according to notes on dotnet/razor#11735 so I will close this out now. |
Is there an existing issue for this?
Describe the bug
I have just updated SDK and packages to the new Preview 3 versions and I can no longer compile a Razor Class Library. Possibly also other projects that depend on it, but I'm blocked so far at the RCL.
I get two errors that appear to be directly related to the net10 build:
and
I can't find a workaround for now and there does not appear to be any way to update the RazorSourceGenerator from 9.0.0.0 to anything higher using nuGet or VS update.
We can repro this error using just the template RCL with no code changes.

The screen shot shows that, while the library compiles with the warnings, the types that should have been included from the Razor files are missing from the output, as you'd expect from these warnings.
Expected Behavior
Project should build as normal. RazorSourceGenerator needs an update if there are breaking changes in dependent libraries.
While the RCL library does build, without the RazorSourceGenerator the Razor types inside the library are not included in the output, so it is not possible to refer to these in other projects.
Steps To Reproduce
My project hierarchy is big and convoluted.
I created a new, entirely blank Razor Class Library from the Visual Studio templates, based on Net10 Preview. Did nothing at all to the code.
Build. Got the same warnings from the compiler.
So, this is pretty easily reproducible.
Attempting to reference Razor types or namespaces from other libraries causes build failures (obviously).
Exceptions (if any)
No response
.NET Version
10.0.100-preview.3.25201.16
Anything else?
I am using Visual Studio Enterprise 17.14.0 Preview 2.0
Windows 11 Enterprise 24H2 (26100.3624)
This is my installed workload list:
This is my SDK list
Output from dotnet --info
Not sure what else might be of value. The RCL project is pretty standard - the Project SDK is
Microsoft.NET.Sdk.Razor
and the TargetFramework is set tonet10.0
with Nullable also set toenable
The text was updated successfully, but these errors were encountered: