New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VS 2017: PackageType=DotnetCliTool fails to install #4190

Open
natemcmaster opened this Issue Jan 4, 2017 · 48 comments

Comments

Projects
None yet
@natemcmaster
Copy link

natemcmaster commented Jan 4, 2017

Details

VS 2017: 15.0.26014
NuGet GUI
Worked in NuGet: 3.5.0.1996 with VS 2015 u3

Repro

  1. File -> New -> Project -> .NET Core -> Console App
  2. Project -> Manage NuGet packages...
  3. Attempt to install a "CLI tool" package, e.g. https://www.nuget.org/packages/Microsoft.DotNet.Watcher.Tools/1.1.0-preview4-final

Fails with error:

Package 'Microsoft.DotNet.Watcher.Tools 1.1.0-preview4-final' has a package type 'DotnetCliTool' that is not supported by project 'ConsoleApp1'.

image

More details

The package's NuSpec:

    <packageTypes>
      <packageType name="DotnetCliTool" />
    </packageTypes>

Output window:

Restoring packages for C:\Users\nmcmaster\documents\visual studio 2017\Projects\ConsoleApp1\ConsoleApp1\ConsoleApp1.csproj...
Detected package downgrade: Microsoft.NETCore.App from 1.1.0 to 1.0.1 
 ConsoleApp1 (>= 1.0.0) -> Microsoft.DotNet.Watcher.Tools (>= 1.1.0-preview4-final) -> Microsoft.NETCore.App (>= 1.1.0) 
 ConsoleApp1 (>= 1.0.0) -> Microsoft.NETCore.App (>= 1.0.1)
Package 'Microsoft.DotNet.Watcher.Tools 1.1.0-preview4-final' has a package type 'DotnetCliTool' that is not supported by project 'ConsoleApp1'.
========== Finished ==========
Time Elapsed: 00:00:01.9317626

The project:

<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp1.0</TargetFramework>
  </PropertyGroup>
  <ItemGroup>
    <Compile Include="**\*.cs" />
    <EmbeddedResource Include="**\*.resx" />
  </ItemGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.NETCore.App" Version="1.0.1" />
  </ItemGroup>
</Project>

cc @joelverhagen

@muratg

This comment has been minimized.

Copy link
Member

muratg commented Jan 4, 2017

@rrelyea, this used to work on VS2015 so looks like a regression that would impact all of the tool projects that use this flag.

@Eilon, could you add this bug to your tracking list?

@natemcmaster

This comment has been minimized.

@rrelyea

This comment has been minimized.

Copy link
Contributor

rrelyea commented Jan 4, 2017

@natemcmaster - We punted the work to support tools installs via the UI with the idea that tools will be installed by default with new projects ... and that people can edit the csproj if an addition is needed.
Make sense?

@natemcmaster

This comment has been minimized.

Copy link

natemcmaster commented Jan 4, 2017

Makes sense. Would still love to see this make it in to RTM.

But if this gets bumped, can we at least change the error? It currently says that the project doesn't support CLI tools, which may mislead some to believe .NET Core CLI tools don't work anymore.

@rrelyea rrelyea modified the milestones: Future-1, 4.0 RC3 Jan 5, 2017

@natemcmaster

This comment has been minimized.

Copy link

natemcmaster commented Jan 5, 2017

@balachir

This comment has been minimized.

Copy link

balachir commented Jan 6, 2017

+1 on a better error message when doing this from the Manage NuGet packages UI

Rob suggested it might be possible to get this working from the Install-Package power shell command for RC3 / RTM. @rrelyea ?

@bricelam

This comment has been minimized.

Copy link

bricelam commented Mar 11, 2017

dotnet add package doesn't support it correctly either.

@isaac2004

This comment has been minimized.

Copy link

isaac2004 commented Jun 2, 2017

This issue still exists with Dot Net Standard 2.0. Is there any update on this issue? I want to be able to use EF Core in a CL targeting standard 2.0 and this stops this from being possible

@geirsagberg

This comment has been minimized.

Copy link

geirsagberg commented Jul 3, 2017

As a workaround, you can edit the .csproj file and add the tool manually, e.g.:

  <ItemGroup>
    <DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.Dotnet" Version="2.0.0-preview2-final" />
  </ItemGroup>
@st2forget

This comment has been minimized.

Copy link

st2forget commented Jul 10, 2017

@geirsagberg,
Still does not work. When use "dotnet restore", it still says: "... has a package type 'DotnetCliTool' that is not supported ..."

@AdrienTorris

This comment has been minimized.

Copy link

AdrienTorris commented Jul 10, 2017

Same error than @st2forget . I tried to add the package manually in the csproj but the error is still the same.

@AdrienTorris

This comment has been minimized.

Copy link

AdrienTorris commented Jul 10, 2017

It works now. I did nothing, just wait ...

@AndreyAkinshin

This comment has been minimized.

Copy link

AndreyAkinshin commented Sep 11, 2017

@mbrookson, Rider prints a correct message: Microsoft.EntityFrameworkCore.Tools.DotNet is not compatible with netstandard2.0, it supports only netcoreapp2.0 (you can check https://www.nuget.org/packages/Microsoft.EntityFrameworkCore.Tools.DotNet, the Dependencies section).
If you create a netcoreapp2.0 project in Rider 2017.2 EAP 1, you should be able to install Microsoft.EntityFrameworkCore.Tools.DotNet without any troubles.

@raffaeler

This comment has been minimized.

Copy link

raffaeler commented Sep 11, 2017

I may have misunderstood but repro-ing the problem is extremely easy.
I created a simple dotnet CLI extension and published in my local repo.
When I try to install it via VS2017, I obtain the following error:

'XYZ 1.0.0.0' has a package type 'DotnetCliTool' that is not supported by project XYZ

I specified these tags in the nuspec:

    <packageTypes>
      <packageType name="DotnetCliTool" />
    </packageTypes>

They did work in VS2015 and does not work anymore in VS2017.
Is there a workaround for making it work from the VS2017 UI?
Modifying the csproj is a no-go in my case since this is a CI/CD tool that should avoid any manual editing step.

Thank you

@mbrookson

This comment has been minimized.

Copy link

mbrookson commented Sep 11, 2017

@AndreyAkinshin I understand that now, but do you know then how I can have my DbContext and migrations in my netstandard2.0 project with all my entities and domain services? I have API controllers in a netcoreapp2.0 which calls the services in the netstandard2.0 project.
This is how my current .NET Framework applications are architected and thought I would be able to replicate this with .NET Core.

@AndreyAkinshin

This comment has been minimized.

Copy link

AndreyAkinshin commented Sep 12, 2017

@mbrookson Sorry, I don't know how to help you, you can't use the Microsoft.EntityFrameworkCore.Tools.DotNet package in a netstandard2.0 project (as a PackageReference).

@bricelam

This comment has been minimized.

Copy link

bricelam commented Sep 12, 2017

@Eilon

This comment has been minimized.

Copy link

Eilon commented Sep 12, 2017

@bricelam indeed, correct me if I'm wrong: the target framework moniker (TFM) of the project is completely independent of the TFM of tool references, right? (But you do have to manually do it, because VS doesn't have a built-in way of doing this.)

@mbrookson

This comment has been minimized.

Copy link

mbrookson commented Sep 12, 2017

@bricelam @Eilon This is good news. So in which project do I actually need to install the Microsoft.EntityFrameworkCore.Tools and Microsoft.EntityFrameworkCore.Tools.DotNet Nuget packages then? Are they still installed in the netcoreapp2.0 web project but then I can run ef commands in the netstandard projects after manually adding that .csproj change mentioned above?

@Eilon

This comment has been minimized.

Copy link

Eilon commented Sep 12, 2017

You still install them in the project (into the same CSPROJ file), but as tools references, not package references. They are represented as different XML elements inside the CSPROJ.

@ErenForce

This comment has been minimized.

Copy link

ErenForce commented Jan 4, 2018

Any news on this? Are we doomed to forever manually edit the .csproj file?

@Eilon

This comment has been minimized.

Copy link

Eilon commented Jan 4, 2018

I think with the upcoming Global Tools feature the priority of this might be a bit lower.

I think @KathleenDollard and @richlander can share more thoughts on this.

@KathleenDollard

This comment has been minimized.

Copy link

KathleenDollard commented Jan 4, 2018

Tools aren't really packages, they have a different purpose, so add package seems the wrong gesture.

We're working on a better tooling story overall, and EF is definitely in that mix. More to come soon.

@raffaeler

This comment has been minimized.

Copy link

raffaeler commented Jan 5, 2018

@KathleenDollard are you saying that there is no solution for the current release of the product?

@cgountanis

This comment has been minimized.

Copy link

cgountanis commented Feb 28, 2018

Still having this issue with the latest SDK.

Error when adding the tools via NUGET as well. Right now we have to add that line manually to do migrations etc...

<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.1" />

How are people using EF in CORE without this working?

@MisinformedDNA

This comment has been minimized.

Copy link

MisinformedDNA commented Feb 28, 2018

Because we are doing it manually as well. It's annoying, but it shouldn't block you.

@bricelam

This comment has been minimized.

Copy link

bricelam commented Mar 2, 2018

Here are the docs on how to install the EF Core tools. (manually)

@vmukunda

This comment has been minimized.

Copy link

vmukunda commented Apr 3, 2018

As specified by @geirsagberg adding the following dependancy directly to the .csproj file worked for me.

<ItemGroup>
    <DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.Dotnet" Version="2.0.0-preview2-final" />
 </ItemGroup>
@rkmr039

This comment has been minimized.

Copy link

rkmr039 commented May 9, 2018

start Developer Command Prompt for VS 2017 and change directory to current project
then run this command
dotnet add package Microsoft.EntityFrameworkCore.Tools.DotNet

vs_cmd
and then rebuild the project

package_added

@SuperJMN

This comment has been minimized.

Copy link

SuperJMN commented Sep 16, 2018

I'm experiencing the same issue. Someone please fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment