我无法运行 Blazor-blazor托管的应用程序(作为一个整体)
我无法编译 Blazor.Client端。
首先-发生此错误
Severity Code Description Project File Line Suppression State
Error MSB3073 The command "dotnet "C:\Admins\Admin\.nuget\packages\microsoft.aspnetcore.blazor.build\0.7.0\targets\../tools/illink/illink.dll"
-l none --verbose --strip-security true --exclude-feature com --exclude-feature sre -v false -c link -u link -b true -d "C:\Admins\Admin\.nuget\packages\microsoft.aspnetcore.blazor.build\0.7.0\targets\../tools/mono/bcl/" -d "C:\Admins\Admin\.nuget\packages\microsoft.aspnetcore.blazor.build\0.7.0\targets\../tools
/mono/bcl/Facades/" -o "C:\Repo\Project\Blazor\Blazor.Client\obj\Debug\netstandard2.0\blazor\linker/" -x
"C:\Admins\Admin\.nuget\packages\microsoft.aspnetcore.blazor.build\0.7.0\targets\BuiltInBclLinkerDescriptor.xml"
-x "C:\Repo\Project\Blazor\Blazor.Client\obj\Debug\netstandard2.0\blazor\linker.descriptor.xml" -a
"C:\Admins\Admin\.nuget\packages\microsoft.aspnetcore.blazor\0.7.0\lib\netstandard2.0
\Microsoft.AspNetCore.Blazor.dll" -a "C:\Admins\Admin\.nuget\packages\microsoft.aspnetcore.blazor.browser\0.7.0\lib\netstandard2.0\Microsoft.AspNetCore.Blazor.Browser.dll" -a "C:\Admins\Admin\.nuget\packages\microsoft.aspnetcore.blazor.build\0.7.0\lib\netstandard1.0\Microsoft.AspNetCore.Blazor.TagHelperWorkaround.dll" -a "C:\Admins\Admin\.nuget\packages\microsoft.extensions.dependencyinjection\2.1.0\lib\netstandard2.0\Microsoft.Extensions.DependencyInjection.dll" -a "C:\Admins\Admin\.nuget\packages\microsoft.extensions.dependencyinjection.abstractions\2.1.0\lib\netstandard2.0
\Microsoft.Extensions.DependencyInjection.Abstractions.dll" -a "C:\Admins\Admin\.nuget\packages
\microsoft.jsinterop\0.7.0\lib\netstandard2.0\Microsoft.JSInterop.dll" -a "C:\Admins\Admin\.nuget
\packages\mono.webassembly.interop\0.7.0\lib\netstandard2.0\Mono.WebAssembly.Interop.dll" -a "C:\Program Files\dotnet\sdk\NuGetFallbackFolder\system.componentmodel.annotations\4.5.0
\lib\netstandard2.0\System.ComponentModel.Annotations.dll" -a "C:\Repo\Project\Blazor\Blazor.Shared
\bin\Debug\netstandard2.0\Blazor.Shared.dll" -a "C:\Repo\Project\Blazor\Blazor.Shared\bin\Debug\netstandard2.0\Microsoft.AspNetCore.Http.Features.dll" -a "C:\Repo\Project\Blazor\Blazor.Client
\obj\Debug\netstandard2.0\Blazor.Client.dll"" exited with code 1. Blazor.Client C:\Admins\Admin\.nuget\packages\microsoft.aspnetcore.blazor.build\0.7.0\targets\Blazor.MonoRuntime.targets 439
然后:
Exception thrown: 'System.ArgumentException' in System.IO.FileSystem.Watcher.dll
An exception of type 'System.ArgumentException' occurred in System.IO.FileSystem.Watcher.dll but was not handled in user code
System.ArgumentException: 'The directory name 'C:\Repo\Project\Blazor\Blazor.Client\bin\Debug\netstandard2.0\dist\' does not exist.'
仅尝试编译客户端时
1>------ Rebuild All started: Project: Blazor.Shared, Configuration: Debug Any CPU ------
1>C:\Program Files\dotnet\sdk\2.1.600-preview-009426\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.RuntimeIdentifierInference.targets(143,5): message NETSDK1057: You are working with a preview version of the .NET Core SDK. You can define the SDK version via a global.json file in the current project. More at https://go.microsoft.com/fwlink/?linkid=869452
1>Blazor.Shared -> C:\Repo\Project\Blazor\Blazor.Shared\bin\Debug\netstandard2.0\Blazor.Shared.dll
2>------ Rebuild All started: Project: Blazor.Client, Configuration: Debug Any CPU ------
2>Blazor.Client -> C:\Repo\Project\Blazor\Blazor.Client\bin\Debug\netstandard2.0\Blazor.Client.dll
2>Fatal error in IL Linker
2>Mono.Linker.LoadException: Error while processing references of 'Blazor.Client, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' ---> Mono.Linker.LoadException: Error while processing references of 'Blazor.Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' ---> Mono.Cecil.AssemblyResolutionException: Failed to resolve assembly: 'Microsoft.Extensions.Primitives, Version=2.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' ---> Mono.Cecil.AssemblyResolutionException: Failed to resolve assembly: 'Microsoft.Extensions.Primitives, Version=2.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'
2> at Mono.Linker.DirectoryAssemblyResolver.Resolve(AssemblyNameReference name, ReaderParameters parameters)
2> at Mono.Linker.AssemblyResolver.Resolve(AssemblyNameReference name, ReaderParameters parameters)
2> at Mono.Linker.LinkContext.Resolve(IMetadataScope scope)
2> --- End of inner exception stack trace ---
2> at Mono.Linker.LinkContext.Resolve(IMetadataScope scope)
2> at Mono.Linker.LinkContext.ResolveReferences(AssemblyDefinition assembly)
2> at Mono.Linker.Steps.LoadReferencesStep.ProcessReferences(AssemblyDefinition assembly)
2> at Mono.Linker.Steps.LoadReferencesStep.ProcessReferences(AssemblyDefinition assembly)
2> --- End of inner exception stack trace ---
2> at Mono.Linker.Steps.LoadReferencesStep.ProcessReferences(AssemblyDefinition assembly)
2> at Mono.Linker.Steps.LoadReferencesStep.ProcessReferences(AssemblyDefinition assembly)
2> --- End of inner exception stack trace ---
2> at Mono.Linker.Steps.LoadReferencesStep.ProcessReferences(AssemblyDefinition assembly)
2> at Mono.Linker.Steps.LoadReferencesStep.ProcessAssembly(AssemblyDefinition assembly)
2> at Mono.Linker.Steps.BaseStep.Process(LinkContext context)
2> at Mono.Linker.Pipeline.ProcessStep(LinkContext context, IStep step)
2> at Mono.Linker.Pipeline.Process(LinkContext context)
2> at Mono.Linker.Driver.Run(ILogger customLogger)
2> at Mono.Linker.Driver.Execute(String[] args, ILogger customLogger)
2>C:\Users\Admin\.nuget\packages\microsoft.aspnetcore.blazor.build\0.7.0\targets\Blazor.MonoRuntime.targets(439,5): error MSB3073: The command "dotnet "C:\Users\User\.nuget\packages\microsoft.aspnetcore.blazor.build\0.7.0\targets\../tools/illink/illink.dll" -l none --verbose --strip-security true --exclude-feature com --exclude-feature sre -v false -c link -u link -b true -d "C:\Users\User\.nuget\packages\microsoft.aspnetcore.blazor.build\0.7.0\targets\../tools/mono/bcl/" -d "C:\Users\User\.nuget\packages\microsoft.aspnetcore.blazor.build\0.7.0\targets\../tools/mono/bcl/Facades/" -o "C:\Repo\Project\Blazor\Blazor.Client\obj\Debug\netstandard2.0\blazor\linker/" -x "C:\Users\User\.nuget\packages\microsoft.aspnetcore.blazor.build\0.7.0\targets\BuiltInBclLinkerDescriptor.xml" -x "C:\Repo\Project\Blazor\Blazor.Client\obj\Debug\netstandard2.0\blazor\linker.descriptor.xml" -a "C:\Users\User\.nuget\packages\microsoft.aspnetcore.blazor\0.7.0\lib\netstandard2.0\Microsoft.AspNetCore.Blazor.dll" -a "C:\Users\User\.nuget\packages\microsoft.aspnetcore.blazor.browser\0.7.0\lib\netstandard2.0\Microsoft.AspNetCore.Blazor.Browser.dll" -a "C:\Users\User\.nuget\packages\microsoft.aspnetcore.blazor.build\0.7.0\lib\netstandard1.0\Microsoft.AspNetCore.Blazor.TagHelperWorkaround.dll" -a "C:\Users\User\.nuget\packages\microsoft.extensions.dependencyinjection\2.1.0\lib\netstandard2.0\Microsoft.Extensions.DependencyInjection.dll" -a "C:\Users\User\.nuget\packages\microsoft.extensions.dependencyinjection.abstractions\2.1.0\lib\netstandard2.0\Microsoft.Extensions.DependencyInjection.Abstractions.dll" -a "C:\Users\User\.nuget\packages\microsoft.jsinterop\0.7.0\lib\netstandard2.0\Microsoft.JSInterop.dll" -a "C:\Users\User\.nuget\packages\mono.webassembly.interop\0.7.0\lib\netstandard2.0\Mono.WebAssembly.Interop.dll" -a "C:\Program Files\dotnet\sdk\NuGetFallbackFolder\system.componentmodel.annotations\4.5.0\lib\netstandard2.0\System.ComponentModel.Annotations.dll" -a "C:\Repo\Project\Blazor\Blazor.Shared\bin\Debug\netstandard2.0\Blazor.Shared.dll" -a "C:\Repo\Project\Blazor\Blazor.Shared\bin\Debug\netstandard2.0\Microsoft.AspNetCore.Http.Features.dll" -a "C:\Repo\Project\Blazor\Blazor.Client\obj\Debug\netstandard2.0\Blazor.Client.dll"" exited with code 1.
2>Done building project "Blazor.Client.csproj" -- FAILED.
========== Rebuild All: 1 succeeded, 1 failed, 0 skipped ==========
双击此错误后,它将打开:
Blazor.MonoRuntime.targets
在
C:\ Users \ Admin.nuget \ packages \ microsoft.aspnetcore.blazor.build \ 0.7.0 \ targets
并在此行上指向:
<!--` Run the linker and put the results in /obj/<<configuration>>/<<targetframework>>/blazor/blazor/linker -->
<Exec Command="dotnet "$(MonoLinkerPath)" $(_BlazorLinkerAdditionalOptions) @(_BlazorFolderLookupPaths, ' ') -o "$(BlazorIntermediateLinkerOutputPath)" @(_BlazorAssemblyDescriptorFiles, ' ') @(_BlazorAssembliesToLink, ' ')" />
重现行为的步骤:
可能是:
1安装.NET 2.1.600-preview-009426
2安装Visual Studio 2019
3创建dotnet new blazorhosted
4尝试运行该应用程序。
应用正常启动
我在装有Win7的2台不同PC上重现了该错误。
在这两种情况下,scenario基本上都是相同的。
答案 0 :(得分:0)
如果要调试ILLink,建议执行以下步骤
然后,您将知道类型解析失败的方式。 另外,如果遇到此类错误,很可能是使用反射或其他方式破坏ILLink的动态类型解析。您应该开始manually opt-out specific types from elimination by ILLink。