升级到 .net core 3.1 preview4 后代码分析器生成错误
Build error with code analyzer after upgrading to .net core 3.1 preview4
我有一个 Blazor webassembly 项目(托管),我刚刚尝试将其升级到 .net core 3.1 的发行版。为此,我已将 VS 2019 预览版升级到 16.5 预览版 1。我已将项目中的所有包升级到 3.1.0-preview4.19579.2。我还将客户端和共享项目更新为 .net 标准 2.1 并安装了最新的模板(我认为)。
当我尝试构建我的解决方案时,我现在收到此错误,似乎在某处显示了重复的代码分析资源文件:
Severity Code Description Project File Line Suppression State
Error MSB4018 The "ResolveBlazorRuntimeDependencies" task failed unexpectedly.
System.InvalidOperationException: Multiple assemblies found with the same assembly name 'Microsoft.CodeAnalysis.resources':
Microsoft.CodeAnalysis.resources
C:\Users\NickWhymark\.nuget\packages\microsoft.codeanalysis.common.3.1\lib\netstandard2.0\de\Microsoft.CodeAnalysis.resources.dll
at Microsoft.AspNetCore.Blazor.Build.ResolveBlazorRuntimeDependencies.<ResolveRuntimeDependenciesCore>g__CreateAssemblyLookup|17_1(IEnumerable`1 assemblyPaths)
at Microsoft.AspNetCore.Blazor.Build.ResolveBlazorRuntimeDependencies.ResolveRuntimeDependenciesCore(String entryPoint, IEnumerable`1 applicationDependencies, IEnumerable`1 monoBclAssemblies)
at Microsoft.AspNetCore.Blazor.Build.ResolveBlazorRuntimeDependencies.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext() Test.Blazor.Client C:\Users\myuser\.nuget\packages\microsoft.aspnetcore.blazor.build.1.0-preview4.19579.2\targets\Blazor.MonoRuntime.targets 252
错误似乎出现在 Web 程序集(客户端)项目中。我在其中看不到任何重复的分析器。但是在服务器项目中,我注意到 Microsoft.AspNetCore.Components.Analyzers.dll 的副本。一个来自Program Files中的.Net Core 3.1 SDK文件夹,另一个来自.nuget/packages。请注意,我没有明确添加 nuget,它只是 "appeared".
虽然奇怪,但我认为服务器项目中的重复分析器不一定是原因,因为我创建了一个新的 Blazor webassembly 项目,它也有重复项但编译正确。
我试过clean/rebuild,重启VS,删除bin/obj个文件夹,但问题依旧。
其他可能相关的要点:
- 我正在使用 Telerik Blazor 控件
- 我安装了 VS2019 的发行版和预览版。我也升级到
16.4.
非常感谢任何帮助!
我在 my project 的更新中遇到了同样的问题。
Severity Code Description Project File Line Suppression State
Error MSB4018 The "ResolveBlazorRuntimeDependencies" task failed unexpectedly.
System.InvalidOperationException: Multiple assemblies found with the same assembly name 'Microsoft.CodeAnalysis.resources':
Microsoft.CodeAnalysis.resources
C:\Users\SARI\.nuget\packages\microsoft.codeanalysis.common.4.0\lib\netstandard2.0\de\Microsoft.CodeAnalysis.resources.dll
at Microsoft.AspNetCore.Blazor.Build.ResolveBlazorRuntimeDependencies.<ResolveRuntimeDependenciesCore>g__CreateAssemblyLookup|17_1(IEnumerable`1 assemblyPaths)
at Microsoft.AspNetCore.Blazor.Build.ResolveBlazorRuntimeDependencies.ResolveRuntimeDependenciesCore(String entryPoint, IEnumerable`1 applicationDependencies, IEnumerable`1 monoBclAssemblies)
at Microsoft.AspNetCore.Blazor.Build.ResolveBlazorRuntimeDependencies.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext() BlazorDemo C:\Users\SARI\.nuget\packages\microsoft.aspnetcore.blazor.build.1.0-preview4.19579.2\targets\Blazor.MonoRuntime.targets 252
从项目文件 (.csproj) 中删除 <BlazorLinkOnBuild>false</BlazorLinkOnBuild>
解决了问题。
编辑:找到另一个 solution。将此添加到项目文件
<Target Name="_RemoveSatelliteAssemblies" BeforeTargets="_ResolveBlazorRuntimeDependencies">
<ItemGroup>
<_BlazorDependencyInput Remove="@(_BlazorDependencyInput->WithMetadataValue('AssetType', 'resources'))" />
</ItemGroup>
</Target>
netcore3.1
、netstandard2.1
和 blazor-wasm-3.1
库似乎存在已知问题。对我来说,https://github.com/aspnet/AspNetCore/issues/17754#issuecomment-564431825 的解决方法有效:
解决方法是编辑文件“.nuget\packages\microsoft.aspnetcore.blazor.build.1.0-preview4.19579.2\targets\Blazor.MonoRuntime.targets”您的主目录并更改:
<BlazorILLink
ILLinkPath="$(MonoLinkerPath)"
AssemblyPaths="@(_BlazorAssemblyToLink)"
RootAssemblyNames="@(_BlazorLinkerRoot)"
RootDescriptorFiles="@(BlazorLinkerDescriptor)"
OutputDirectory="$(BlazorIntermediateLinkerOutputPath)"
ExtraArgs="$(_BlazorLinkerAdditionalOptions)"
ToolExe="$(_DotNetHostFileName)"
ToolPath="$(_DotNetHostDirectory)" />
到
<BlazorILLink
ILLinkPath=""$(MonoLinkerPath)""
AssemblyPaths="@(_BlazorAssemblyToLink)"
RootAssemblyNames="@(_BlazorLinkerRoot)"
RootDescriptorFiles="@(BlazorLinkerDescriptor)"
OutputDirectory="$(BlazorIntermediateLinkerOutputPath)"
ExtraArgs="$(_BlazorLinkerAdditionalOptions)"
ToolExe="$(_DotNetHostFileName)"
ToolPath="$(_DotNetHostDirectory)" />
问题是,如果用户名包含空格(如果您有一个 Windows 帐户并给出名字和姓氏,这是默认设置 --> 例如 Hans Meier), 链接器路径配置不正确,引号丢失。
我有一个 Blazor webassembly 项目(托管),我刚刚尝试将其升级到 .net core 3.1 的发行版。为此,我已将 VS 2019 预览版升级到 16.5 预览版 1。我已将项目中的所有包升级到 3.1.0-preview4.19579.2。我还将客户端和共享项目更新为 .net 标准 2.1 并安装了最新的模板(我认为)。
当我尝试构建我的解决方案时,我现在收到此错误,似乎在某处显示了重复的代码分析资源文件:
Severity Code Description Project File Line Suppression State
Error MSB4018 The "ResolveBlazorRuntimeDependencies" task failed unexpectedly.
System.InvalidOperationException: Multiple assemblies found with the same assembly name 'Microsoft.CodeAnalysis.resources':
Microsoft.CodeAnalysis.resources
C:\Users\NickWhymark\.nuget\packages\microsoft.codeanalysis.common.3.1\lib\netstandard2.0\de\Microsoft.CodeAnalysis.resources.dll
at Microsoft.AspNetCore.Blazor.Build.ResolveBlazorRuntimeDependencies.<ResolveRuntimeDependenciesCore>g__CreateAssemblyLookup|17_1(IEnumerable`1 assemblyPaths)
at Microsoft.AspNetCore.Blazor.Build.ResolveBlazorRuntimeDependencies.ResolveRuntimeDependenciesCore(String entryPoint, IEnumerable`1 applicationDependencies, IEnumerable`1 monoBclAssemblies)
at Microsoft.AspNetCore.Blazor.Build.ResolveBlazorRuntimeDependencies.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext() Test.Blazor.Client C:\Users\myuser\.nuget\packages\microsoft.aspnetcore.blazor.build.1.0-preview4.19579.2\targets\Blazor.MonoRuntime.targets 252
错误似乎出现在 Web 程序集(客户端)项目中。我在其中看不到任何重复的分析器。但是在服务器项目中,我注意到 Microsoft.AspNetCore.Components.Analyzers.dll 的副本。一个来自Program Files中的.Net Core 3.1 SDK文件夹,另一个来自.nuget/packages。请注意,我没有明确添加 nuget,它只是 "appeared".
虽然奇怪,但我认为服务器项目中的重复分析器不一定是原因,因为我创建了一个新的 Blazor webassembly 项目,它也有重复项但编译正确。
我试过clean/rebuild,重启VS,删除bin/obj个文件夹,但问题依旧。
其他可能相关的要点:
- 我正在使用 Telerik Blazor 控件
- 我安装了 VS2019 的发行版和预览版。我也升级到 16.4.
非常感谢任何帮助!
我在 my project 的更新中遇到了同样的问题。
Severity Code Description Project File Line Suppression State
Error MSB4018 The "ResolveBlazorRuntimeDependencies" task failed unexpectedly.
System.InvalidOperationException: Multiple assemblies found with the same assembly name 'Microsoft.CodeAnalysis.resources':
Microsoft.CodeAnalysis.resources
C:\Users\SARI\.nuget\packages\microsoft.codeanalysis.common.4.0\lib\netstandard2.0\de\Microsoft.CodeAnalysis.resources.dll
at Microsoft.AspNetCore.Blazor.Build.ResolveBlazorRuntimeDependencies.<ResolveRuntimeDependenciesCore>g__CreateAssemblyLookup|17_1(IEnumerable`1 assemblyPaths)
at Microsoft.AspNetCore.Blazor.Build.ResolveBlazorRuntimeDependencies.ResolveRuntimeDependenciesCore(String entryPoint, IEnumerable`1 applicationDependencies, IEnumerable`1 monoBclAssemblies)
at Microsoft.AspNetCore.Blazor.Build.ResolveBlazorRuntimeDependencies.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext() BlazorDemo C:\Users\SARI\.nuget\packages\microsoft.aspnetcore.blazor.build.1.0-preview4.19579.2\targets\Blazor.MonoRuntime.targets 252
从项目文件 (.csproj) 中删除 <BlazorLinkOnBuild>false</BlazorLinkOnBuild>
解决了问题。
编辑:找到另一个 solution。将此添加到项目文件
<Target Name="_RemoveSatelliteAssemblies" BeforeTargets="_ResolveBlazorRuntimeDependencies">
<ItemGroup>
<_BlazorDependencyInput Remove="@(_BlazorDependencyInput->WithMetadataValue('AssetType', 'resources'))" />
</ItemGroup>
</Target>
netcore3.1
、netstandard2.1
和 blazor-wasm-3.1
库似乎存在已知问题。对我来说,https://github.com/aspnet/AspNetCore/issues/17754#issuecomment-564431825 的解决方法有效:
解决方法是编辑文件“.nuget\packages\microsoft.aspnetcore.blazor.build.1.0-preview4.19579.2\targets\Blazor.MonoRuntime.targets”您的主目录并更改:
<BlazorILLink
ILLinkPath="$(MonoLinkerPath)"
AssemblyPaths="@(_BlazorAssemblyToLink)"
RootAssemblyNames="@(_BlazorLinkerRoot)"
RootDescriptorFiles="@(BlazorLinkerDescriptor)"
OutputDirectory="$(BlazorIntermediateLinkerOutputPath)"
ExtraArgs="$(_BlazorLinkerAdditionalOptions)"
ToolExe="$(_DotNetHostFileName)"
ToolPath="$(_DotNetHostDirectory)" />
到
<BlazorILLink
ILLinkPath=""$(MonoLinkerPath)""
AssemblyPaths="@(_BlazorAssemblyToLink)"
RootAssemblyNames="@(_BlazorLinkerRoot)"
RootDescriptorFiles="@(BlazorLinkerDescriptor)"
OutputDirectory="$(BlazorIntermediateLinkerOutputPath)"
ExtraArgs="$(_BlazorLinkerAdditionalOptions)"
ToolExe="$(_DotNetHostFileName)"
ToolPath="$(_DotNetHostDirectory)" />
问题是,如果用户名包含空格(如果您有一个 Windows 帐户并给出名字和姓氏,这是默认设置 --> 例如 Hans Meier), 链接器路径配置不正确,引号丢失。