-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dotnet build raise error MSB4062: The "Microsoft.CodeAnalysis.BuildTasks.Csc" task could not be loaded from the assembly #1173 #40602
Comments
Hello, anyone can help me? I encountered the same issues. Build step: F:\gitP\dotnet\runtime.dotnet\sdk\5.0.100-alpha1-015772\Roslyn\Microsoft.CSharp.Core.targets(59,5): error MSB4062: The "Microsoft.CodeAnalysis.BuildTasks.Csc" task could not be loaded from the assembly F:\gitP\dotnet\runtime.dotnet\sdk\5.0.100-alpha1-015772\Roslyn\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. |
This is not the intended use of this package. That package is meant to be used to deliver bits between .NET repositories and to hot fix issues on customer machines. It's not meant to be used to allow for using C# 8 features, such as nullable, in previous versions of Visual Studio. True it can often be used to create this effect but it's not a behavior that we designed the package for. There are a number of corner cases around this scenario that do not work.
This occurs because the MSBuild process is attempting to load the csc task from two different locations:
The This is another reason why this package isn't supported for general purpose usage and geared towards hot fixes. |
The documentation didn't mention any limitation for the package.
As you said,
But the build success with MSBuild. in my post:
so, why success here and fail with dotnet build. Some projects use this package with vs2017 image in appveyor to build in c#8 with Nullable reference types (without moving to vs 2019). Please
|
The WIKI is out of date. I've updated it to have the relevant information. The official documentation on the NuGet Gallery has the relevant lines:
As for
That's due to differences in how .NET Desktop and .NET Core work with respect to assembly loading. In .NET Desktop it's possible for two assemblies with the same name but different versions and strong name signed to load into the same Our |
Thanks @jaredpar |
This question was asked in dotnet project then advised to move it here.
Environment
vs2019 v16.4.0 is installed
last netcore 3.1.100 is installed.
Console project.csproj SDK style , net461
reference a class library project netstandard2.0, net461
The class library reference the package: Microsoft.Net.Compilers.Toolset v 3.4.0 to support c# 8 nullable in VS2017 .
Building the project using vs2019 IDE success.
Building the project using msbuild command success.:
msbuild /t:build
Building the project using dotnet build fail with the error
Removing the package
"Microsoft.Net.Compilers.Toolset
and run dotnet build success.How to stop this error in dotnet build?
The text was updated successfully, but these errors were encountered: