Microsoft.AspNetCore.App vs Microsoft.NETCore.App publishing problem - deployment

I have a .NET core 2.2 application which I'm trying to publish to my web hosting but I'm getting a "500 - Internal Server Error" as a result.
I contacted support and they located the problem as being the following:
We enabled detailed error for your website and it is showing "Handler >"aspNetCore" has a bad module "AspNetCoreModuleV2" in its module list". It seems that you are using Microsoft.AspNetCore.App 2.2.1 for your website
application and this version is not installed on the server. Due to this website is not working.
On the server Microsoft.NETCore.App 2.2.1 is installed. So we would suggest you to re-deploy the application using .NetCore 2.2.1 and again check the website.
We only support .Net core runtimes installed on our shared hosting server. Re-deploy your application using the correct version to avoid any further issues. Please note that we do not support SCD (Self Contain Deployed application) on our shared server. We do support FDD (Framework Dependent Deployed application) only.
If I do a "dotnet --info" I can see that both .NETCore.App and AspNetCore.App are installed on my machine.
.NET Core SDKs installed:
2.2.103 [C:\Program Files\dotnet\sdk]
.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.2.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.2.1 [C:\Program
Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.2.1 [C:\Program > Files\dotnet\shared\Microsoft.NETCore.App]
My .csproj is referencing Microsoft.AspNetCore.App but it seems I cannot change this to Microsoft.NETCore.App.
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App"/>
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All"/>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.1"/>
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="6.0.0"/>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.2.1"/>
</ItemGroup>
</Project>
Is there any way I can deploy this app to use Microsoft.NETCore.App so it works on the server?

Related

Install .NET Standard version of a multi-target Nuget from a .NET 4.6.2 application?

Is it possible from a .NET 4.6.2 application to prefer .NET Standard version installation of a multi-target Nuget?
I have a .NET 4.6.2 application which is using a Nuget package built for both .NETFramework 4.6.2 and .NETStandard 2.0
When looking into the .csproj project file I can see this:
<Reference Include="CompanyAcme.TheNugetPackage.Client, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\TheNugetPackage.Client.2.1.4\lib\net462\CompanyAcme.TheNugetPackage.Client.dll</HintPath>
</Reference>
Which makes me think that my .NET 4.6.2 application is using the .NET 4.6.2 version of the Nuget package.
You can do it with this filthy hack, but I'd certainly think twice before doing it
<PackageReference Include="Prism.Core" ExcludeAssets="Compile" GeneratePathProperty="true"> <Version>7.1.0.431</Version> </PackageReference>
<Reference Include="Prism"> <HintPath>$(PkgPrism_Core)lib\netstandard2.0\Prism.dll</HintPath> </Reference>
From https://duanenewman.net/blog/post/a-better-way-to-override-references-with-packagereference/

Azure Devops - Compatibility problems moving from .NET Core 3.1 to .NET 5 at Nuget Package

I have a .NET Core solution which was running well using .NET Core 3.1 using a Pipeline on Azure Devops. Everything was working fine on the Pipeline.
After moving from .NET Core 3.1 to .NET 5.0, I started to have some strange troubles running the pipeline, specifically with Nuget packages.
I can build with no problems, but when it starts to pack using Nuget Package, I've got this error:
[error] The nuget command failed with exit code(1)
NU1202: Package Microsoft.EntityFrameworkCore 5.0.0 is not compatible with net50 (.NETFramework,Version=v5.0). Package Microsoft.EntityFrameworkCore 5.0.0 supports: netstandard2.1 (.NETStandard,Version=v2.1)
Some weird fact is that this solution is running fine at the local machine.
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Version>1.8.8.9</Version>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
I already tried to change the OS on the Build, but I've got this error:
The current available version of MSBuild is 16.7.0.37604. Change the .NET Core SDK specified in global.json to an older version that requires the MSBuild version currently available.
Does someone have an idea?
Package Microsoft.EntityFrameworkCore.Relational 5.0.0 supports:
netstandard2.1 (.NETStandard,Version=v2.1)
This is because it was using an old version of Nuget. You can try to change it to 5.x and restore.
Here is a case with similar issue you can refer to.

EF Core cannot install the Initial Migrations

These are the packages I have:
And this is my global.json file:
{
"sdk": {
"version": "3.1.101"
}
}
And this is my project file:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.1">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.1" />
</ItemGroup>
</Project>
Now I am trying to run this command but I get an error. What am I missing?
dotnet ef migrations add Initial
Error I get:
A compatible installed .NET Core SDK for global.json version [3.1.101] from [C:\MyRepoz\SportsSln\SportsStore\global.json] was not found
Install the [3.1.101] .NET Core SDK or update [C:\MyRepoz\SportsSln\SportsStore\global.json] with an installed .NET Core SDK:
1.1.14 [C:\Program Files\dotnet\sdk]
2.1.202 [C:\Program Files\dotnet\sdk]
2.1.508 [C:\Program Files\dotnet\sdk]
2.1.512 [C:\Program Files\dotnet\sdk]
2.1.801 [C:\Program Files\dotnet\sdk]
2.2.401 [C:\Program Files\dotnet\sdk]
3.1.301 [C:\Program Files\dotnet\sdk]
3.1.403 [C:\Program Files\dotnet\sdk]
OK the problem was that it specifically needs version 3.1.1 of .NET Core SDK.
So I went to their website and downloaded it and installed it.
Website is this: https://dotnet.microsoft.com/download/dotnet-core/3.1
Looks like dotnet is not recognised (you can verify it by typing dotnet --list-sdks, which should produce same error).
The solution should be to add env variable to PATH which points to the directory that contains SDKs. On Windows x64, this should be C:\Program Files\dotnet.
Also verify that C:\Program Files\dotnet\sdk\3.1.101 actually exists.

How do I ensure correct DotNet Core gets included in the build?

I am trying to deploy a .netcore 2.1.5 api to Windows 2012 Server R2
Currently my published api site gives the following error when I navigate to it
HTTP Error 502.5 - Process Failure
Common causes of this issue:
The application process failed to start
The application process started but then stopped
The application process started but failed to listen on the configured port
Troubleshooting steps:
Check the system event log for error messages
Enable logging the application process' stdout messages
Attach a debugger to the application process and inspect
For more information visit: https://go.microsoft.com/fwlink/?LinkID=808681
In the event log I can see
Event 1000, IIS AspNetCore Module
Application 'MACHINE/WEBROOT/APPHOST/MYSITE.COM.AU/MYAPINAME' with physical root 'C:\WebSites\MYSITE.COM.AU\MyApps\MYAPINAME\' failed to start process
commandline '.\dotnet .\mydllname.dll', ErrorCode='0x80004005 : 80008083
From this question
I see that I can include
<PublishWithAspNetCoreTargetManifest>False</PublishWithAspNetCoreTargetManifest>
In the publish profile If I want to ensure the correct version of DotNetCore gets installed on the host computer.
But how do I set that up if I want to use Azure Devops?
I tried checking Publish Web Projects in the Publish task
but I then get an error
No web project was found in the repository. Web projects are identified by
presence of either a web.config file or wwwroot folder in the directory.
Project file(s) matching the specified pattern were not found.
The dependencies include
Microsoft.AspNetCore.App 2.1.5
but I don't see a coresponding dll deployed.
I tried installing dotnet-runtime-2.1.5 on the computer, downloaded from
the installer site
[Update]
I noticed the logs folder was missing so I created it manually
[Update]
I added the task suggested by Eriawan
The YAML is
steps:
- task: DotNetCoreInstaller#0
displayName: 'Use .NET Core sdk 2.1.5'
inputs:
version: 2.1.5
I get in the log
2018-10-29T08:29:05.4839748Z ##[section]Starting: Use .NET Core sdk 2.1.5
2018-10-29T08:29:05.4843909Z ==============================================================================
2018-10-29T08:29:05.4843981Z Task : .NET Core Tool Installer
2018-10-29T08:29:05.4844041Z Description : Acquires a specific version of .NET Core from internet or the tools cache and adds it to the PATH. Use this task to change the version of .NET Core used in subsequent tasks.
2018-10-29T08:29:05.4844089Z Version : 0.1.16
2018-10-29T08:29:05.4844134Z Author : Microsoft Corporation
2018-10-29T08:29:05.4844192Z Help : [More Information](https://go.microsoft.com/fwlink/?linkid=853651)
2018-10-29T08:29:05.4844234Z ==============================================================================
2018-10-29T08:29:05.9812262Z Tool to install: .NET Core sdk version 2.1.5.
2018-10-29T08:29:05.9825645Z Checking if a cached copy exists for this version...
2018-10-29T08:29:05.9830151Z Cache does not contains this particular .NET Core. Will be downloaded and installed.
2018-10-29T08:29:05.9833458Z Detected platform (Primary): win-x64
2018-10-29T08:29:05.9833723Z Getting URL to download .NET Core sdk version: 2.1.5.
2018-10-29T08:29:06.5248134Z Could not fetch download information for version 2.1.5. Please check if the version specified is correct. You can refer the link for supported versions => https://github.com/dotnet/core/blob/master/release-notes/releases.json. Falling back to creating convention based URL.
2018-10-29T08:29:06.5481883Z [command]C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoLogo -Sta -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command "& 'D:\a\_tasks\DotNetCoreInstaller_b0ce7256-7898-45d3-9cb5-176b752bfea6\0.1.16\externals\install-dotnet.ps1' -Version 2.1.5 -DryRun"
2018-10-29T08:29:07.6386710Z dotnet-install: Payload URLs:
2018-10-29T08:29:07.6387117Z dotnet-install: Primary - https://dotnetcli.azureedge.net/dotnet/Sdk/2.1.5/dotnet-sdk-2.1.5-win-x64.zip
2018-10-29T08:29:07.6387245Z dotnet-install: Legacy - https://dotnetcli.azureedge.net/dotnet/Sdk/2.1.5/dotnet-dev-win-x64.2.1.5.zip
2018-10-29T08:29:07.6387445Z dotnet-install: Repeatable invocation: .\install-dotnet.ps1 -Version 2.1.5 -Channel LTS -Architecture x64 -InstallDir <auto>
2018-10-29T08:29:07.6451802Z Downloading: https://dotnetcli.azureedge.net/dotnet/Sdk/2.1.5/dotnet-sdk-2.1.5-win-x64.zip
2018-10-29T08:29:08.8792388Z ##[warning]Could not download installation package from this URL: https://dotnetcli.azureedge.net/dotnet/Sdk/2.1.5/dotnet-sdk-2.1.5-win-x64.zip Error: {}
2018-10-29T08:29:08.8807163Z Downloading: https://dotnetcli.azureedge.net/dotnet/Sdk/2.1.5/dotnet-dev-win-x64.2.1.5.zip
2018-10-29T08:29:09.5450400Z ##[warning]Could not download installation package from this URL: https://dotnetcli.azureedge.net/dotnet/Sdk/2.1.5/dotnet-dev-win-x64.2.1.5.zip Error: {}
2018-10-29T08:29:09.5453128Z ##[error]Failed to download package for installation
2018-10-29T08:29:09.5551776Z ##[section]Finishing: Use .NET Core sdk 2.1.5
The designer shows
The csproj is
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<ApplicationIcon />
<OutputType>Exe</OutputType>
<StartupObject />
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DocumentationFile>bin\Debug\netcoreapp2.1\trackApi.xml</DocumentationFile>
<DefineConstants>TRACE;DEBUG;NETCOREAPP2_1</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DocumentationFile>bin\Release\netcoreapp2.1\trackApi.xml</DocumentationFile>
</PropertyGroup>
<ItemGroup>
<Folder Include="logs\" />
<Folder Include="Views\Account\" />
<Folder Include="wwwroot\" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.3" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" Version="2.1.5" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.1.5" />
<PackageReference Include="Serilog.Extensions.Logging" Version="2.0.2" />
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
<PackageReference Include="Serilog.Sinks.RollingFile" Version="3.3.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="3.0.0" />
</ItemGroup>
<ItemGroup>
<Content Update="appsettings.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
</Project>
[Update]
problems in build pipeline
[Update]
I created a new pipeline using YAML
pool:
vmImage: 'VS2017-Win2016'
variables:
buildConfiguration: 'Debug'
steps:
- task: DotNetCoreInstaller#0
displayName: 'Use .NET Core sdk 2.1.5'
inputs:
version: 2.1.5
- task: DotNetCoreCLI#2
displayName: Restore
inputs:
command: restore
projects: '**/Api*.csproj'
However I still get an error
018-10-29T09:36:13.7155347Z ##[section]Starting: Use .NET Core sdk 2.1.5
2018-10-29T09:36:13.7158688Z ==============================================================================
2018-10-29T09:36:13.7158742Z Task : .NET Core Tool Installer
2018-10-29T09:36:13.7158774Z Description : Acquires a specific version of .NET Core from internet or the tools cache and adds it to the PATH. Use this task to change the version of .NET Core used in subsequent tasks.
2018-10-29T09:36:13.7158842Z Version : 0.1.16
2018-10-29T09:36:13.7158878Z Author : Microsoft Corporation
2018-10-29T09:36:13.7158926Z Help : [More Information](https://go.microsoft.com/fwlink/?linkid=853651)
2018-10-29T09:36:13.7158958Z ==============================================================================
2018-10-29T09:36:14.1220877Z Tool to install: .NET Core sdk version 2.1.5.
2018-10-29T09:36:14.1231419Z Checking if a cached copy exists for this version...
2018-10-29T09:36:14.1238258Z Cache does not contains this particular .NET Core. Will be downloaded and installed.
2018-10-29T09:36:14.1240864Z Detected platform (Primary): win-x64
2018-10-29T09:36:14.1240993Z Getting URL to download .NET Core sdk version: 2.1.5.
2018-10-29T09:36:14.5706519Z Could not fetch download information for version 2.1.5. Please check if the version specified is correct. You can refer the link for supported versions => https://github.com/dotnet/core/blob/master/release-notes/releases.json. Falling back to creating convention based URL.
2018-10-29T09:36:14.5957734Z [command]C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoLogo -Sta -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command "& 'D:\a\_tasks\DotNetCoreInstaller_b0ce7256-7898-45d3-9cb5-176b752bfea6\0.1.16\externals\install-dotnet.ps1' -Version 2.1.5 -DryRun"
2018-10-29T09:36:15.3109409Z dotnet-install: Payload URLs:
2018-10-29T09:36:15.3109790Z dotnet-install: Primary - https://dotnetcli.azureedge.net/dotnet/Sdk/2.1.5/dotnet-sdk-2.1.5-win-x64.zip
2018-10-29T09:36:15.3109942Z dotnet-install: Legacy - https://dotnetcli.azureedge.net/dotnet/Sdk/2.1.5/dotnet-dev-win-x64.2.1.5.zip
2018-10-29T09:36:15.3110089Z dotnet-install: Repeatable invocation: .\install-dotnet.ps1 -Version 2.1.5 -Channel LTS -Architecture x64 -InstallDir <auto>
2018-10-29T09:36:15.3188675Z Downloading: https://dotnetcli.azureedge.net/dotnet/Sdk/2.1.5/dotnet-sdk-2.1.5-win-x64.zip
2018-10-29T09:36:16.5236693Z ##[warning]Could not download installation package from this URL: https://dotnetcli.azureedge.net/dotnet/Sdk/2.1.5/dotnet-sdk-2.1.5-win-x64.zip Error: {}
2018-10-29T09:36:16.5256084Z Downloading: https://dotnetcli.azureedge.net/dotnet/Sdk/2.1.5/dotnet-dev-win-x64.2.1.5.zip
2018-10-29T09:36:17.2185860Z ##[warning]Could not download installation package from this URL: https://dotnetcli.azureedge.net/dotnet/Sdk/2.1.5/dotnet-dev-win-x64.2.1.5.zip Error: {}
2018-10-29T09:36:17.2189408Z ##[error]Failed to download package for installation
2018-10-29T09:36:17.2271136Z ##[section]Finishing: Use .NET Core sdk 2.1.5
The url https://dotnetcli.azureedge.net/dotnet/Sdk/2.1.5/dotnet-dev-win-x64.2.1.5.zip shows an error
This XML file does not appear to have any style information associated with it. The document tree is shown below.
<Error>
<Code>BlobNotFound</Code>
<Message>
The specified blob does not exist. RequestId:7447502f-301e-00a8-516d-6f7cde000000 Time:2018-10-29T09:57:58.4200303Z
</Message>
</Error>
[Update]
Eriawan has the answer.
I needed to use a YAML pipeline and get the version here.
In order to control the build to use specific version of .NET Core runtime, you must tell the build agent to install the .NET Core SDK to use and also specify the SDK version to install before building your code.
If you use YAML on your Azure DevOps Pipelines build, you could run this task: DotNetCoreInstaller#0 and set the version of to 2.1.403 .
The task must be run before any tasks, preferably the first task to run.
For example:
- task: DotNetCoreInstaller#0
inputs:
version: '2.1.403'
If you're using the build definition designer, add the ".NET Core Tool Installer" task and specify the version that you want to use from there.
Please consult .NET Core build sample on MSFT docs:
https://learn.microsoft.com/en-us/azure/devops/pipelines/languages/dotnet-core?view=vsts&tabs=yaml#build-environment
UPDATE 1:
OK, I have seen your build error. Looks like the .NET Core installer task has wrong URL address for .NET Core SDK of 2.1.403.
You can use pure YAML instead. I will file a bug on the .NET Core installer task repo. In the meantime, please use a full YAML.
I already have one working YAML file, a sample of this is available on my own repo.
For example:
https://github.com/RXCommunica/rx-azuredevops-rest/blob/master/azuredevopsrest-ci-vs2017.yml
UPDATE 2:
I have added comments for your YAML. The .NET Core tool version on your YAML is incorrect. Update/change your yaml from the original:
- task: DotNetCoreInstaller#0
displayName: 'Use .NET Core sdk 2.1.5'
inputs:
version: 2.1.5
to:
- task: DotNetCoreInstaller#0
displayName: 'Use .NET Core sdk 2.1.5'
inputs:
version: 2.1.403
This is important, because version of .NET Core runtime is not equal to the version of the actual SDK tool version.
Please consult this doc for the tool version and the related runtime list of .NET Core 2.1:
https://www.microsoft.com/net/download/dotnet-core/2.1

Microsoft.EntityFrameworkCore.Tools.DotNet v2.0.1

Currently Microsoft.EntityFrameworkCore.Tools.DotNet V2.0.1 is showing a dependency of .NetCoreApp Version = 2.0
Any reason why that isnt version >=2.0 ?
Any idea when support for the more recent versions of
.NetCore SDK will be available
EDIT: Added screenshot
See dependency listed as .NetCoreApp = v2.0 and not .NetStandard = V2.0 or >= CoreApp V2.0 for similar packages.
edit2:
I ran the following new Project tests:
i still think there is an issue here.
I have .netcore sdk 2.1.4 installed
I started with brand new solution in VS2017 15.5.5
I create a new core project
netcoreapp2.0
and a new standard project
netstandard2.0
These packages
o Microsoft.EntityFrameworkCore.tools v2.0.1
o Microsoft.EntityFrameworkCore.design v2.0.1
o Microsoft.EntityFrameworkCore v2.0.1
o Microsoft.EntityFrameworkCore.Sqlite
can all be successfully installed in both projects
netstandard2.0
and
netcoreapp2.0
However:
Microsoft.EntityFrameworkCore.Tools.DotNet v2.0.1
can not be installed in netstandard2.0 project, which I can live with and the error makes some sense.
Restoring packages for C:_Dev\PJSTest\PJSStd\PJSStd.csproj... Package
Microsoft.EntityFrameworkCore.Tools.DotNet 2.0.1 is not compatible
with netstandard2.0 (.NETStandard,Version=v2.0). Package
Microsoft.EntityFrameworkCore.Tools.DotNet 2.0.1 supports:
netcoreapp2.0 (.NETCoreApp,Version=v2.0) Package restore failed.
Rolling back package changes for 'PJSStd'. Time Elapsed:
00:00:00.1634807
========== Finished ==========
BUT
Microsoft.EntityFrameworkCore.Tools.DotNet v2.0.1
can not be even be installed in a netcoreapp2.0 project
Restoring packages for C:_Dev\EFTEST\EFCore\EFCore.csproj... Detected
package downgrade: Microsoft.NETCore.App from 2.0.3 to 2.0.0.
Reference the package directly from the project to select a different
version. EFCore -> Microsoft.EntityFrameworkCore.Tools.DotNet 2.0.1
-> Microsoft.NETCore.App (>= 2.0.3) EFCore -> Microsoft.NETCore.App (>= 2.0.0) Package restore failed. Rolling back package changes for
'EFCore'. Time Elapsed: 00:00:01.1413809
========== Finished ==========
I think there is an issue with versioning on the CoreApp dependency.
I'm happy to be corrected, but my understanding is that .NetCoreApp (v2) is the platform, whereas .NetCore.App (v2.0.5, currently) is the set of API's that target that platform.
So the fact that Microsoft.EntityFrameworkCore.Tools.DotNet V2.0.1 only points to .NetCoreApp,Version = 2.0 means it can only support the apis from that platform... which says nothing about what platforms those dependencies support. e.g. you if you take a further and look inside at the Microsoft.NetCore.App dependencies, you will see listings under .NetCoreApp,Version = 1.0 up to 2.0.
EDIT: My understanding of various .NET core versioning landscape goes as follows:
The .NET Core SDK version is 2.1.5. This allows the building of .NET standard and .NET core apps.
The Microsoft.EntityFrameworkCore.Tools.DotNet version is 2.0.1. This references .netcoreapp2.0
.netcoreapp2.0 is the platform that implements Microsoft.NetCore.App, which is currently version 2.0.5 of the runtime.
The key part of netcoreapp2.0 is its dependence on .NETStandard.Library (netstandard2.0) but netstandard2.0 does not depend on netcoreapp2.0. I think this answer explains it better than I can. So the EntityFramework cli tools won't work on a library that uses .netstandard2.0 because it targets .netcoreapp2.0. Incidentally, EFCore does work - because it targets .netstandard - just the tools won't.
In summary, the SDK that you have, at version 2.1.4, already contains the necessary .NET Core platforms and runtimes. So no downgrade to the original version 2 is required. What needs to happen is that the csproj has to be updated to target the .NET Core runtime instead in order to use the tools: <TargetFramework>netcoreapp2.0</TargetFramework>.
EDIT2: Here's a sample of a csproj file that targets .netstandard (so that UWP can reference it), and is able to use the EFCore tools.DotNet:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.0.1" PrivateAssets="All" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.1" />
</ItemGroup>
</Project>
The Microsoft.EntityFrameworkCore.Tools is a package reference that targets .NET Standard. the Microsoft.EntityFrameworkCore.Tools.DotNet is a tools reference and is treated differently to package references. So the versioning and targets are also a little different.