12

I'm having an issue trying to build a dotnet core project from command line that has these references:

    <PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="2.6.1" />
<PackageReference Include="Microsoft.Net.Compilers" Version="2.6.1" />

For whatever reason it keeps saying Microsoft.Build.Tasks.CodeAnalysis.dll assembly has already been loaded. Here is the exact error message:

C:\Users.nuget\packages\microsoft.net.compilers\2.6.1\tools\Microsoft.CSharp.Core.targets(84,5): error MSB4062: The "Microsoft.CodeAnalysis.BuildTasks.Csc" task could not be loaded from the assembly

C:\Users.nuget\packages\microsoft.net.compilers\2.6.1\build..\tools\Microsoft.Build.Tasks.CodeAnalysis.dll. Assembly with same name is already loaded Confirm that the declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask.

When I go to that project directory and run dotnet build It has no issues building the project, but when I run dotnet build against the solution that's when I get this error. If I build the solution from Visual Studio it also has no issues building. Really strange behavior, not quite sure how to get around it.

The Pax Bisonica
  • 2,154
  • 2
  • 26
  • 45
  • Maybe https://stackoverflow.com/questions/59696012/microsoft-codeanalysis-buildtasks-csc-task-could-not-be-loaded-from-the-assembl answers your question. – brijber Sep 01 '22 at 10:41

0 Answers0