locked
Blazor Webassembly error when adding project refrence RRS feed

  • Question

  • User492022847 posted

    In my Blazor WebAssembly project I add a project reference to a class library in my soulution. Then I get the following error:

    > Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(387, 5): [NETSDK1082] There was no runtime pack for Microsoft.AspNetCore.App available for the specified RuntimeIdentifier 'browser-wasm'.

    Also the entire project has missing references to System, Microsoft.AspNetCore, ...

    I am using the latest NET5.

    This is my project properties where I add my refrence:

    <Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">
    
        <PropertyGroup>
            <TargetFramework>net5.0</TargetFramework>
            <UseBlazorWebAssembly>true</UseBlazorWebAssembly>
        </PropertyGroup>
    
        <ItemGroup>
            <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="5.0.0" />
            <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="5.0.0" PrivateAssets="all" />
            <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Authentication" Version="5.0.0" />
            <PackageReference Include="Microsoft.Extensions.Http" Version="5.0.0" />
            <PackageReference Include="System.Net.Http.Json" Version="5.0.0" />
        </ItemGroup>
    
        <ItemGroup>
          <ProjectReference Include="..\Dashboard.Core\Dashboard.Core.csproj" />
        </ItemGroup>
    </Project>

    Monday, November 16, 2020 8:39 PM

All replies

  • User475983607 posted

    Please do not make the community guess what you are trying to do.   What is the reference project?  Is it a .NET 5 project?  .NET standard?  Perhaps you need to follow the migration guide?

    https://docs.microsoft.com/en-us/aspnet/core/migration/31-to-50?view=aspnetcore-5.0&tabs=visual-studio

    Monday, November 16, 2020 9:14 PM
  • User492022847 posted

    All my projects are NET 5. I started with a new sulotion and all the projects are in .NET 5. So migrations isn't usefull for me. 

    Monday, November 16, 2020 9:24 PM
  • User475983607 posted

    dikkepanda

    All my projects are NET 5. I started with a new sulotion and all the projects are in .NET 5. So migrations isn't usefull for me. 

    Your response is not very helpful.  You answered one question and now we know the project is a .NET 5 project.  But what kind of project?  A Razor Page Class Library?  A class library?  What is it?  Can you explain the general design?

    Monday, November 16, 2020 9:34 PM
  • User492022847 posted

    Sorry, I am new in .NET. The project that I try to refrence is een class library. So, I have a BlazorWebassembly and in that project i try to refrence to a class library.

    Monday, November 16, 2020 9:41 PM
  • User475983607 posted

    dikkepanda

    Sorry, I am new in .NET. The project that I try to refrence is een class library. So, I have a BlazorWebassembly and in that project i try to refrence to a class library.

    I can't reproduce this problem.  I created .NET 5 Blazor WASM project.  Next I created a .net standard class library with the following class.

    using System;
    
    namespace ClassLibraryDemo
    {
        public class Constants
        {
            public const string Greeting = "Hello World";
        }
    }
    

    In the Blazor index page displays Hello World.

    @page "/"
    
    <h1>Hello, world!</h1>
    
    Welcome to your new app.
    
    <SurveyPrompt Title="How is Blazor working for you?" />
    
    <div>
        @ClassLibraryDemo.Constants.Greeting
    </div>
    
    <Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">
    
      <PropertyGroup>
        <TargetFramework>net5.0</TargetFramework>
      </PropertyGroup>
    
      <ItemGroup>
        <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="5.0.0" />
        <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="5.0.0" PrivateAssets="all" />
        <PackageReference Include="System.Net.Http.Json" Version="5.0.0" />
      </ItemGroup>
    
      <ItemGroup>
        <ProjectReference Include="..\ClassLibraryDemo\ClassLibraryDemo.csproj" />
      </ItemGroup>
    
    </Project>

    Are you sure you created a .net standard class?

    <Project Sdk="Microsoft.NET.Sdk">
    
      <PropertyGroup>
        <TargetFramework>netstandard2.1</TargetFramework>
      </PropertyGroup>
    
    </Project>
    

    Monday, November 16, 2020 10:01 PM
  • User492022847 posted

    I have used your advice and also started an empty project. But I used NET 5 for the class library just the same as my original project. I had no problems so I went to see what the differences are between the projects. The difference was that I made a reference to another class library in my class library. In that class library I used several packages and I disabled them all. One by one I included the package back and found that the package IdentityServer4 and IdentityCore.Ui were causing this problem.

    I want to thank you for taking the time to help me and point me in the good direction of finding a solution.

    Tuesday, November 17, 2020 11:31 AM