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:
dotnet clean
C:\Users\<UserName>\.nuget\packages
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With