aspnetcore: Razor Class Library in docker container referencing MVC throws rzc generate exited with code 150

Describe the bug

Docker container (from image mcr.microsoft.com/dotnet/core/sdk:3.0-buster) with Razor Class Library project referencing nuget

<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.2.0" />

throws error : rzc generate exited with code 150

To Reproduce

  1. in command line execute

docker run -it --rm mcr.microsoft.com/dotnet/core/sdk:3.0-buster

  1. Inside container execute

mkdir rcl && cd rcl && dotnet new razorclasslib

  1. modify rcl.csproj in the following way to read
<Project Sdk="Microsoft.NET.Sdk.Razor">

  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
    <RazorLangVersion>3.0</RazorLangVersion>
  </PropertyGroup>


  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.Components" Version="3.0.0" />
    <PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="3.0.0" />
    <PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.2.0" />
  </ItemGroup>

</Project>

Outcome

root@3a0f120b5bed:/rcl# dotnet build
Microsoft (R) Build Engine version 16.3.0+0f4c62fea for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Restore completed in 16.53 ms for /rcl/rcl.csproj.
  It was not possible to find any compatible framework version
  The specified framework 'Microsoft.NETCore.App', version '2.0.9' was not found.
    - The following frameworks were found:
        3.0.0 at [/usr/share/dotnet/shared/Microsoft.NETCore.App]

  You can resolve the problem by installing the specified framework and/or SDK.

  The .NET Core frameworks can be found at:
    - https://aka.ms/dotnet-download
/usr/share/dotnet/sdk/3.0.100/Sdks/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Microsoft.NET.Sdk.Razor.Component.targets(106,5): error : rzc generate exited with code 150. [/rcl/rcl.csproj]

Build FAILED.

/usr/share/dotnet/sdk/3.0.100/Sdks/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Microsoft.NET.Sdk.Razor.Component.targets(106,5): error : rzc generate exited with code 150. [/rcl/rcl.csproj]
    0 Warning(s)
    1 Error(s)

Time Elapsed 00:00:20.54

Expected outcome

Project builds

Further technical details

  • ASP.NET Core version

docker container run from image mcr.microsoft.com/dotnet/core/sdk:3.0-buster). Same is happening with alpine based image: mcr.microsoft.com/dotnet/core/sdk:3.0-alpine3.10

Include the output of dotnet --info

dotnet --info .NET Core SDK (reflecting any global.json): Version: 3.0.100 Commit: 04339c3a26

Runtime Environment: OS Name: debian OS Version: 10 OS Platform: Linux RID: debian.10-x64 Base Path: /usr/share/dotnet/sdk/3.0.100/

Host (useful for support): Version: 3.0.0 Commit: 7d57652f33

.NET Core SDKs installed: 3.0.100 [/usr/share/dotnet/sdk]

.NET Core runtimes installed: Microsoft.AspNetCore.App 3.0.0 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 3.0.0 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

To install additional .NET Core runtimes or SDKs: https://aka.ms/dotnet-download

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 18 (9 by maintainers)

Most upvoted comments

Sorry, I should have been more clear. Setting RazorLangVersion to 3.0 for applications targeting MVC 2.X, i.e. <PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.2.0" /> is not supported.

The reason why your roll forward ends up working I bet is that it’s lifting your MVC version to be 3.0. If you remove that package reference entirely you’ll still have access to MVC’s 3.0 bits (we’re part of the shared framework now) and won’t have to set the rollforward piece.