【问题标题】:Build fail for Asp.Net Core 3 (Blazor client side)Asp.Net Core 3(Blazor 客户端)的构建失败
【发布时间】:2019-05-28 15:15:56
【问题描述】:

我已经开始使用 ASP.NET Core 3 和 Blazor 框架开发 Web 应用程序。 在几天/几周内,我可以构建我的应用程序。 自发布预览版 5 以来,我无法构建我的应用程序(使用 dotnet build 命令)。 我有下一个错误:

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]

我的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>

我好几天没听懂,直到……

【问题讨论】:

  • 你运行了哪个命令?
  • @MindSwipe dotnet 构建
  • This GitHub issue for mono(blazor 的运行时)跟踪此错误代码。有人可以通过将&lt;BlazorLinkOnBuild&gt;false&lt;/BlazorLinkOnBuild&gt; 添加到 csproj 中的 ProertyGroup 标记来修复它

标签: c# .net asp.net-core blazor


【解决方案1】:

Mono GitHub 上的This 问题是相关的。

据我所知,基本上,在 Mono 的某个地方,IL 链接器失败并抛出这个神秘的错误消息。我们可以在您的错误消息中看到这方面的提示。

截至目前,GitHub 上的 michaelccote 通过在 .csproj 文件的 &lt;PropertyGroup&gt;...&lt;/PropertyGroup&gt; 标签内添加 &lt;BlazorLinkOnBuild&gt;false&lt;/BlazorLinkOnBuild&gt; 元素解决了这个问题

【讨论】:

  • 哪个 .csproj 文件? *.Server 还是 *.Client?
【解决方案2】:

也许当我做 Visual Studio / .NET Core 3 preview 5 时

dotnet cli 无法使用包含 &lt;TargetFramework&gt; 和 &lt;TargetFrameworks&gt; 属性的 csproj 构建应用程序...

【讨论】:

    【解决方案3】:

    当您使用 Blazor WebAssembly、ASP.NET Core 3.1 时,请导航至 yoursolution/yourproject.Client/ 并编辑 yourproject.Client.csproj-File。添加以下行:

    <Project Sdk="Microsoft.NET.Sdk.Web">
      <PropertyGroup>
        [...]
        <BlazorWebAssemblyEnableLinking>false</BlazorWebAssemblyEnableLinking>
      </PropertyGroup>
      [...]
    </Project>
    

    【讨论】:

      猜你喜欢
      • 2019-10-08
      • 2021-07-25
      • 1970-01-01
      • 2021-04-14
      • 1970-01-01
      • 2017-06-02
      • 2020-08-29
      • 2020-08-31
      • 1970-01-01
      相关资源
      最近更新 更多