DarthVader
DarthVader

Reputation: 55092

.net core not found even though it is installed. Should i restart my Mac to use microsoft stack?

I have .net core 2.1 installed as you can see as follows;

➜  Util.Samples.Webs git:(master) ✗ dotnet --version
2.1.200
➜  Util.Samples.Webs git:(master) ✗ 

When I run visual studio to run this project.

I get an error:

Restore failed for 'Microsoft.NETCore.App (>= 2.1.0)'.
Restore failed.

When I look at options of the project. I see .NET core 2.1 (Not installed) but it is installed as you see above.

I tried changing TargetFramework in my .proj file but no luck.

Should I restart my Mac just like restarting Windows? How can I resolve this?

Here is dotnet --info output:

➜  Util git:(master) ✗ dotnet --info
.NET Command Line Tools (2.1.200)

Product Information:
 Version:            2.1.200
 Commit SHA-1 hash:  2edba8d7f1

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  10.13
 OS Platform: Darwin
 RID:         osx.10.13-x64
 Base Path:   /usr/local/share/dotnet/sdk/2.1.200/

Microsoft .NET Core Shared Framework Host

  Version  : 2.0.7
  Build    : 2d61d0b043915bc948ebf98836fefe9ba942be11

➜  Util git:(master) ✗ 

Upvotes: 1

Views: 808

Answers (1)

omajid
omajid

Reputation: 15223

Looks like you were a victim of .NET Core's rather bizarre versioning scheme. In this scheme, the SDK and Runtime have different versions that were diverging, but still close enough to be confusing. In your case, you have now seen a SDK 2.1 that can not target .NET Core (Runtime) 2.1. This was "fixed" (some discussion here), but the upshot is the versions are still confusing and dotnet --info is your best best to find out which SDK and Runtime versions are supported by your installation of .NET Core.

You are trying to build a netcoreapp2.1 (aka .NET Core 2.1) project. You need an SDK that knows about it.

But the SDK you have (which is version 2.1.200) is actually an older SDK that does not know about .NET Core 2.1! The SDK versions that know about .NET Core 2.1 are versioned 2.1.300 or later. You need a newer .NET Core SDK version, which will include a more recent .NET Core Runtime 2.1 version as well.

You should have a good enough version of .NET Core if dotnet --info says something about "2.1" in a "runtime" section.

Upvotes: 2

Related Questions