Blazor Mono Clientside Error after updating to netcore3.0-preview8

霸气de小男生 提交于 2021-02-18 14:14:10

问题


I have updated my blazor client side project project from preview7 to preview 8, runnign with Visual Studio 2019.

I have followed the instructions detailed here;

ASP.NET Core and Blazor updates in .NET Core 3.0 Preview 8

However, when I build the solution get the following error;

Fatal error in IL Linker 5> 5>Unhandled Exception: Mono.Linker.Steps.XmlResolutionException: Failed to process XML description: ---> Mono.Cecil.AssemblyResolutionException: Failed to resolve assembly: 'Microsoft.AspNetCore.Mvc.Core, Version=3.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' ---> Mono.Cecil.AssemblyResolutionException: Failed to resolve assembly: 'Microsoft.AspNetCore.Mvc.Core, Version=3.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' 5> at Mono.Linker.DirectoryAssemblyResolver.Resolve(AssemblyNameReference name, ReaderParameters parameters) 5> at Mono.Linker.AssemblyResolver.Resolve(AssemblyNameReference name, ReaderParameters parameters) 5> at Mono.Linker.LinkContext.Resolve(IMetadataScope scope) 5> --- End of inner exception stack trace --- 5> at Mono.Linker.LinkContext.Resolve(IMetadataScope scope) 5> at Mono.Linker.LinkContext.ResolveReferences(AssemblyDefinition assembly) 5> at Mono.Linker.Steps.ResolveFromXmlStep.ProcessAssemblies(LinkContext context, XPathNodeIterator iterator) 5> at Mono.Linker.Steps.ResolveFromXmlStep.Process() 5> --- End of inner exception stack trace --- 5> at Mono.Linker.Steps.ResolveFromXmlStep.Process() 5> at Mono.Linker.Steps.BaseStep.Process(LinkContext context) 5> at Mono.Linker.Pipeline.ProcessStep(LinkContext context, IStep step) 5>
at Mono.Linker.Pipeline.Process(LinkContext context) 5> at Mono.Linker.Driver.Run(ILogger customLogger) 5> at Mono.Linker.Driver.Execute(String[] args, ILogger customLogger) 5>
at Mono.Linker.Driver.Main(String[] args) 5>C:\Users\matt.nuget\packages\microsoft.aspnetcore.blazor.build\3.0.0-preview8.19405.7\targets\Blazor.MonoRuntime.targets(441,5): error MSB3073: The command "dotnet "C:\Users\matt.nuget\packages\microsoft.aspnetcore.blazor.mono\3.0.0-preview8.19380.1\build\netstandard1.0../../tools/illink/illink.dll" -l none --disable-opt unreachablebodies --verbose --strip-security true --exclude-feature com --exclude-feature sre -v false -c link -u link -b true -d "C:\Users\matt.nuget\packages\microsoft.aspnetcore.blazor.mono\3.0.0-preview8.19380.1\build\netstandard1.0../../tools/mono/bcl/" -d "C:\Users\matt.nuget\packages\microsoft.aspnetcore.blazor.mono\3.0.0-preview8.19380.1\build\netstandard1.0../../tools/mono/bcl/Facades/" -o "C:\Users\matt\Source\Repos\OakfieldLeasing\OakfieldLeasing.Blazor.Client\obj\Debug\netcoreapp3.0\blazor\linker/" -x "C:\Users\matt.nuget\packages\microsoft.aspnetcore.blazor.build\3.0.0-preview8.19405.7\targets\BuiltInBclLinkerDescriptor.xml" -x "C:\Users\matt\Source\Repos\OakfieldLeasing\OakfieldLeasing.Blazor.Client\obj\Debug\netcoreapp3.0\blazor\linker.descriptor.xml" -a "C:\Users\matt.nuget\packages\blazored.localstorage\2.0.12\lib\netstandard2.0\Blazored.LocalStorage.dll" -a "C:\Users\matt.nuget\packages\microsoft.aspnetcore.blazor\3.0.0-preview8.19405.7\lib\netstandard2.0\Microsoft.AspNetCore.Blazor.dll" -a "C:\Users\matt.nuget\packages\microsoft.aspnetcore.blazor.httpclient\3.0.0-preview8.19405.7\lib\netstandard2.0\Microsoft.AspNetCore.Blazor.HttpClient.dll" -a "C:\Users\matt.nuget\packages\mono.webassembly.interop\3.0.0-preview8.19405.4\lib\netstandard2.0\Mono.WebAssembly.Interop.dll" -a "C:\Users\matt.nuget\packages\newtonsoft.json\12.0.3-beta1\lib\netstandard2.0\Newtonsoft.Json.dll" -a "C:\Users\matt\Source\Repos\OakfieldLeasing\OakfieldLeasing.Blazor.Shared\bin\Debug\netstandard2.1\OakfieldLeasing.Blazor.Shared.dll" -a "C:\Users\matt\Source\Repos\OakfieldLeasing\OakfieldLeasing.Blazor.Client\obj\Debug\netcoreapp3.0\OakfieldLeasing.Blazor.Client.dll"" exited with code -532462766.

The only other project being referenced by the Blazor Client side project is the Shared project which references .Net Standard 2.1.

I have the following listed in my dependencies -> analyzers on the Blazor Client project.

Finally my .csproj is

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

  <PropertyGroup>
    <TargetFramework>netcoreapp3.0</TargetFramework>
    <OutputType>Exe</OutputType>
    <LangVersion>7.3</LangVersion>
    <RazorLangVersion>3.0</RazorLangVersion>
  </PropertyGroup>

  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
    <OutputPath></OutputPath>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Blazored.LocalStorage" Version="2.0.12" />
    <PackageReference Include="Microsoft.AspNetCore.Blazor" Version="3.0.0-preview8.19405.7" />
    <PackageReference Include="Microsoft.AspNetCore.Blazor.Build" Version="3.0.0-preview8.19405.7" PrivateAssets="all" />
    <PackageReference Include="Microsoft.AspNetCore.Blazor.HttpClient" Version="3.0.0-preview8.19405.7" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3-beta1" />
  </ItemGroup>

  <ItemGroup>
    <ProjectReference Include="..\OakfieldLeasing.Blazor.Shared\OakfieldLeasing.Blazor.Shared.csproj" />
  </ItemGroup>

  <ItemGroup>
    <Folder Include="wwwroot\images\" />
  </ItemGroup>

</Project>

I have also tried replacing the Newtonsoft.Json with Microsoft.AspNetCore.NewtonsoftJson Nuget package, but this doesn't seem to make a difference.

Does anyone have any idea on what could be causing this please?


回答1:


The issue has come from misreading the upgrade blog and documentation.

The blog here

ASP.NET Core and Blazor updates in .NET Core 3.0 Preview 8

In turn refers to Steve Sandersons migration steps here;

Migrate from ASP.NET Core 2.2 to 3.0

which is for porting from 2.2 to 3.0 and references aslter the .csproj to <TargetFramework>netcoreapp3.0</TargetFramework>

which I had wrongly done to the client project. Which is not valid because Mono WebAssembly runs as netstandard2.0, not netcoreapp3.0.

Reverting the .csproj back to netstandard2.0 fixed the issue.



来源:https://stackoverflow.com/questions/57626013/blazor-mono-clientside-error-after-updating-to-netcore3-0-preview8

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!