1

If I create a new project (or open old working project) with the target framework .NET Core 3.1 or .NET 5.0 or any newer versions using VS2019 or VS2022, and I try running or building the project, I get the following errors:

Screenshot of the error (1)

Screenshot of the error (2)

I tried to install everything, but The SDKs aren't found in the "C:\Program Files (x86)\dotnet\sdk" folder.

Screenshot of what I installed (as an example VS20122)

The result of dotnet --info

Screenshot of the list of the "target framework" in the project properties

Screenshot of what I installed (as an example VS20122)2

Screenshot of what I installed (as an example VS20122)3

PS : With .NET Framework I don't have that problem.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • Run `dotnet --info`, does 5.0 show up in the SDK section? What is the `TargetFramework` value in your csproj file? – gunr2171 May 15 '23 at 11:48
  • 2
    I see the runtimes in your installation, but not the SDKs. See: [Download .NET SDKs for Visual Studio](https://dotnet.microsoft.com/en-us/download/visual-studio-sdks). Or use the VS installer. See also: [What's the difference between SDK and Runtime in .NET Core?](https://stackoverflow.com/a/49702098/880990). – Olivier Jacot-Descombes May 15 '23 at 12:07
  • @gunr2171 I edited the body of my question and included some other screenshots to respond your question. in the csproj file : net6.0 enable enable – Amir Elamine May 15 '23 at 14:09
  • 1
    1) Please post text as _text_, not images. 2) You don't have 5.0 in the SDK section, so it makes sense you can't compile .Net 5 code. 3) Your project says it targets .Net 6, not 5. In all cases, please use Olivier's link above to install the right version of the .Net SDK that you need. – gunr2171 May 15 '23 at 14:38
  • @gunr2171 1) I wanted to show you everything to get things clear. 2) & 3) I've installed All the .Net core listed in the VS Installer but the VS doesn't show them in the target framework and was weird. + 4) I Solved the issue by just installing the X86 of the .Net core (by default the VS Installer installed the X64 version of the runtimes and SDKs.) and that was weirder. – Amir Elamine May 15 '23 at 15:42

0 Answers0