Aspnetcore: Blazor Library template does not build.

Created on 27 Apr 2019  路  6Comments  路  Source: dotnet/aspnetcore

Trying to build the Blazor Library (blazorlib) template produces the following error.

rzc generate exited with code 1.

To Reproduce

  1. Create a new solution.
  2. dotnet new blazorlib
  3. Add the project to the solution.
  4. Try to build the project.

Expected behavior

The project should build.

Additional context

.NET Core SDK (reflecting any global.json):
Version: 3.0.100-preview4-011223
Commit: 118dd862c8

Runtime Environment:
OS Name: Windows
OS Version: 10.0.17134
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\3.0.100-preview4-011223\

Host (useful for support):
Version: 3.0.0-preview4-27615-11
Commit: ee54d4cbd2

.NET Core SDKs installed:
2.1.602 [C:\Program Files\dotnet\sdk]
2.1.700-preview-009601 [C:\Program Files\dotnet\sdk]
2.2.202 [C:\Program Files\dotnet\sdk]
3.0.100-preview4-011223 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.2.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.2.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.0.0-preview4-19216-03 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.2.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.0.0-preview4-27615-11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

> Microsoft.WindowsDesktop.App 3.0.0-preview4-27613-28 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Microsoft Visual Studio Community 2019 Preview
Version 16.1.0 Preview 2.0
VisualStudio.16.Preview/16.1.0-pre.2.0+28822.285
Microsoft .NET Framework
Version 4.7.03056

Installed Version: Community

Application Insights Tools for Visual Studio Package 9.0.20307.1
Application Insights Tools for Visual Studio

ASP.NET and Web Tools 2019 16.1.302.53887
ASP.NET and Web Tools 2019

ASP.NET Core Blazor Language Services 16.0.19216.03

ASP.NET Web Frameworks and Tools 2019 16.1.302.53887
For additional information, visit https://www.asp.net/

Azure App Service Tools v3.0.0 16.1.302.53887
Azure App Service Tools v3.0.0

C# Tools 3.1.0-beta2-19211-01+9d88fee4efb9f7ae4ae053d63b9f8b5b31217c90
C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Common Azure Tools 1.10
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

IntelliCode Extension 1.0
IntelliCode Visual Studio Extension Detailed Info

Microsoft Continuous Delivery Tools for Visual Studio 0.4
Simplifying the configuration of Azure DevOps pipelines from within the Visual Studio IDE.

Microsoft JVM Debugger 1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines

Microsoft Library Manager 1.0
Install client-side libraries easily to any web project

Microsoft MI-Based Debugger 1.0
Provides support for connecting Visual Studio to MI compatible debuggers

Microsoft Visual Studio Tools for Containers 1.1
Develop, run, validate your ASP.NET Core applications in the target environment. F5 your application directly into a container with debugging, or CTRL + F5 to edit & refresh your app without having to rebuild the container.

NuGet Package Manager 5.1.0
NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.

ProjectServicesPackage Extension 1.0
ProjectServicesPackage Visual Studio Extension Detailed Info

ResourcePackage Extension 1.0
ResourcePackage Visual Studio Extension Detailed Info

ResourcePackage Extension 1.0
ResourcePackage Visual Studio Extension Detailed Info

SQL Server Data Tools 16.0.61904.17120
Microsoft SQL Server Data Tools

TypeScript Tools 16.0.10411.2001
TypeScript Tools for Microsoft Visual Studio

Visual Basic Tools 3.1.0-beta2-19211-01+9d88fee4efb9f7ae4ae053d63b9f8b5b31217c90
Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Visual F# Tools 10.4 for F# 4.6 16.0.0.0. Commit Hash: 809f41207b74a1356208f11b8fa3a15233734050.
Microsoft Visual F# Tools 10.4 for F# 4.6

Visual Studio Code Debug Adapter Host Package 1.0
Interop layer for hosting Visual Studio Code debug adapters in Visual Studio

Visual Studio Tools for Containers 1.0
Visual Studio Tools for Containers

Most helpful comment

You probably have the wrong version of Microsoft.AspNetCore.Blazor.Templates, that's why you have the wrong package versions.

Can you run the following commands and tell me if it works?

> dotnet new -u Microsoft.AspNetCore.Blazor.Templates
> dotnet new -i Microsoft.AspNetCore.Blazor.Templates::3.0.0-preview4-19216-03
> dotnet new blazorlib
> dotnet build

Your .csproj should look something like this:
(notice how now it uses Microsoft.AspNetCore.Components.Browser)

<Project Sdk="Microsoft.NET.Sdk.Razor">

  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
    <IsPackable>true</IsPackable>
    <RestoreAdditionalProjectSources>
      https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json;
      https://dotnet.myget.org/F/blazor-dev/api/v3/index.json;
    </RestoreAdditionalProjectSources>
    <LangVersion>7.3</LangVersion>
    <RazorLangVersion>3.0</RazorLangVersion>
    <AddRazorSupportForMvc>true</AddRazorSupportForMvc>
  </PropertyGroup>

  <ItemGroup>
    <!-- .js/.css files will be referenced via <script>/<link> tags; other content files will just be included in the app's 'dist' directory without any tags referencing them -->
    <EmbeddedResource Include="content\**\*.js" LogicalName="blazor:js:%(RecursiveDir)%(Filename)%(Extension)" />
    <EmbeddedResource Include="content\**\*.css" LogicalName="blazor:css:%(RecursiveDir)%(Filename)%(Extension)" />
    <EmbeddedResource Include="content\**" Exclude="**\*.js;**\*.css" LogicalName="blazor:file:%(RecursiveDir)%(Filename)%(Extension)" />
  </ItemGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.Components.Browser" Version="3.0.0-preview4-19216-03" />
  </ItemGroup>

</Project>

All 6 comments

Can you post the contents of .csproj?

I'm also experiencing this.

I walked through the following tutorial:
https://www.telerik.com/blogs/creating-a-reusable-javascript-free-blazor-modal

Template comes with stable NuGet package Microsoft.AspNetCore.Blazor.Build v.0.7.0. There's an update available for version 3.0.0-preview4-19216-03 which fixed the issue for me.

You probably have the wrong version of Microsoft.AspNetCore.Blazor.Templates, that's why you have the wrong package versions.

Can you run the following commands and tell me if it works?

> dotnet new -u Microsoft.AspNetCore.Blazor.Templates
> dotnet new -i Microsoft.AspNetCore.Blazor.Templates::3.0.0-preview4-19216-03
> dotnet new blazorlib
> dotnet build

Your .csproj should look something like this:
(notice how now it uses Microsoft.AspNetCore.Components.Browser)

<Project Sdk="Microsoft.NET.Sdk.Razor">

  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
    <IsPackable>true</IsPackable>
    <RestoreAdditionalProjectSources>
      https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json;
      https://dotnet.myget.org/F/blazor-dev/api/v3/index.json;
    </RestoreAdditionalProjectSources>
    <LangVersion>7.3</LangVersion>
    <RazorLangVersion>3.0</RazorLangVersion>
    <AddRazorSupportForMvc>true</AddRazorSupportForMvc>
  </PropertyGroup>

  <ItemGroup>
    <!-- .js/.css files will be referenced via <script>/<link> tags; other content files will just be included in the app's 'dist' directory without any tags referencing them -->
    <EmbeddedResource Include="content\**\*.js" LogicalName="blazor:js:%(RecursiveDir)%(Filename)%(Extension)" />
    <EmbeddedResource Include="content\**\*.css" LogicalName="blazor:css:%(RecursiveDir)%(Filename)%(Extension)" />
    <EmbeddedResource Include="content\**" Exclude="**\*.js;**\*.css" LogicalName="blazor:file:%(RecursiveDir)%(Filename)%(Extension)" />
  </ItemGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.Components.Browser" Version="3.0.0-preview4-19216-03" />
  </ItemGroup>

</Project>

@rjmr97 That did it!

@rjmr97 That worked for me too 馃憤 Thanks

Was this page helpful?
0 / 5 - 0 ratings

Related issues

FourLeafClover picture FourLeafClover  路  3Comments

aurokk picture aurokk  路  3Comments

guardrex picture guardrex  路  3Comments

UweKeim picture UweKeim  路  3Comments

snebjorn picture snebjorn  路  3Comments