Chris
Chris

Reputation: 28064

The "Microsoft.CodeAnalysis.BuildTasks.Csc" task could not be loaded

I'm trying to publish a newly created asp.net 4.6 web project to Azure web apps and receiving the following error:

remote: D:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.CSharp.targets(316,9): error MSB4062: The "Microsoft.CodeAnalysis.BuildTasks.Csc" task could not be loaded from the assembly D:\home\site\repository\packages\Microsoft.Net.Compilers.1.0.0\build..\tools\Microsoft.Build.Tasks.CodeAnalysis.dll. Could not load file or assembly 'Microsoft.Build.Utilities.Core, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. 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. [D:\home\site\repository\WebApp\WebApp.csproj]

Everything builds fine via Visual Studio 2015 on my local machine. I thought Azure web apps were all set to support VS 2015 RTM upon release, but it would appear they do not have MSBuild 14.0 installed. Is there a work around or a roadmap for this problem?

Upvotes: 5

Views: 10739

Answers (3)

Burak Altin
Burak Altin

Reputation: 468

In my case I have to edit my .csproj file and find below lines and delete them

<Error Condition="!Exists('..\packages\Microsoft.Net.Compilers.1.0.0\build\Microsoft.Net.Compilers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Net.Compilers.1.0.0\build\Microsoft.Net.Compilers.props'))" />
<Error Condition="!Exists('..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props'))" />

Now everything is fine,

Upvotes: 3

Judy007
Judy007

Reputation: 5870

Here was the fix for me. Using Nuget Package Manager, remove these two packages if referenced:

  1. Microsoft.CodeDom.Providers.DotNetCompilerPlatform
  2. Microsoft.Net.Compilers

After that, run a rebuild. This ensured that the build was not trying to use a specific build exe. Click here for the Diff against previous revision

Upvotes: 15

Zain Rizvi
Zain Rizvi

Reputation: 24636

Azure Web Apps doesn't support ASP.NET 4.6 yet. It's on it's way though, so stay tuned.

Upvotes: 1

Related Questions