Reputation: 13458
I have converted a library to .NET Standard 2.0 to be a Razor Component library:
I changed the SDK type to Razor:
<Project Sdk="Microsoft.NET.Sdk.Razor">
and added the references to the Razor component libraries
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components" Version="3.1.8" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="3.1.8" />
</ItemGroup>
However when editing components I find the compilation process is failing. For example it fails to correctly map a @bind=..
attribute in a HTML tag and the Razor components don't seem to compile correctly.
Upvotes: 1
Views: 555
Reputation: 13458
This is caused by a missing _Imports.razor
file, which is normally created if you create a Razor Component Library directly. This brings the correct Component library into scope for Razor compilation. Create this in the root of the library.
The content should contain at least this line:
@using Microsoft.AspNetCore.Components.Web
You can bring other namespaces into scope as well if you desire.
Upvotes: 1