Skip to content

Global tools - Part 1 #5036

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

Merged
merged 12 commits into from
May 30, 2018
Merged

Global tools - Part 1 #5036

merged 12 commits into from
May 30, 2018

Conversation

mairaw
Copy link
Contributor

@mairaw mairaw commented Apr 26, 2018

Related to #4627 and #4509

@KathleenDollard I've used your gist to get this started but I think there's more work to do here. But see if this looks good for a first version, so we can have some docs out.

Internal review URLs:
dotnet tool install
dotnet tool uninstall
dotnet tool update
dotnet tool list
Global Tools

@mairaw mairaw added the P0 label Apr 26, 2018

`-f|--framework <FRAMEWORK>`

Specifies the [target framework](../../standard/frameworks.md) to install the tool for.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when does someone need to specify this @KathleenDollard?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, not until a breaking runtime came out.

Producers can construct packages targeting multiple TFMs, say, a single package with a tool for netcoreapp2.1 and netcoreappVNEXT. Or even produce a package with a TFM different from the one used in the CLI.

The CLI utilize NuGet to pick the fittest TFM. The CLI has the notion of a bundled TFM, which indicates the TFM that the CLI itself targets. CLI will always pass that TFM to NuGet and NuGet will write asset file with filtered TFM. CLI does not prob the disk, instead it finds asset by reading the asset file.

This approach does not work when the tool is packaged with netcoreapp and say net46, because the CLI will always pick the netcoreapp TFM. In order to work around this, the consumer will have to provide the TFM to install the command. Note that this should not be a problem if the package contains only the net46 TFM.

Also, when the user has the 2.1 CLI installed and then installs the 2.1 runtime, the 2.1 version of the tool will continue to be selected, as that’s the CLI bundled version. But the user can obtain the netcoreapp3.0 version of tool by specifying TFM in the command line. Again using the escape hatch we defined above. We use the TFM bundled version because it has the highest likelihood of succeeding, since that tool will target the runtime that the CLI itself is using to run.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wli3 Shall we add something like

"For .NET Core 2.1 this switch is rarely needed."

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wli3 @KathleenDollard

Ok, I understand the concept that inside the package, you can have multiple TFMs supported and by specifying this, you can effectively select one. But it would be good to add to the command description, some concise explanation of why you might need to specify this. the netcoreapp and other TFMs, for example, seems like a good scenario. Or maybe an explanation that CLI will try to choose the best TFM for you, so you rarely need this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whatcha' think about this:

While most Global Tools are not framework specific, framework specific tools are supported. If a framework is specified, it is used to select the correct version of the tool. If a framework is not specified, the framework of the currently running .NET SDK is used.

The framework is specified via its TFM, which you can find here.

In most cases, you do not need the --framework switch.

Copy link

@wli3 wli3 Apr 27, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"While most Global Tools are not framework specific, framework specific tools are supported"

This is kind of wrong. All tools are TFM specific. But you can multi target. And we only support netcoreapp2.1. Maybe

"SDK will try to choose most appropriate TFM by default . However, this can be overwritten by this flag""


`--version <VERSION_NUMBER>`

The version of the tool to install. By default, the latest stable package version is installed.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add something like

"Use the --version switch to install preview versions."

Copy link
Member

@BillWagner BillWagner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I read through everything this morning, and had a few comments.

Let me know when you are ready for a final review.


`PACKAGE_ID`

ID of the NuGet package that contains the .NET Core Global tool to install.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it worth mentioning that the PACKAGE_ID is the same as the package name?

Copy link
Contributor Author

@mairaw mairaw Apr 26, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was actually thinking if I should use PACKAGE_NAME instead. PACKAGE_ID is what shows up in --help. We already use PACKAGE_NAME in the NuGet commands. So I think it's better to switch and then I'll switch on --help when I finally have a chance to review the strings and all.


`-g|--global`

Specifies that the tool to be removed is from a user-wide installation. If you don't specify this option, you must specify the `--tool-path` option.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy and paste error: List doesn't remove a tool, does it?

Copy link
Contributor Author

@mairaw mairaw Apr 26, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, copy and paste error 😢


* Find information about the tool (usually a website or GitHub page).
* Check the author and statistics in the home for the feed (usually NuGet.org).
* Install the tool.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uninstall is also an option, right?


