0

I just created a new .NET Core 2.2 project with Visual Studio 2019 Community (Version 16.1.6).

Although as a surprise I could not compile the basic project it created.

I see all kinds of errors as it can be seen on this image:

enter image description here

Running the dotnet --list-sdks command in cmd results in:

1.1.14 [C:\Program Files\dotnet\sdk]
2.1.602 [C:\Program Files\dotnet\sdk]
2.1.604 [C:\Program Files\dotnet\sdk]
2.1.700 [C:\Program Files\dotnet\sdk]
2.1.701 [C:\Program Files\dotnet\sdk]
2.2.203 [C:\Program Files\dotnet\sdk]

so I have these SDKs installed.

Maybe my SDK installations somehow became corrupted?

When I tried NuGet restore for the solution, this is the output:

All packages are already installed and there is nothing to restore.
Time Elapsed: 00:00:00.2025637
========== Finished ==========

Error occurred while restoring NuGet packages: The local source 'D:\Microsoft\Xamarin\NuGet\' doesn't exist.

I can't recall correctly, but maybe I deleted the latter folder, because it seemed irrelevant (I chose a different location for VS install, so why would the installer copy something there? Non-sense.). If that is the problem, how do I fix it?

Also, why does it even need Xamarin? This is not a xamarin project!

Thanks in advance!

Stephen Kennedy
  • 20,585
  • 22
  • 95
  • 108
Károly Ozsvárt
  • 1,025
  • 1
  • 12
  • 24
  • I decided to give the environment a full reinstall since I already had a lot of unused components installed. I will update this thread whether that helped (I hope it will, it should). – Károly Ozsvárt Jul 19 '19 at 19:29

2 Answers2

0

NuGet is trying to read from a local source that doesn't exist. Go to Tools\Options and from NuGet Package Manager, remove the local source or change it. Then you should be able to use NuGet again to restore the missing SDKs.

If still not working, and you think you deleted some folders, then I suggest to uninstall VS and install it again correctly. Templates from VS should works fine.

References :

An error occurred while trying to restore packages. Please try again

Unable to find nuget local source error occurred while restoring nuget packages the local source doesn't exist

J.K
  • 1,178
  • 10
  • 13
0

For Visual Studio 2019 16.1, you need .NET Core 2.2 SDK 2.2.30x, which can be downloaded from https://dotnet.microsoft.com/download/dotnet-core/2.2

Lex Li
  • 60,503
  • 9
  • 116
  • 147
  • Wouldn't that come with VS2019 (as in a mandatory install component for Console apps)? – Jeremy Thompson Jul 20 '19 at 05:01
  • @JeremyThompson but clearly that's missing on this machine for whatever reason. Your "mandatory" assertion is invalid on a user machine, as there is no mechanism to prevent manual uninstallation. – Lex Li Jul 21 '19 at 02:29