Skip to content
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

Is there a plan to support global tools install like Npm ? #7427

Closed
John0King opened this issue Dec 26, 2016 · 43 comments
Closed

Is there a plan to support global tools install like Npm ? #7427

John0King opened this issue Dec 26, 2016 · 43 comments
Assignees
Labels
Milestone

Comments

@John0King
Copy link

In NodeJs we can use npm install bower -g to install bower or other tools ,
I think dotnet should do it too .
I expect there will be a command like : dotnet tools install <toolname> -g by default the tools put in global shoud build a platform specific binary ( on windows, there will be a <app>.exe file )

and dotnet tools install <toolname> to manage the tools section in project.json.

@leixu2txtek
Copy link

nuget ?

@John0King
Copy link
Author

yes

@TheRealPiotrP
Copy link
Contributor

Global tools is something we want to pursue, but won't get to it during 1.0 release.

@TheRealPiotrP TheRealPiotrP changed the title Is there a plan to support tools install like Npm ? Is there a plan to support global tools install like Npm ? Jan 18, 2017
@Petermarcu
Copy link
Member

I assume no project file is required for someone to acquire a global tool. Many tools people want to deliver are not about projects. They are about debugging or reverse engineering already built assets.

@noahfalk
Copy link
Member

We (the diagnostics folks) would love to use something like this to deliver some diagnostic tools we have in mind.

@gulshan
Copy link

gulshan commented Jan 19, 2017

Can it be just dotnet install instead of dotnet tools install?

@lt72
Copy link

lt72 commented Feb 13, 2017

@piotrpMSFT was there any progress on this issue and do we know if this is a committed work item for 2.0?

@TheRealPiotrP
Copy link
Contributor

@lt72 No 2.0 work is committed at this point. we're still getting 1.0 out the door.

@lt72
Copy link

lt72 commented Feb 15, 2017

@mikem and @noahfalk FYI: our POR for downloading the debugger tools needs to take into account the current state of the art RE: dotnet CLI schedule. See Peter's answers above.

@MartinJohns
Copy link

MartinJohns commented Jun 23, 2017

@piotrpMSFT Any updates? 1.0 is already out the door for quite some time, and this feature would really be useful to actually make tools usable.

@ricky-hartmann-zocdoc
Copy link

In the npm/node world, installing a package globally allows you to invoke it with nothing else in front of it:

npm install -g webpack
webpack ...

Installed locally, you need to either call it in the scripts of your package.json, or invoke it behind something like npx which checks the global and local stores

npm install --save webpack
npx webpack ...

Maybe I'm wrong, but I feel like the dotnet tools (whether installed locally or globally) should always be invoked with dotnet prefixing it, indicating (whether its local or global) that this is trying to use a tool that comes from the dotnet install step, therefore using the current CLR. Otherwise, wouldn't all tools need to be packaged as standalones (maybe not ideal)?

Potential issue
If I upgrade (say from 2.0.0 to 3.0.0) should I expect the tools I installed when I had 2.0.0 to still work when I try to run them? In most cases with npm/node upgrades, this does work.

@John0King
Copy link
Author

My personal opinion : when install a tool globally, dotnet should publish a Self-Contained app , so when you update/remove the dotnet cli or clear the packages cache ,those tools still can work .

@ricky-hartmann-zocdoc
Copy link

Yea, the more I'm thinking about it, self contained would be nice after an upgrade of the cli/runtime

@Ghasan
Copy link

Ghasan commented Oct 13, 2017

.NET Standard is backward compatible, so it is safe to assume that it will work. I don't think it is a good idea to package a small tool to a size of 100mb+ just to make it standalone. And I am more inclined into tools being accessible from the terminal directly, with no need for 'dotnet tool'. Just like how we use npm tools.

In case of breaking changes, there should be enough time given for authors to upgrade their tools.

@tmds
Copy link
Member

tmds commented Oct 13, 2017

If I upgrade (say from 2.0.0 to 3.0.0) should I expect the tools I installed when I had 2.0.0 to still work when I try to run them?