Installs version 1.0.0 of the [dotnetsay](https://www.nuget.org/packages/dotnetsay/) sample Global Tool:

`dotnet tool install -g dotnetsay --version 1.0.0`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change to 2.0.0 since 1.0.0 is broken due to Preview 2 changes.


`-g|--global`

Specifies that the tool to be removed is from a user-wide installation. If you don't specify this option, you must specify the `--tool-path` option.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove "to be removed". Something like:

"Specifies that the list be from the user-wide installation....


`--tool-path <PATH>`

Specifies a custom location where to find global tools. PATH can be absolute or relative. Can't be combined with the `--global` option.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Parallel the -g text.

Also: If this isn't specified, the -g switch should be

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, --g required if this isn't included.


`--tool-path <PATH>`

Specifies the location where to install the global tool. PATH can be absolute or relative. If PATH doesn't exist, the command tries to create it. Can't be combined with the `--global` option.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps

"If you don't specify this option, you must specify the --global option.


## Examples

Installs the [dotnetsay](https://www.nuget.org/packages/dotnetsay/) sample Global Tool:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add similar to

"in the default location"


`PACKAGE_ID`

ID of the NuGet package that contains the .NET Core Global tool to uninstall.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add

"You can find the package ID using the dotnet tool list command.


`--tool-path <PATH>`

Specifies the location where to uninstall the global tool. PATH can be absolute or relative. Can't be combined with the `--global` option.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do same as in other commands regarding -g required if this not used.


`PACKAGE_ID`

ID of the NuGet package that contains the .NET Core Global tool to update.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps: Consistent with uninstall, suggest list to find package ID


`--tool-path <PATH>`

Specifies the location where the global tool is installed. PATH can be absolute or relative. Can't be combined with the `--global` option.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consistent with others, if you don't include -g required

Copy link
Contributor

@KathleenDollard KathleenDollard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We aren't consistent with how we cap "global tools" in different parts. I didn't help within the body of my comments.

I've followed Rich's lead and caps, but if the standard for docs is lower case, I have no problem with that. Might loop in @richlander on that.


You can find .NET Core Global Tools on [NuGet](https://www.nuget.org). However, NuGet doesn't yet allow you to search specifically for .NET Core Global Tools.

You may also find tool recommendations in blog posts.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we include an external link here. Nate McMaster has compiled a list.

https://github.com/natemcmaster/dotnet-tools


## Check the author and statistics

Since .NET Core Global Tools run in full trust and are installed on your path, they can be very powerful. Don't download tools from people you don't trust.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"are generally installed...

If the tool is hosted on NuGet, you can check the author and statistics by searching for the tool.

## Install a global tool

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either here or at the end of the section let's talk about location. This a suggestion for this location, but I'm not sure whether this is best here or somewhat different text at the end.

"Global tools can be installed in the default directory or in a specific location. The default directories are:

OS Path
Linux/macOS $HOME/.dotnet/tools
Windows %USERPROFILE%\.dotnet\tools

These locations are added to the user's path when the SDK is first run, so global tools installed there can be called directly.

Global tools can also be installed in a specific directory. When installed in a specific directory, the user must ensure the command is available, by including that directory in the path, by calling the command with the directory specified, or calling the tool from within the specified directory.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this info was missing and I was adding something to that extent. Went with your suggestion.


## Install a global tool

To install a global tool, you use the [dotnet tool install](dotnet-tool-install.md) .NET Core CLI command like in the following example:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"tool in the default directory, you use


Once the tool is installed, you can call it by using its command. Note that the command may not be the same as the package name.

If the command is `dotnetsay`, you call it with:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some variation of

", and it was installed with the --global switch, you

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well, whether it's global or not, you'd still use the same command no? you just might have to specify the path depending on where you are

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, I'm fine leaving this as is.

```

You can find which tools are included in an installed Global Tool package by listing the installed packages.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dotnet tool list -g


* An application rolls forward to the highest patch release of the specified major and minor version.
* If there is no matching runtime with a matching major and minor version number, the next higher minor version is used.
* Roll forward doesn't occur between preview versions of the runtime or between preview versions and release versions.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Thus, Global Tools created during the preview must be rebuilt and republished by the author and reinstalled.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

```

Contact the author of the Global Tool and see if they can recompile and republish their tool package to NuGet with an updated version number. Once they have updated the package on NuGet, you can update your copy.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a special problem with Preview 1 tools. They must be manually uninstalled, and will give errors if you try to update. It is especially ugly because you can git "doesn't exist" on uninstall and "can't install cause it exists" on install.

The fix is in the release notes, but since it's so nasty, do we need something here as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm adding a warning. You might eventually be able to remove it after we're past RTM.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't quite right. I added a note elsewhere that we probably want this warning in uninstall and update. Probably also here.

Uninstall fails and you must go to the directories to delete
Therefore Update fails

"If you installed Global Tools that were built with .NET Core 2.1 Preview 1 release, there's a known issue where you must manually uninstall these tools. Neither uninstall or update will work. For information on removing Preview 1 global tools, see .NET Core 2.1 Preview 2 Known Issues.

@mairaw
Copy link
Contributor Author

mairaw commented Apr 27, 2018

I've addressed all the feedback and added some additional info from @natemcmaster's blog post. Let m,e know if you see anything wrong with my changes.

/cc @KathleenDollard

@mairaw
Copy link
Contributor Author

mairaw commented Apr 27, 2018

@BillWagner I think this is ready for a final review. There's more work to be done in the future.

@KathleenDollard
Copy link
Contributor

KathleenDollard commented Apr 27, 2018 via email

Copy link
Contributor

@KathleenDollard KathleenDollard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found a few more things.


## Name

`dotnet tool list` - Lists all [.NET Core Global Tools](global-tools.md) currently installed on your machine or specified path.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Current text could be read: All global tools installed anywhere on your machine.

"currently installed in the default directory on your machine or specified path.


## Description

The `dotnet tool list` command provides a way for you to list all .NET Core Global Tools installed on your machine (current user profile) or specified path. The command lists the package name, version installed, and the global tool command. To use the list command, you either have to specify that you want to see all user-wide tools using the `--global` option or specify a custom path using the `--tool-path` option.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same problem as above. Alternative resolution:

"list all .NET Core Global Tools installed user-wide on your machine (current user profile) or in the specified path


## Examples

Lists all Global Tools installed in your machine (current user profile):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same problem. Suggest

"installed user-wide on


`dotnet tool list -g`

Lists the sample Global Tools from a specific Windows folder:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Drop "sample"


## Examples

Uninstalls the [dotnetsay](https://www.nuget.org/packages/dotnetsay/) sample Global Tool:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe drop "sample" here and below


## Examples

Updates the [dotnetsay](https://www.nuget.org/packages/dotnetsay/) sample Global Tool:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe drop "sample" here and below


Once the tool is installed, you can call it by using its command. Note that the command may not be the same as the package name.

If the command is `dotnetsay`, you call it with:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, I'm fine leaving this as is.

`--tool-path <PATH>`

Specifies the location where to uninstall the global tool. PATH can be absolute or relative. Can't be combined with the `--global` option. If you don't specify this option, you must specify the `--global` option.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably add a warning about uninstall not working on Preview 1 tools. Let's get the other warning right and then see what should go here. Similar warning should probably go in update.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that we're only shipping these docs now and we don't usually cover preview issues on those unless it's the current functionality, I'm not going to address this comment. But please let me know if you still feel this is needed.

```

Contact the author of the Global Tool and see if they can recompile and republish their tool package to NuGet with an updated version number. Once they have updated the package on NuGet, you can update your copy.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't quite right. I added a note elsewhere that we probably want this warning in uninstall and update. Probably also here.

Uninstall fails and you must go to the directories to delete
Therefore Update fails

"If you installed Global Tools that were built with .NET Core 2.1 Preview 1 release, there's a known issue where you must manually uninstall these tools. Neither uninstall or update will work. For information on removing Preview 1 global tools, see .NET Core 2.1 Preview 2 Known Issues.

@mairaw mairaw changed the title first draft of global tools WIP first draft of global tools Apr 27, 2018
@mairaw mairaw added the blocked Blocked for some reason label Apr 27, 2018
@mairaw
Copy link
Contributor Author

mairaw commented Apr 27, 2018

Sure @KathleenDollard, we can wait. Somehow I thought you wanted the link for the aka.ms/global-tools live ASAP. I was also wondering about the capitalization of Global Tools that you mentioned earlier. Did @richlander say anything?

@@ -0,0 +1,166 @@
---
title: .NET Core Global Tools
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question about naming (for @livarcocc @KathleenDollard). At one point, I remember us saying we wanted to call this feature ".NET Core tools" because 'global' is just one way to install the tool, but not the only one. Am I remembering right? Has the thinking changed? Or have we settled on calling this feature ".NET Core Global Tools"?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've had pretty universal stickiness on .NET Core Global Tools and I think we should let that ride to avoid confusion with a new feature. We can differentiate "Repo" (or "Project") tools if they behave differently.

Copy link
Contributor

@natemcmaster natemcmaster left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One minor suggestion, but otherwise this looks like a good start. I assume there will be a separate PR for docs on creating .NET Core tools,

If the tool author wanted the tool to appear in the context of the `dotnet` prompt, they may have written it in a way that you call it as `dotnet <command>`, such as:

```bash
dotnet ef
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This example doesn't exactly match with what you are describing. dotnet ef is now a built-in command. A better example of this would be dotnet serve or @spboyer's dotnet doc

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great catch. Let's use dotnet doc

@KathleenDollard
Copy link
Contributor

@mairaw We are changing --source-feed to --add-source and removing -f. Neither --framework or --add-source will have an abbreviation.

This implementation is still working its way through repos.

I think that finishes up my input on this version.

@natemcmaster yes there will be a separate doc for creation.

@ghost
Copy link

ghost commented May 2, 2018

Re --source-feed to --add-source, that pull request is now merged:
dotnet/cli#9164

@ghost
Copy link

ghost commented May 24, 2018

@KathleenDollard, could this move forward if the name was settled? I will then update manpages in cli repo so Unix like OS packages can get updated docs packed by RTM. Thanks!


[!INCLUDE [topic-appliesto-net-core-2-1plus.md](../../../includes/topic-appliesto-net-core-2-1plus.md)]

.NET Core Global Tools are a special NuGet package that contains a console application. A Global Tool can be installed on your machine on a default location that is specified in the PATH environment variable or on a custom location.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[…] Tools are a […] package that contains a […] application

I think the grammatical number here is not correct. I think it would make sense to put everything in singular:

A .NET Core Global Tool is a special NuGet package that contains a console application.


[!INCLUDE [topic-appliesto-net-core-2-1plus.md](../../../includes/topic-appliesto-net-core-2-1plus.md)]

.NET Core Global Tools are a special NuGet package that contains a console application. A Global Tool can be installed on your machine on a default location that is specified in the PATH environment variable or on a custom location.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A Global Tool can be installed on your machine on a default location that is specified in the PATH environment variable […]

This could be read as if PATH is used to specify where a Tool is installed. Maybe change it to:

A Global Tool can be installed on your machine on a default location that is included in the PATH environment variable […]

* Uninstall the tool.

> [!IMPORTANT]
> .NET Core Global Tools appear on your path and run in full trust. Do not install .NET Core Global Tools unless you trust the author.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's "full trust"? AFAIK, that's a .Net Framework concept that does not exist in .Net Core.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@KathleenDollard can you comment here? Can't recall if I got that from you or not. The way I read this is that the app would have access to everything on your computer include registry, log files, etc.


### What could go wrong

Global Tools are shared framework applications, which means they rely on a .NET Core runtime installed on your machine. If the expected runtime is not found, they follow normal .NET Core runtime roll-forward rules such as:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's a "shared framework application"? Do you mean "framework-dependent application"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe you're correct @svick. Also @KathleenDollard I've heard that we were having some confusion with the roll-forward terminology. Should we still use that here? /cc @nguerrera @johnbeisner

@mairaw mairaw changed the title WIP first draft of global tools Global tools - Part 1 May 30, 2018
@mairaw mairaw removed the blocked Blocked for some reason label May 30, 2018
@mairaw
Copy link
Contributor Author

mairaw commented May 30, 2018

@BillWagner @JRAlexander @rpetrusha can one of you review and approve this one?

@mairaw mairaw requested a review from rpetrusha as a code owner May 30, 2018 08:47
Copy link
Member

@BillWagner BillWagner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This LGTM. I'll fix the merge conflicts, and I'll :shipit:

@BillWagner BillWagner merged commit f694eae into dotnet:master May 30, 2018
@KathleenDollard
Copy link
Contributor

Yes, we can move this onward

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants