dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
35.38k stars 10k forks source link

[BlazorWebassembly] Upgrade to net5.0 rc fails with several errors #26773

Closed TFTomSun closed 4 years ago

TFTomSun commented 4 years ago

I tried to upgrade an existing application to net5.0. The application builds fine (without optimization), unfortunately the application doesn't load at all. I see several errors. Here's the log file: localhost-1602332680112.log

One of the errors is:

Error: System.TypeLoadException: Could not resolve type with token 0100003e from typeref (expected class 'System.Runtime.CompilerServices.IAsyncStateMachine' in assembly 'System.Runtime, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a')

The application depends on some razor class libraries (which I updated to net5.0) and some netstandard2.0 libaries.

nikonthethird commented 4 years ago

It's still attempting to run dotnet.3.2.0.js instead of dotnet.5.0.0-rc.1.20451.14.js. It looks like your upgrade may be incomplete.

Which guide did you follow?

Did you do all the things described here as well?

Btw this also mentions to remove any Microsoft.AspNetCore.Components.WebAssembly.Build package reference.

Robelind commented 4 years ago

Without Microsoft.AspNetCore.Components.WebAssembly.Build, wwwroot\_framework is empty, except for the empty directories _bin and wasm.

TFTomSun commented 4 years ago

@nikonthethird I did all the required changes. I don't know if it could be related to the netstandard 2.0 projects. They reference some system assemblies and of course not in a 5.0.0-* version

TFTomSun commented 4 years ago

I was able to solve the issues I had.

Robelind commented 4 years ago

I was able to solve the issues I had.

Could you please share how you solved it.

mkArtakMSFT commented 4 years ago

Glad that you were able to solve your issue, @TFTomSun. We're closing this issue. Hope you can share some info with @Robelind as they have similar issue.

TFTomSun commented 4 years ago

@Robelind I had several issues to fix. Here is my working blazor app csproj:

<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">
  <PropertyGroup>
    <TargetFramework>net50</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="Microsoft.Bcl.AsyncInterfaces" Version="5.0.0-*" />
    <PackageReference Include="System.Threading.Channels" Version="5.0.0-*" />

   <PackageReference Include="TomSun.Net.Blazor.Demo.Common" Version="*" />
  </ItemGroup>
</Project>

A razor library should look like this:

<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk.Razor">
  <PropertyGroup>
    <TargetFramework>net50</TargetFramework>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.Components" Version="5.0.0-*" />
    <PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="5.0.0-*" />
  </ItemGroup>
  <ItemGroup />
</Project>