VS Code - The reference assemblies for ".NETFramework,Version=v5.0" were not found
Answer a question
I have a problem with VS Code .net 5 settings.
Error MSB3971: The reference assemblies for ".NETFramework,Version=v5.0" were not found. You might be using an older .NET SDK to target .NET 5.0 or higher. Update Visual Studio and/or your .NET SDK.
Some time ago I was using .net core 3 recently I wanted to move to the newest version.
- I have installed the latest version of the SDK -> https://dotnet.microsoft.com/download/dotnet/5.0
- I updated VS Code to the latest version
- I started a brand new project in .net 5
I was looking for a solution to my problem on the internet, but nothing works.
Powershell dotnet version:
dotnet --version
5.0.401
dotnet --info
Zestaw .NET SDK (odzwierciedlenie dowolnego pliku global.json):
Version: 5.0.401
Commit: 4bef5f3dbf
Środowisko uruchomieniowe:
OS Name: Windows
OS Version: 10.0.19043
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\5.0.401\
Host (useful for support):
Version: 5.0.10
Commit: e1825b4928
.NET SDKs installed:
2.1.700 [C:\Program Files\dotnet\sdk]
2.1.801 [C:\Program Files\dotnet\sdk]
2.2.202 [C:\Program Files\dotnet\sdk]
5.0.401 [C:\Program Files\dotnet\sdk]
.NET runtimes installed:
Microsoft.AspNetCore.All 2.1.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.2.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.2.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.10 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.1.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.2.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.10 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 5.0.10 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
To install additional .NET runtimes or SDKs:
https://aka.ms/dotnet-download
Visual Studio Code Version:
version: 1.60.2
Info about Visual Studio Code
The contents of the project.csproj file
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.3" />
</ItemGroup>
</Project>
I have the latest SDK and VS Code, I don't know what else I can do to make it work.
I uninstall all versions of .net and install only 5.0. Now i have new error
error MSB4236: The SDK 'Microsoft.NET.Sdk.Web' specified could not be found.
After I reinstall .NET I got this from terminal:
dotnet --info
Zestaw .NET SDK (odzwierciedlenie dowolnego pliku global.json):
Version: 5.0.401
Commit: 4bef5f3dbf
Środowisko uruchomieniowe:
OS Name: Windows
OS Version: 10.0.19043
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\5.0.401\
Host (useful for support):
Version: 5.0.10
Commit: e1825b4928
.NET SDKs installed:
5.0.401 [C:\Program Files\dotnet\sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 5.0.10 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 5.0.10 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 5.0.10 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
To install additional .NET runtimes or SDKs:
https://aka.ms/dotnet-download
Answers
I struggled with this problem for a long time. Here is a list of things that need to be checked.
-
Remove all SDKs from your computer. - Find in the control panel "Programs and Features" then delete all
Microsoft .NET Runtime - x.x.xx
,Microsoft .NET SDK x.x.x
-
Install newest .NET SDK and Runtime - i use this site
-
Check your PATH - Check if the path with the environment variables in windows contains
C:\Program Files\dotnet
-
!! Check MSBuildSDKsPath Environment Variable - It turned out that installing the new SDK does not change the information in the environment paths. I still had the old version listed there and after uninstalling everything, I got a message saying that
'Microsoft.NET.Sdk.Web' could not be found.
Check the value of the MSBuildSDKsPath variable. The proper value for me was x
C:\Program Files\dotnet\sdk\5.0.401\Sdks
更多推荐
所有评论(0)