Skip to content

MSBuildWorkspace does not cleanly load blazorwasm project #72015

@JoeRobich

Description

@JoeRobich

Version Used: 4.10 Preview 1

Reported in #69225

Steps to Reproduce:

  1. dotnet new blazorwasm (or blazor or blazorwasm-empty)
  2. use MSBuildWorkspace.OpenProjectAsync to load the newly created project

Expected Behavior:
Project loads without any workspace diagnostics and compilation reports no compiler diagnostics.

Actual Behavior:
Compilation reports "CS0246: The type or namespace name {'csharp_blazor_project'|'App'} could not be found (are you missing a using directive or an assembly reference?)"

Possibly unrelated
I noticed that the C# extension in VS Code reports the following when opening the blazorwasm project.

Generator 'RazorSourceGenerator' failed to initialize. It will not contribute to the output and compilation errors may occur as a result. Exception was of type 'TypeLoadException' with message 'Type 'Microsoft.CodeAnalysis.ExternalAccess.RazorCompiler.HostOutputNode`1[TInput]' from assembly 'Microsoft.CodeAnalysis.ExternalAccess.RazorCompiler, Version=4.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' is attempting to implement an inaccessible interface.'.
System.TypeLoadException: Type 'Microsoft.CodeAnalysis.ExternalAccess.RazorCompiler.HostOutputNode`1[TInput]' from assembly 'Microsoft.CodeAnalysis.ExternalAccess.RazorCompiler, Version=4.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' is attempting to implement an inaccessible interface.
   at Microsoft.CodeAnalysis.ExternalAccess.RazorCompiler.GeneratorExtensions.RegisterHostOutput[TSource](IncrementalGeneratorInitializationContext& this, IncrementalValuesProvider`1 source, Action`3 action)
   at Microsoft.NET.Sdk.Razor.SourceGenerators.RazorSourceGenerator.Initialize(IncrementalGeneratorInitializationContext context)
   at Microsoft.CodeAnalysis.GeneratorDriver.RunGeneratorsCore(Compilation compilation, DiagnosticBag diagnosticsBag, CancellationToken cancellationToken) in /_/src/Compilers/Core/Portable/SourceGeneration/GeneratorDriver.cs:line 226

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions