I am creating an ASP.Net Core 3 pre-release 9 MVC app and I want to create some Razor Class Libraries (RCL). When creating a RCL from the template it will default to targeting netstandard2.0
which is indeed not possible for .Net Core 3 anymore referring to the following GitHub issue. This then throws some weird errors by the following code:
<Project Sdk="Microsoft.NET.Sdk.Razor">
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
<RazorLangVersion>3.0</RazorLangVersion>
</PropertyGroup>
<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>
</Project>
For creating RCL for MVC, you need to configuring Support pages and views
like
For this, it will append <AddRazorSupportForMvc>true</AddRazorSupportForMvc>
in your *.csproj like
<Project Sdk="Microsoft.NET.Sdk.Razor">
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
<AddRazorSupportForMvc>true</AddRazorSupportForMvc>
</PropertyGroup>
<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>
</Project>
For above screen shot, it uses VS 2019 Preview.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With