[英]Build fail for Asp.Net Core 3 (Blazor client side)
I've start to develop a web application with ASP.NET Core 3 and Blazor framework.我已经开始使用 ASP.NET Core 3 和 Blazor 框架开发 Web 应用程序。 During few days/weeks, I could build my application.在几天/几周内,我可以构建我的应用程序。 Since preview 5 announced, I couldn't build my application (with dotnet build
command).自预览版 5 发布以来,我无法构建我的应用程序(使用dotnet build
命令)。 I've the next error:我有下一个错误:
C:\Users\a\.nuget\packages\microsoft.aspnetcore.blazor.build\3.0.0-preview5-19227-01\targets\Blazor.MonoRuntime.targets(439,5): error MSB3073: The command "dotnet "" -l
-o "D:\Repos\IdeaStudio.Website.Client\obj\Debug\netstandard2.0\linker/"
-x "C:\Users\a\.nuget\packages\microsoft.aspnetcore.blazor.build\3.0.0-preview5-19227-01\targets\BuiltInBclLinkerDescriptor.xml"
-x "D:\Repos\IdeaStudio.Website.Client\obj\Debug\netstandard2.0\linker.descriptor.xml"
-a "C:\Users\a\.nuget\packages\microsoft.aspnetcore.blazor\3.0.0-preview5-19227-01\lib\netstandard2.0\Microsoft.AspNetCore.Blazor.dll"
-a "C:\Users\a\.nuget\packages\microsoft.aspnetcore.components\3.0.0-preview5-19227-01\lib\netstandard2.0\Microsoft.AspNetCore.Components.dll"
-a "C:\Users\a\.nuget\packages\microsoft.aspnetcore.components.browser\3.0.0-preview5-19227-01\lib\netstandard2.0\Microsoft.AspNetCore.Components.Browser.dll"
-a "C:\Users\a\.nuget\packages\microsoft.extensions.dependencyinjection\3.0.0-preview5.19227.9\lib\netstandard2.0\Microsoft.Extensions.DependencyInjection.dll"
-a "C:\Users\a\.nuget\packages\microsoft.extensions.dependencyinjection.abstractions\3.0.0-preview5.19227.9\lib\netstandard2.0\Microsoft.Extensions.DependencyInjection.Abstractions.dll"
-a "C:\Users\a\.nuget\packages\microsoft.jsinterop\3.0.0-preview5.19227.9\lib\netstandard2.0\Microsoft.JSInterop.dll"
-a "C:\Users\a\.nuget\packages\mono.webassembly.interop\3.0.0-preview5.19227.9\lib\netstandard2.0\Mono.WebAssembly.Interop.dll"
-a "C:\Users\a\.nuget\packages\system.componentmodel.annotations\4.6.0-preview5.19224.8\lib\netstandard2.0\System.ComponentModel.Annotations.dll"
-a "D:\Repos\IdeaStudio.Website.Client\obj\Debug\netstandard2.0\IdeaStudio.Website.Client.dll"" exited with code 1.
[D:\Repos\IdeaStudio.Website.Client\IdeaStudio.Website.Client.csproj]
My csproj
looks like :我的csproj
看起来像:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<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>
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<OutputType>Exe</OutputType>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.5.1" />
<PackageReference Include="Microsoft.AspNetCore.Blazor" Version="3.0.0-preview5-19227-01" />
<PackageReference Include="Microsoft.AspNetCore.Blazor.Build" Version="3.0.0-preview5-19227-01" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.Blazor.DevServer" Version="3.0.0-preview5-19227-01" PrivateAssets="all" />
</ItemGroup>
</Project>
I did not understand for several days until...搞了好几天没看懂。。。
This issue on the Mono GitHub is related. Mono GitHub 上的这个问题是相关的。
Basically, as far as I understand it, somewhere in Mono the IL Linker fails and throws this cryptic error message.基本上,据我所知,在 Mono 的某个地方,IL 链接器失败并抛出这个神秘的错误消息。 We can see hints to this in your error message.我们可以在您的错误消息中看到这方面的提示。
As of now, michaelccote on GitHub solved the problem by adding the <BlazorLinkOnBuild>false</BlazorLinkOnBuild>
element inside the <PropertyGroup>...</PropertyGroup>
tags of the .csproj file截至目前,GitHub 上的 michaelccote 通过在 .csproj 文件的<PropertyGroup>...</PropertyGroup>
标签中添加<BlazorLinkOnBuild>false</BlazorLinkOnBuild>
元素解决了该问题
Maybe when I did the Visual Studio / .NET Core 3 preview 5也许当我做 Visual Studio / .NET Core 3 预览 5
dotnet cli
can't build an application with a csproj which contains <TargetFramework>
and <TargetFrameworks>
properties... dotnet cli
无法使用包含<TargetFramework>
和<TargetFrameworks>
属性的 csproj 构建应用程序...
When you are using Blazor WebAssembly, ASP.NET Core 3.1 please navigate to yoursolution/yourproject.Client/
and edit yourproject.Client.csproj
-File.当你使用 Blazor WebAssembly、ASP.NET Core 3.1 时,请导航到yoursolution/yourproject.Client/
并编辑yourproject.Client.csproj
。 Add the following line:添加以下行:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
[...]
<BlazorWebAssemblyEnableLinking>false</BlazorWebAssemblyEnableLinking>
</PropertyGroup>
[...]
</Project>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.