Asp.Net Core 3(Blazor客户端)的生成失败

时间:2019-05-28 15:15:57

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

我已经开始使用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>

好几天以前我都不明白...

3 个答案:

答案 0 :(得分:2)

与Mono GitHub上的

This问题有关。

据我所知,基本上,在IL Mono中的某个地方,IL Linker失败并抛出此错误消息。我们可以在您的错误消息中看到提示。

到目前为止,GitHub上的michaelccote通过在.csproj文件的<BlazorLinkOnBuild>false</BlazorLinkOnBuild>标签内添加<PropertyGroup>...</PropertyGroup>元素解决了该问题

答案 1 :(得分:1)

  

也许当我做Visual Studio / .NET Core 3预览版5

dotnet cli无法使用包含<TargetFramework><TargetFrameworks>属性的csproj构建应用程序...

答案 2 :(得分:0)

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

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