In late December 2016 I find that the default DotNetCore and default DotNetCore SDK are not playing nicely when it comes to the command line
I believe I have now found a fail-safe way of getting the command to work, without playing around with project.json. That solution simply means selecting the LTS (Long Term Support) version of the DotNetCore runtime rather than the Current version. But it took me a long time to get to that realization.
First, the screenshots showing the 2 errors which blocked any progress on this for some time, and which seem to crop up pretty frequently on a Google:
I then went back to a clean-ish machine, defined, as:
- no DotNetCore references in Programs and Features – that is both for the runtime and SDK
- recursive deletion of c:\Program Files\Dotnet
- prove that [dotnet] executing under PowerShell returns [no such command] of somesuch.
These are the key locations for getting the correct combination of files, right now:
So for the runtime, I grabbed the Current / Windows / .NET Core 1.1 runtime – Installer, noting and installing that version of the installer. The fact it is the Current version will be significant later in the post:
Now create a new working folder, e.g. c:\sandbox\t1 and navigate there (admin mode). Prove that [dotnet] now works:
All good. Now what happens if we try to run dotnet commands?
Fine. Return to the sdk location referenced above:
Note that confusingly it is the .Net Core element that is 1.1.0, with the SDK element 1.0.0. Regardless. Now try the [dotnet ef] command again…
No executable found matching command "dotnet-ef"
Hm. It requires you to invoke in fact the template Web to get this to work. So do e.g..
dotnet new -t Web
Now try [dotnet ef], and you get a different error:
The specified framework 'Microsoft.NETCore.App', version '1.0.0' was not found. - Check application dependencies and target a framework version installed at: C:\Program Files\dotnet\shared\Microsoft.NETCore.App - The following versions are installed: 1.1.0 - Alternatively, install the framework version '1.0.0'.
Let’s look at what P&F says we have:
1.1.0 both for the Runtime and for the SDK. Yet the message says I have “specified” 1.0.0. No I haven’t. I spent some time trying to marry up the project.json and the project.lock.json content to reconcile what was generated. I couldn’t, suggesting to me that the 1.0.0 requirement is somehow baked into DotNetCore EF in the current version. So then I went back to the downloads area above, and rather than specifying the Current version, I asked for the LTS or Longterm Support Version of the Runtime:
So although it says above it wants 1.0.0, maybe 1.0.3 is good enough. We run [dotnet ef] again, and this time we have lift-off:
And the installation has created a 1.0.3 runtime location in addition to the 1.1.0 runtime that was already there from the earlier default installation from the download area.
That’s all for this article. Another day we will look at scaffolding the EF project.
I will leave in some other screenshots: