question

Xen-8306 avatar image
0 Votes"
Xen-8306 asked Xen-8306 answered

error MSB4062: The "Microsoft.CodeAnalysis.BuildTasks.Csc" task could not be loaded from the assembly

[9:54 AM] Xen Cloete - BCX

Hi Gentle-men and ladies.


We are struggling with an issue the last few days and would like some assistance if possible. We have recently created a build server and loaded TeamCity to do our build.
Our app is a .NET Core 2.1 Web application. We are running the application on Visual Studio 2017. Not sure if you need information regarding the IDE. VisualStudioVersion = 15.0.27703.2035


We have the following error on three projects. I will list only one here.


==========================================================================================================
C:\TeamCity\buildAgent\temp\buildTmp.nuget\packages\microsoft.net.compilers\2.8.2\tools\Microsoft.CSharp.Core.targets(52,5):
error MSB4062: The "Microsoft.CodeAnalysis.BuildTasks.Csc" task could not be loaded from the assembly
C:\TeamCity\buildAgent\temp\buildTmp.nuget\packages\microsoft.net.compilers\2.8.2\build..\tools\Microsoft.Build.Tasks.CodeAnalysis.dll.
Assembly with same name is already loaded Confirm that the <UsingTask> 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.

        "C:\TeamCity\buildAgent\work\5d44c9bda67a0c54\src\Solutions\WareHouse1.CloudRegion1.sln" ( target) (1) ->
        "C:\TeamCity\buildAgent\work\5d44c9bda67a0c54\src\WareHouse1CloudRegion1\DataAccess\Context\EFCore\SqlServer\WareHouse1.CloudRegion1.DataAccess.Context.EFCore.SqlServer.csproj" ( target) (8:18) ->
        "C:\TeamCity\buildAgent\work\5d44c9bda67a0c54\src\WareHouse1CloudRegion1\DataAccess\Context\EFCore\SqlServer\WareHouse1.CloudRegion1.DataAccess.Context.EFCore.SqlServer.csproj" (default target) (8:20) ->
        (ResolveKeySource target) ->
          C:\Program Files\dotnet\sdk\2.1.522\Microsoft.Common.CurrentVersion.targets(3214,5): error : PFX signing not supported on .NET Core
    
    
        "C:\TeamCity\buildAgent\work\5d44c9bda67a0c54\src\Solutions\WareHouse1.CloudRegion1.sln" ( target) (1) ->
        "C:\TeamCity\buildAgent\work\5d44c9bda67a0c54\src\WareHouse1CloudRegion1\DataAccess\Context\EFCore\SqlServer\WareHouse1.CloudRegion1.DataAccess.Context.EFCore.SqlServer.csproj" ( target) (8:18) ->
        "C:\TeamCity\buildAgent\work\5d44c9bda67a0c54\src\WareHouse1CloudRegion1\DataAccess\Context\EFCore\SqlServer\WareHouse1.CloudRegion1.DataAccess.Context.EFCore.SqlServer.csproj" (default target) (8:19) ->
          C:\Program Files\dotnet\sdk\2.1.522\Microsoft.Common.CurrentVersion.targets(3214,5): error : PFX signing not supported on .NET Core
    
    
        "C:\TeamCity\buildAgent\work\5d44c9bda67a0c54\src\Solutions\WareHouse1.CloudRegion1.sln" ( target) (1) ->
        "C:\TeamCity\buildAgent\work\5d44c9bda67a0c54\src\WareHouse1CloudRegion1\UI\IdentityServer\WareHouse1Identity.csproj" ( target) (40:5) ->
          C:\Program Files\dotnet\sdk\2.1.522\Microsoft.Common.CurrentVersion.targets(3214,5): error : PFX signing not supported on .NET Core
    
    
        "C:\TeamCity\buildAgent\work\5d44c9bda67a0c54\src\Solutions\WareHouse1.CloudRegion1.sln" ( target) (1) ->
        "C:\TeamCity\buildAgent\work\5d44c9bda67a0c54\src\WareHouse1CloudRegion1\UI\Host\WareHouse1.CloudRegion1.UI.Web.Host.csproj" ( target) (30:5) ->
        "C:\TeamCity\buildAgent\work\5d44c9bda67a0c54\src\WareHouse1CloudRegion1\UI\Host\Modules\WareHouse1.CloudRegion1.Modules.Core\WareHouse1.CloudRegion1.Modules.Core.csproj" ( target) (47:7) ->
          C:\Program Files\dotnet\sdk\2.1.522\Microsoft.Common.CurrentVersion.targets(3214,5): error : PFX signing not supported on .NET Core


==========================================================================================================


The problem is this section:
error MSB4062: The "Microsoft.CodeAnalysis.BuildTasks.Csc" task could not be loaded from the assembly
C:\TeamCity\buildAgent\temp\buildTmp.nuget\packages\microsoft.net.compilers\2.8.2\build..\tools\Microsoft.Build.Tasks.CodeAnalysis.dll.
Assembly with same name is already loaded Confirm that the <UsingTask> 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 looking for resolution to this problem all I could find was to strongName sign the projects. So I did and the problem now is that .NET Core does not support PFX Signing.


Question asked before.


  1. Does the solution build on Visual Studio 2017? yes and works

  2. Have you StrongName signed the assemblies? yes and does not work on TeamCity Build See error above re: .NET Core



So the question is how do we resolve this problem?


Let me if anyone needs more information.


Thank you


X.















vs-msbuild
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

DylanZhu-MSFT avatar image
0 Votes"
DylanZhu-MSFT answered

Hi Xen,

error MSB4062: The "Microsoft.CodeAnalysis.BuildTasks.Csc" task could not be loaded from the assembly

You can try to rename the package folder in your project directory, then clean and rebuild your project. The reference link: https://stackoverflow.com/a/32155774/11557747

Best Regards,
Dylan


If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Xen-8306 avatar image
0 Votes"
Xen-8306 answered DylanZhu-MSFT commented

Morning Dylan,

Thank you for your reply.

We went ahead and did what you suggested. We renamed the folder and rebuilt the application. The package's folder was recreated on build. We committed the changes to the DevAzure Repo. The Build was run again on TeamCity. Unfortunately the same errors pops up. See below.

"C:\TeamCity\buildAgent\work\5d44c9bda67a0c54\src\Solutions\Warehouse1.CloudRegion1.sln" ( target) (1) ->
"C:\TeamCity\buildAgent\work\5d44c9bda67a0c54\src\Warehouse1CloudRegion1\UI\Host\Warehouse1.CloudRegion1.UI.Web.Host.csproj" ( target) (30:5) ->
"C:\TeamCity\buildAgent\work\5d44c9bda67a0c54\src\Warehouse1CloudRegion1\UI\Host\Modules\Warehouse1.CloudRegion1.Modules.Core\Warehouse1.CloudRegion1.Modules.Core.csproj" ( target) (47:7) ->
C:\TeamCity\buildAgent\temp\buildTmp.nuget\packages\microsoft.net.compilers\2.8.2\tools\Microsoft.CSharp.Core.targets(52,5): error MSB4062: The "Microsoft.CodeAnalysis.BuildTasks.Csc" task could not be loaded from the assembly C:\TeamCity\buildAgent\temp\buildTmp.nuget\packages\microsoft.net.compilers\2.8.2\build..\tools\Microsoft.Build.Tasks.CodeAnalysis.dll. Assembly with same name is already loaded Confirm that the <UsingTask> 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.

Any ideas?

Regards

X.

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @Xen-8306 , thanks for feedback. You could try to uninstall the Microsoft.CodeDom.Providers.DotNetCompilerPlatform and Microsoft.Net.Compilers packages in your project.

0 Votes 0 ·
Xen-8306 avatar image
0 Votes"
Xen-8306 answered

Hi Dylan,

I will give it a try and see what happens.

Thanks

Xen


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.