Home: VS 2017: PackageType=DotnetCliTool fails to install

Created on 4 Jan 2017  路  52Comments  路  Source: NuGet/Home

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

2 VS.Client Feature

Most helpful comment

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

All 52 comments

@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 - 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?

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.

cc @DamianEdwards

+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 ?

dotnet add package doesn't support it correctly either.

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

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>

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

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

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

Still not working for me, same error as @st2forget

Not working for me. Trying to install Autorest, console, mvc, tried all tricks available on the internet.

Still not working none of the forementioned methods for me.

Still not working

Could someone share exact repro steps for what they are trying that isn't working along with the version of dotnet used?

@emgarten

-Microsoft Visual Studio Community 2017 Version 15.2 (26430.16) Release
-NuGet Package Manager 4.2.0
-Package Installer 2.0.101
-asp.net core 1.1
-.net 4.6.1

I'm trying to setup social login like twitter and facebook, but I can't install some packages based on instructions
https://docs.microsoft.com/en-us/aspnet/core/security/authentication/social/facebook-logins
https://docs.microsoft.com/en-us/aspnet/core/security/authentication/social/twitter-logins

Problem with installing this packages
Microsoft.Extensions.SecretManager.Tools -Version 1.0.1
Microsoft.AspNetCore.Authentication.Twitter
Microsoft.AspNetCore.Authentication.Facebook

I'm trying install from package manager, from package console and from .csproj

Without any success, I was tried also in asp.net core 1.0

and from .csproj

Would you share your csproj? What output did you get?

@emgarten csproj
`

<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Cookies" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.3" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="1.1.2" PrivateAssets="All" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="1.1.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer.Design" Version="1.1.2" PrivateAssets="All" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="1.1.1" PrivateAssets="All" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="1.1.2" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.2" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="1.1.1" PrivateAssets="All" />
<PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="1.1.2" />




<DotNetCliToolReference Include="Microsoft.Extensions.SecretManager.Tools" Version="1.0.0-msbuild3-final" />

`
dotnet restore

`dotnet restore
Restoring packages for C:\Users\alexo\Documents\Visual Studio 2017\Projects\WebSocialLogin\WebSocialLogin\WebSocialLogin.csproj...
Restoring packages for C:\Users\alexo\Documents\Visual Studio 2017\Projects\WebSocialLogin\WebSocialLogin\WebSocialLogin.csproj...
Restoring packages for C:\Users\alexo\Documents\Visual Studio 2017\Projects\WebSocialLogin\WebSocialLogin\WebSocialLogin.csproj...
Restoring packages for C:\Users\alexo\Documents\Visual Studio 2017\Projects\WebSocialLogin\WebSocialLogin\WebSocialLogin.csproj...
Restore completed in 1,89 sec for C:\Users\alexo\Documents\Visual Studio 2017\Projects\WebSocialLogin\WebSocialLogin\WebSocialLogin.csproj.
Restore completed in 1,96 sec for C:\Users\alexo\Documents\Visual Studio 2017\Projects\WebSocialLogin\WebSocialLogin\WebSocialLogin.csproj.
Restore completed in 2 sec for C:\Users\alexo\Documents\Visual Studio 2017\Projects\WebSocialLogin\WebSocialLogin\WebSocialLogin.csproj.
Generating MSBuild file C:\Users\alexo\Documents\Visual Studio 2017\Projects\WebSocialLogin\WebSocialLogin\obj\WebSocialLogin.csproj.nuget.g.props.
Writing lock file to disk. Path: C:\Users\alexo\Documents\Visual Studio 2017\Projects\WebSocialLogin\WebSocialLogin\obj\project.assets.json
Restore completed in 3,17 sec for C:\Users\alexo\Documents\Visual Studio 2017\Projects\WebSocialLogin\WebSocialLogin\WebSocialLogin.csproj.

NuGet Config files used:
C:\Users\alexoAppData\Roaming\NuGet\NuGet.Config
C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.Offline.config

Feeds used:
https://api.nuget.org/v3/index.json
https://www.myget.org/F/aspnet-contrib/api/v3/index.json
C:\Program Files (x86)\Microsoft SDKs\NuGetPackages`

From nuget manager
Severity Code Description Project File Line Suppression State Error Package 'Microsoft.Extensions.SecretManager.Tools 1.0.1' has a package type 'DotnetCliTool' that is not supported by project 'WebSocialLogin'. 0

From package console
`
PM> Install-Package Microsoft.Extensions.SecretManager.Tools -Version 1.0.1
GET https://api.nuget.org/v3/registration2-gz/microsoft.extensions.secretmanager.tools/index.json
GET https://www.myget.org/F/aspnet-contrib/api/v3/registration1/microsoft.extensions.secretmanager.tools/index.json
OK https://api.nuget.org/v3/registration2-gz/microsoft.extensions.secretmanager.tools/index.json 634ms
Restoring packages for C:\Users\alexo\OneDrive\projects\proliant_gis\XGis\XGis.Web\XGis.Web.csproj...
Install-Package : Package 'Microsoft.Extensions.SecretManager.Tools 1.0.1' has a package type 'DotnetCliTool' that is not supported by project 'XGis.Web'.
At line:1 char:1

  • Install-Package Microsoft.Extensions.SecretManager.Tools -Version 1.0 ...
  • ~~~~~~~~~~~~~~~~~

    • CategoryInfo : NotSpecified: (:) [Install-Package], Exception

    • FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand

Time Elapsed: 00:00:02.1396353`

@AlexOliinyk1 manually editting the csproj and restoring works for you then?

The issue is tracking support for adding tools using the VS UI and Package Console. The workaround is to edit the csproj to add the tool until this feature is added to VS.

@emgarten it is looks like edit .csproj works, but it seems package still not installed.
Please see following image
http://prntscr.com/g0f5lq

Maybe I something missed but I'm trying a lot of time, and in the newly created project and with different version asp.net core, and it seems visual studio and nuget has latest updates.

@emgarten Any ideas ? Because it is really blocker for me

The Package Manager Console runs in the solution directory by default. Did you 'cd' into the project directory before running 'dotnet user-secrets'?

@natemcmaster Thanks, I'm run this 'dotnet user-secrets -h' from 'powershell' based solution path and it is look like all is works. You really saved, my day.
@emgarten Thanks

I made it by running command in cmd:

dotnet add package Microsoft.EntityFrameworkCore.Tools.DotNet

Best regards!

Stiill doesn't work for me in VS2017 (VisualStudio.15.Release/15.3.0+26730.3)

I have the same issue, did you guys fixed?

I'm having this issue on OSX. Neither VS for Mac or JetBrains' Rider can install the package. I've also tried dotnet add package Microsoft.EntityFrameworkCore.Tools.DotNetin the CLI but that failed in the same way.
Manually editing the .csproj doesn't work either.

I'm trying to use EF Core 2.0 with .NET standard 2.0

@mbrookson, I patched NuGet in Rider and fix the problem. Rider 2017.2 EAP 1 will support the installation of such packages (will be available soon).

Using Rider 2017.2 EAP I am still getting issues with this. Trying to install gives me an error in the Nuget log. Package Microsoft.EntityFrameworkCore.Tools.DotNet 2.0.0 is not compatible with netstandard2.0 (.NETStandard,Version=v2.0). Package Microsoft.EntityFrameworkCore.Tools.DotNet 2.0.0 supports: netcoreapp2.0 (.NETCoreApp,Version=v2.0).

Trying to install it in a .NETStandard 2.0 project which I am using for a data/domain layer, which is referenced by my API project.

This doesn't appear to be a Rider issue as it happens when I run the dotnet CLI commands too. Can EF Core Tools only be installed in a netcoreapp2.0 project now and not a netstandard2.0 project?

Any help would be appreciated!

@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.

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

@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.

@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).

@mbrookson @AndreyAkinshin You definitely can. See the workaround above.

@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.)

@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?

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.

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

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.

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.

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

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?

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

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

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>

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

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

We're not planning on adding CLI support for dotnetclitoolreferences anymore.
dotnet global tools, etc... are the direction.

@rrelyea What does that mean? Are you going to stop using DotNetCliToolReferences altogether? Or that they won't work when installed via the CLI. Cause this bug was occurring when installed via VS.

I made it by running command in cmd:

dotnet add package Microsoft.EntityFrameworkCore.Tools.DotNet

Best regards!

it works for me

Little help for those trying Core 3 Preview

https://wildermuth.com/2019/08/19/My-First-Look-at-ASP-NET-Core-3-0

Was this page helpful?
0 / 5 - 0 ratings