I have a Blazor webassembly project (hosted) and I've just tried to upgrade it to the release version of .net core 3.1. To do this I have upgraded VS 2019 preview to 16.5 preview 1. I've upgraded all the packages in my project to 3.1.0-preview4.19579.2. I've also updated the client and shared projects to .net standard 2.1 and installed the latest templates (I think).
When I try and build my solution I'm now getting this error which appears to show a duplicate code analysis resource file somewhere:
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.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\3.1.0-preview4.19579.2\targets\Blazor.MonoRuntime.targets 252
The error appears to be in the web assembly (client) project. I can't see any duplicate Analyzers in that. However in the Server project I've noticed a duplicate of Microsoft.AspNetCore.Components.Analyzers.dll. One is coming from the .Net Core 3.1 SDK folder in Program Files, and the other is coming from .nuget/packages. Note I haven't explicitly added the nuget one, it just "appeared".
Whilst odd, I don't think the duplicate analyzers in the server project is necessarily the cause because I created a new Blazor webassembly project and that also had the duplicates but compiled correctly.
I've tried clean/rebuild, restarting VS, deleting bin/obj folders but the problem persists.
Other points that may be relevant:
Any help much apreciated!
I had the same problem with the update for 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\3.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\3.1.0-preview4.19579.2\targets\Blazor.MonoRuntime.targets 252
Removing <BlazorLinkOnBuild>false</BlazorLinkOnBuild>
from the project file (.csproj) fixed the problem.
Edit: Found another solution. Add this to the project file
<Target Name="_RemoveSatelliteAssemblies" BeforeTargets="_ResolveBlazorRuntimeDependencies">
<ItemGroup>
<_BlazorDependencyInput Remove="@(_BlazorDependencyInput->WithMetadataValue('AssetType', 'resources'))" />
</ItemGroup>
</Target>