3.0 can be side-by-side installed to 2.0. If you uninstall 2.0, the tool will give a message it doesn't find the appropriate runtime.
For 1.x, the versioning policy did not allow a 1.1 runtime to execute a 1.0 application. Fortunately, for 2.x this has changed. An application for 2.x will run on all runtimes 2.y (y>=x).

dotnet should publish a Self-Contained app
self contained would be nice after an upgrade of the cli/runtime

Considering runtimes can be installed side-by-side, tools should be published as framework dependent applications. This means they have a dependency on a runtime (e.g. .NET Core 2.x) but not a dependency on a specific platform (e.g. linux-x64).

@John0King
Copy link
Author

John0King commented Oct 13, 2017

@Ghasan @tmds Framework dependent applications will be great only if the tools only serve for development .
Self-Contained app will be great for other daily work, for example: bundl and minify js css file, thing's like bower, processing images . those work don't require you to update .net core SDK/Runtime , and will not be effect if you clean up package cache.

and probably easier to implement : create a new project and reference the tools as a PackageReference , and then publish, the project's as a proxy to call the tools Main , and by that we can rename the tools name to a short name

@tmds
Copy link
Member

tmds commented Oct 13, 2017

@John0King I don't see at what point a self-contained application would be created.
If I do dotnet install GreatTool. self-contained means I get a linux-x64 app on Linux, a win-x64 app on Windows and an osx-64 app on Mac.

This would be the framework dependent way:
Suppose GreatTool is published as a framework dependent application on NuGet.
When a user does dotnet install GreatTool, dotnet will look at nuget.org and see what versions are available. If the latest version supports a runtime I have install it, dotnet will install the package. Otherwise dotnet will suggest to install a compatible runtime and provide a list of older versions of the package which are compatible with the runtimes I have installed.

@John0King
Copy link
Author

tools should be published as framework dependent applications

Do you mean publish to Nuget as framework dependent application (platform irrelevant app) ? If you do, I will agree with you. Self-contained publish process should only happen when you install it.

@tmds
Copy link
Member

tmds commented Oct 13, 2017

Self-contained publish process should only happen when you install it.

The publish process for a self-contained application starts from the application source code. It doesn't start from a published framework-dependent application.
Self-containing the application means adding a runtime for the install platform. Instead of adding the runtime to the application, it makes more sense to require the runtime to be installed on the machine. Then all application can share the runtime and it gets patched.

@John0King
Copy link
Author

John0King commented Oct 13, 2017

default
@tmds this is a demo that I manual publish with self-contained publish

project file:

<PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp2.0</TargetFramework>
    <RuntimeIdentifier>win7-x64</RuntimeIdentifier>
    <AssemblyName>CLITools</AssemblyName>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.Extensions.SecretManager.Tools" Version="2.0.0" />
  </ItemGroup>

Program.cs

        public static void Main(string[] args)
        {
            Microsoft.Extensions.SecretManager.Tools.Program.Main(args);
        }

add the folder to Path environment variable then it's done.

this is the most easy way , and can change the long name to a short name (without the dotnet- prefix). unfortunately it doesn't work if the tools do not have a public entry point.
I think even without the extra project , it still can publish a self-contained application, because tools can be restore (I saw it in vs output window) , and then copy all the necessary file ( runtime,dotnet.exe,and nuget dependency) to the tools folder, rename dotnet.exe and <toolsname>.dll to <new-tools-name>.exe/.dll , final step: create the <new-tools-name>.deps.json .

@tmds
Copy link
Member

tmds commented Oct 13, 2017

Aha. You are suggesting that the way to make the FDD NuGet package callable via a short name is to create and publish a SCD that calls the FDD.
I leave it up to the people doing the implementation to figure out the proper way to do this.

So, we both think tools should be published to NuGet as FDD. That was what I was talking about.

@tmds
Copy link
Member

tmds commented Jan 23, 2018

@tonerdo implemented this feature as a cli extension: https://github.com/tonerdo/dotget

@livarcocc
Copy link
Contributor

This is actually being implemented in the CLI directly as well, as global tools. The install tool and pack tool experience just made in to the CLI available from our nightlies at the main branch.

@tmds
Copy link
Member

tmds commented Jan 23, 2018

@livarcocc is this 2.1 milestone or 2.2?

@dasMulli
Copy link
Contributor

