Lele Edgo
Lele Edgo

Reputation: 53

The "GenerateDepsFile" task failed unexpectedly: Missing Microsoft.DotNet.PlatformAbstractions

Updated my .NET Core SDK to the latest version (3.1.405) and now nothing works anymore. Whenever I try dotnet run on any project I get the following error:

C:\Program Files\dotnet\sdk\3.1.405\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(194,5): error MSB4018: The "GenerateDepsFile" task failed unexpectedly. [C:\Users\<UserName>\Desktop\Test\Test.csproj]
C:\Program Files\dotnet\sdk\3.1.405\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(194,5): error MSB4018: System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.DotNet.PlatformAbstractions, Version=2.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified. [C:\Users\<UserName>\Desktop\Test\Test.csproj]
C:\Program Files\dotnet\sdk\3.1.405\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(194,5): error MSB4018: File name: 'Microsoft.DotNet.PlatformAbstractions, Version=2.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' [C:\Users\<UserName>\Desktop\Test\Test.csproj]
C:\Program Files\dotnet\sdk\3.1.405\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(194,5): error MSB4018:    at Microsoft.NET.Build.Tasks.FrameworkReferenceResolver.GetDefaultReferenceAssembliesPath() [C:\Users\<UserName>\Desktop\Test\Test.csproj]
C:\Program Files\dotnet\sdk\3.1.405\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(194,5): error MSB4018:    at Microsoft.NET.Build.Tasks.GenerateDepsFile.WriteDepsFile(String depsFilePath) [C:\Users\<UserName>\Desktop\Test\Test.csproj]
C:\Program Files\dotnet\sdk\3.1.405\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(194,5): error MSB4018:    at Microsoft.NET.Build.Tasks.GenerateDepsFile.ExecuteCore() [C:\Users\<UserName>\Desktop\Test\Test.csproj]
C:\Program Files\dotnet\sdk\3.1.405\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(194,5): error MSB4018:    at Microsoft.NET.Build.Tasks.TaskBase.Execute() [C:\Users\<UserName>\Desktop\Test\Test.csproj]
C:\Program Files\dotnet\sdk\3.1.405\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(194,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() [C:\Users\<UserName>\Desktop\Test\Test.csproj]
C:\Program Files\dotnet\sdk\3.1.405\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(194,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask) [C:\Users\<UserName>\Desktop\Test\Test.csproj]

The build failed. Fix the build errors and run again.

Test.csproj:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp3.1</TargetFramework>
  </PropertyGroup>

</Project>

The error occurs on every single .NET Core project, even when creating a blank new one.

I've spent way too many hours looking for a solution and tried multiple solutions from similar threads, eg:

My dotnet --info output:

.NET SDK (reflecting any global.json):
 Version:   5.0.102
 Commit:    71365b4d42

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.19041
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\5.0.102\

Host (useful for support):
  Version: 5.0.2
  Commit:  cb5f173b96

.NET SDKs installed:
  3.1.405 [C:\Program Files\dotnet\sdk]
  5.0.102 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.All 2.1.24 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.24 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.24 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.1.3 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 3.1.11 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.2 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

I feel like it might have to do with .NET 5 seemingly being the default. I've also read that Microsoft.DotNet.PlatformAbstractions will no longer be supported with that version of the .NET SDK, but don't know what to do with that information and couldn't find anything helpful.

Upvotes: 5

Views: 5169

Answers (4)

JW.
JW.

Reputation: 51678

I saw the same error when I had both the 3.1.416 and 5.0.405 SDKs installed, on a project that targets 3.1. For some reason it built on the command line, but when I tried to debug using Visual Studio Code, I got the error.

I was able to fix it by creating a global.json in the project (or one of its parent directories), with:

{
  "sdk": {
    "version": "3.1.416",
    "rollForward": "disable"
  }
}

Upvotes: 0

Sina Bahmanpour
Sina Bahmanpour

Reputation: 67

I had the same problem. The only thing that worked for me was to install the latest version of Microsoft.DotNet.PlatformAbstractions package from by NuGet!

In your default project, just right click on Dependencies, choose Manage NuGet Packages and in Browse tab, search Microsoft.DotNet.PlatformAbstractions and install the latest version.

Upvotes: 0

JWP
JWP

Reputation: 6963

For me it was an issue where I had 7 projects in a solution. The ones that failed had their own assembly name, and the error indicated "Duplicate names".

Once change per example below the problem stopped.

Assembly Name (before) : SpecFlow
Assembly Name (after)  : Core.SpecFlow
//Where the core Assembly had already been built, which cause the "Duplicates" issue.

Upvotes: 0

Wouter
Wouter

Reputation: 185

I had the same problem. The only thing that worked for me was to delete the sdk folders of 5.* (or move them to another location in case you need them again later).

I've tried to uninstall them with the uninstall tool github.com/dotnet/cli-lab/releases but that version didn't show up.

Upvotes: 4

Related Questions