Resolving «rzc generate exited with error code» error

comments

Microsoft Blazor Logo

Today I were involved back into project I had worked on before. A lot has changed in the project since then. Teammates decided to explore Blazor for client web applications developmen. They decided to use Blazor in non-critical place first - for Web UI for admins (actually, for developers and analytics).

When I've opened and tried to build the solution with Blazor project in Rider, I got error:

%USERPROFILE%\.nuget\packages\microsoft.aspnetcore.blazor.build\0.7.0\targets\RazorCompilation.targets(184,5):
Error  : rzc generate exited with code -2147450730.

Note here and after I use abbreviation %USERPROFILE% environment variable which is pointing to current user's profile directory. This part of path is unique for different users.

There was no any explanation what's going wrong in build output at all and I started to google. Which is fun, other people doesn't got -2147450730 exit code, it was 1 or 2 in tickets. I didn't find any steps which may helps me though.

Blazor project file looked as simple as this:

<Project Sdk="Microsoft.NET.Sdk.Web">
  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
    <OutputType>Exe</OutputType>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.Blazor.Browser" Version="0.7.0" />
    <PackageReference Include="Microsoft.AspNetCore.Blazor.Build" Version="0.7.0" PrivateAssets="all" />
  </ItemGroup>
</Project>

I decided to build just that project from command line with dotnet build. I got the same error, but there was an explanation:

It was not possible to find any compatible framework version.
The specified framework 'Microsoft.NETCore.App', version '2.0.7' was not found.
    - The following frameworks were found:
        3.0.1 at [C:\Program Files\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

.NET SDK 2.0.7 is missing. Bingo! Ok, I've installed the latest SDK for .NET Core 2.0 (v2.1.202 at time of writing). Since other projects in solution used .NET Core 2.1, I've also installed SDK for .NET Core 2.1 (v2.1.607 at time of writing). Unfortunately, other error was there:

%USERPROFILE%\.nuget\packages\microsoft.aspnetcore.blazor.build\0.7.0\targets\RazorCompilation.targets(184,5):
error : rzc generate exited with code 1.

This error was more common, but nothing has helped me from search results.

I understood that error is linked with .NET Core 3 SDK presence. I've tried to specify SDK version using global.json and this helps:

{
    "sdk": {
        "version": "2.1.607"
    }
}

Note you can see installed SDK versions using dotnet --info command. Here I need specify .NET Core 2.1 SDK version because of other projects in solution was targeting to netcoreapp2.1.

Note also that after all I've removed the .NET SDK v2.0 and it's still builds successfully. So, installing .NET SDK v2.0 may be unnecessary.

Conclusion

When you have .NET Core 3 SDK installed, and you use Blazor, you may got «rzc generate exited with error code» error. To resolve, you may need install latest .NET Core SDK 2.0 and/or 2.1 and specify sdk version in global.json.

Hope this helps someone :)


liberapay link If you like this post, consider supporting me on liberapay

Comments