dasMulli commented Jan 23, 2018

Just finished a blog post on how to create & use tool packages for dotnet install tool:
https://dasmulli.blog/2018/01/23/exploring-global-net-core-tools/

https://twitter.com/dasmulli/status/955853684876996608

@livarcocc
Copy link
Contributor

It will be 2.1 of .NET Core. 2.1.3xx of the CLI.

@johnkors
Copy link

@livarcocc Should ~/.dotnet/tools be automatically added to path on macOS using the latest 2.1.3xx installer?

@livarcocc
Copy link
Contributor

cc @wli3

@wli3
Copy link

wli3 commented Jan 24, 2018

@johnkors

Should ~/.dotnet/tools be automatically added to path on macOS using the latest 2.1.3xx installer?

Yes, it is automatically added to path on macOS using the installer.

@wli3
Copy link

wli3 commented Jan 24, 2018

issue on dotnet-x not working on mac https://github.com/dotnet/cli/issues/8450

@John0King
Copy link
Author

@livarcocc
Will those tools run after dotnet nuget locals global-packages --clear ?

@wli3
Copy link

wli3 commented Jan 24, 2018

Yes, they will still run. Tools asset is stored in a different place.

@johnkors
Copy link

@wli3 , ok on macOS I had to manually add ~/.dotnet/tools to PATH. I tried re-launching the terminal as well.

@dasMulli
Copy link
Contributor

@johnkors you don’t happen to use zsh with oh-my-zsh?
That one pins the path on install and macOS’ own path helper no longer works..

@johnkors
Copy link

Yeah, I'm using zsh. Makes sense. Thanks, @dasMulli !

@wli3
Copy link

wli3 commented Jan 24, 2018

@johnkors @dasMulli I added an issue on different shell support on mac. https://github.com/dotnet/cli/issues/8466 suggestions are welcome

@BrunoJuchli
Copy link
Contributor

Will this also cover use cases such as installing a test runner?
Will it support installing different versions of that tool side-by-side?
Will a solution/project be able to specify a dependency on a tool (& -version)?

@wli3
Copy link

wli3 commented Mar 7, 2018

Will this also cover use cases such as installing a test runner?
Will it support installing different versions of that tool side-by-side?
Will a solution/project be able to specify a dependency on a tool (& -version)?

As plan for 2.1.300 all the answers are no

@BrunoJuchli
Copy link
Contributor

BrunoJuchli commented Mar 7, 2018

@wli3
Thanks for the clarification.

@rohit21agrawal
In that case I'd like to note that the comment in NuGet/Home#1521

Dotnet tools (available with 15.7 shortly) will bridge this gap.
dotnet/cli#5147

is inaccurate as there's still going to be a lot of use cases missing that have been possible with solution level packages.

@John0King
Copy link
Author

may be create a new tool dotnet-dnx as a default global tool . use dnx tool-name to find and excute tool in project file's <CliToolsReference /> , and tools assert are just normal nuget packages (has version) just like current tools , and dnx without toolname can be use for C# interactive (like in visual studio)

@dasMulli
Copy link
Contributor

dasMulli commented Mar 8, 2018

I've heard people ask offline for a "pull and execute" 1-step tool invoke command that - like docker run or npx will fetch the "thing" automatically and then use it, so a dotnet run tool xunit (or something shorter, my naming skills don't seem to improve) could be an alias for dotnet install tool -g xunit && dotnet xunit [other args].
Wondering if more ppl are interested in this.

@johnkors
Copy link

johnkors commented Mar 8, 2018

AFAIK, dotnet build does a dotnet restore unlesss you opt out, so @dasMulli s proposal would at least make it follow that pattern.

@livarcocc
Copy link
Contributor

We have now implemented our global tools feature through dotnet tool install (formerly dotnet install tool).

It has a local tool version (through --tool-path instead of --global) along with uninstall, list and update.

As such, I am going to close this issue. If there are specific feature requests around the feature we have built in 2.1.300, I would suggest filling new separate issues for those asks.

@msftgits msftgits transferred this issue from dotnet/cli Jan 31, 2020
@msftgits msftgits added this to the 2.1.3xx milestone Jan 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests