Merge branch 'master' into dev-ragrawal-updatenuget2484

This commit is contained in:
Livar 2017-04-26 16:35:18 -07:00 committed by GitHub
commit b4214c8b18
9 changed files with 97 additions and 16 deletions

View file

@ -0,0 +1,71 @@
# .NET CLI Tab Completion
In version 2.0 of the .NET Core CLI, we have added support for providing suggestions when you press `tab`. While it's not yet enabled by default, you can try it out today by installing a [preview build](https://github.com/dotnet/cli#installers-and-binaries) from the master branch or by building from source.
Here are some examples of what it provides:
Input | becomes | because
:------------------------------------|:----------------------------------------------------------------------------|:--------------------------------
`dotnet a⇥` | `dotnet add` | `add` is the first subcommand, alphabetically.
`dotnet add p⇥` | `dotnet add --help` | it matches substrings and `--help` comes first alphabetically.
`dotnet add p⇥⇥` | `dotnet add package` | pressing tab a second time brings up the next suggestion.
`dotnet add package Microsoft⇥` | `dotnet add package Microsoft.ApplicationInsights.Web` | results are returned alphabetically.
`dotnet remove reference ⇥` | `dotnet remove reference ..\..\src\OmniSharp.DotNet\OmniSharp.DotNet.csproj` | it is project file aware.
## How to enable it
Tab completion is currently supported in three shells: PowerShell, bash, and zsh. These scripts assume that `dotnet` v2.0 is on your path. You can verify that you have the correct version of `dotnet` on your path by trying out the new `complete` command directly:
```
[04/26/2017 11:38:20] C:\
> dotnet complete "dotnet add p"
```
If you just installed `dotnet` you may see the first-run output:
```
Welcome to .NET Core!
---------------------
Learn more about .NET Core @ https://aka.ms/dotnet-docs. Use dotnet --help to see available commands or go to https://aka.ms/dotnet-cli-docs.
Telemetry
--------------
The .NET Core tools collect usage data in order to improve your experience. The data is anonymous and does not include command-line arguments. The data is collected by Microsoft and shared with the community.
You can opt out of telemetry by setting a DOTNET_CLI_TELEMETRY_OPTOUT environment variable to 1 using your favorite shell.
You can read more about .NET Core tools telemetry @ https://aka.ms/dotnet-cli-telemetry.
Configuring...
-------------------
A command is running to initially populate your local package cache, to improve restore speed and enable offline access. This command will take up to a minute to complete and will only happen once.
Decompressing 100% 4936 ms
Expanding 100% 17195 ms
```
You should see the following ouput (perhaps coming at the end of the first-run output). This indicates that `dotnet` is resolving to a v2.0 installation that supports completion.
```
--help
package
```
### PowerShell
To enable tab completion in PowerShell, edit your PowerShell profile:
```
notepad $PROFILE
```
Add the contents of [register-completions.ps1](https://github.com/dotnet/cli/blob/master/scripts/register-completions.ps1) to this file and save.
### bash
To enable tab completion in bash, edit your `.bashrc` file to add the contents of [register-completions.bash](https://github.com/dotnet/cli/blob/master/scripts/register-completions.bash).
### zsh
To enable tab completion in zsh, edit your `.zshrc` file to add the contents of [register-completions.zsh](https://github.com/dotnet/cli/blob/master/scripts/register-completions.zsh).
## How it works
Each of these scripts provides a hook for completions for its respective shell. The logic that determines which suggestions to provide is in the CLI itself, configured using [our new parser](https://github.com/dotnet/CliCommandLineParser). You can see a code example [here](https://github.com/dotnet/cli/blob/master/src/dotnet/commands/dotnet-add/dotnet-add-package/AddPackageParser.cs#L23).

View file

@ -5,7 +5,7 @@
<clear />
<add key="templating" value="https://dotnet.myget.org/F/templating/api/v3/index.json" />
<add key="dotnet-core" value="https://dotnet.myget.org/F/dotnet-core/api/v3/index.json" />
<add key="aspnetcore-dev" value="https://dotnet.myget.org/F/aspnetcore-ci-dev/api/v3/index.json" />
<add key="aspnetcore-dev" value="https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json" />
<add key="websdkfeed" value="https://dotnet.myget.org/F/dotnet-web/api/v3/index.json" />
<add key="cli-deps" value="https://dotnet.myget.org/F/cli-deps/api/v3/index.json" />
<add key="roslyn" value="https://dotnet.myget.org/f/roslyn/api/v3/index.json" />

View file

@ -5,5 +5,7 @@
<TargetFramework>netcoreapp2.0</TargetFramework>
<OutputType>Exe</OutputType>
<RuntimeFrameworkVersion>$(CLI_SharedFrameworkVersion)</RuntimeFrameworkVersion>
<!-- Issue: https://github.com/dotnet/sdk/issues/1150 -->
<DisableImplicitPackageTargetFallback>true</DisableImplicitPackageTargetFallback>
</PropertyGroup>
</Project>

View file

@ -11,11 +11,11 @@
<SharedFrameworkVersion>$(CLI_SharedFrameworkVersion)</SharedFrameworkVersion>
<SharedHostVersion>$(CLI_SharedFrameworkVersion)</SharedHostVersion>
<HostFxrVersion>$(CLI_SharedFrameworkVersion)</HostFxrVersion>
<TemplateEngineVersion>1.0.0-beta2-20170421-198</TemplateEngineVersion>
<TemplateEngineTemplateVersion>1.0.0-beta2-20170421-198</TemplateEngineTemplateVersion>
<TemplateEngineTemplate2_0Version>1.0.0-beta2-20170421-198</TemplateEngineTemplate2_0Version>
<PlatformAbstractionsVersion>2.0.0-preview2-002081</PlatformAbstractionsVersion>
<DependencyModelVersion>2.0.0-preview2-002081</DependencyModelVersion>
<TemplateEngineVersion>1.0.0-beta2-20170425-201</TemplateEngineVersion>
<TemplateEngineTemplateVersion>1.0.0-beta2-20170425-203</TemplateEngineTemplateVersion>
<TemplateEngineTemplate2_0Version>1.0.0-beta2-20170425-203</TemplateEngineTemplate2_0Version>
<PlatformAbstractionsVersion>2.0.0-preview1-002088</PlatformAbstractionsVersion>
<DependencyModelVersion>2.0.0-preview1-002088</DependencyModelVersion>
<CliCommandLineParserVersion>0.1.0-alpha-142</CliCommandLineParserVersion>
</PropertyGroup>

View file

@ -63,6 +63,8 @@ Copyright (c) .NET Foundation. All rights reserved.
<WriteLinesToFile File="$(GeneratedMSBuildExtensionsDirectory)/$(BundledVersionsPropsFolder)/$(BundledVersionsPropsFileName)"
Lines="$(BundledVersionsPropsContent)"
Overwrite="true" />
<Copy
SourceFiles="$(GeneratedMSBuildExtensionsDirectory)/$(BundledVersionsPropsFolder)/$(BundledVersionsPropsFileName)"
DestinationFiles="$(SdkOutputDirectory)/$(BundledVersionsPropsFileName)" />
</Target>
</Project>

View file

@ -1,7 +1,7 @@
# PowerShell parameter completion shim for the dotnet CLI
Register-ArgumentCompleter -Native -CommandName dotnet -ScriptBlock {
param($commandName, $wordToComplete, $cursorPosition)
C:\dev\github\cli\artifacts\win10-x64\stage2\dotnet.exe complete --position $cursorPosition "$wordToComplete" | ForEach-Object {
dotnet complete --position $cursorPosition "$wordToComplete" | ForEach-Object {
[System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_)
}
}

View file

@ -185,5 +185,12 @@ namespace Microsoft.DotNet.Tools
public const string ProjectNotCompatibleWithFrameworks = "Project `{0}` cannot be added due to incompatible targeted frameworks between the two projects. Please review the project you are trying to add and verify that is compatible with the following targets:";
public const string ProjectDoesNotTargetFramework = "Project `{0}` does not target framework `{1}`.";
public const string ProjectCouldNotBeEvaluated = "Project `{0}` could not be evaluated. Evaluation failed with following error:\n{1}";
/// common options
public const string VerbosityOptionDescription = "Set the verbosity level of the command. Allowed values are q[uiet], m[inimal], n[ormal], d[etailed], and diag[nostic]";
public const string FrameworkOptionDescription = "Target framework to publish for. The target framework has to be specified in the project file.";
public const string RuntimeOptionDescription = "Publish the project for a given runtime. This is used when creating self-contained deployment. Default is to publish a framework-dependent app.";
public const string ConfigurationOptionDescription = "Configuration to use for building the project. Default for most projects is \"Debug\".";
public const string CmdVersionSuffixDescription = "Defines the value for the $(VersionSuffix) property in the project.";
}
}

View file

@ -3,6 +3,7 @@ using System.IO;
using System.Linq;
using Microsoft.DotNet.Cli.CommandLine;
using Microsoft.DotNet.Tools.Common;
using Microsoft.DotNet.Tools;
namespace Microsoft.DotNet.Cli
{
@ -18,7 +19,7 @@ namespace Microsoft.DotNet.Cli
public static Option VerbosityOption() =>
Create.Option(
"-v|--verbosity",
"Set the verbosity level of the command. Allowed values are q[uiet], m[inimal], n[ormal], d[etailed], and diag[nostic]",
CommonLocalizableStrings.VerbosityOptionDescription,
Accept.AnyOneOf(
"q", "quiet",
"m", "minimal",
@ -30,7 +31,7 @@ namespace Microsoft.DotNet.Cli
public static Option FrameworkOption() =>
Create.Option(
"-f|--framework",
"Target framework to publish for. The target framework has to be specified in the project file.",
CommonLocalizableStrings.FrameworkOptionDescription,
Accept.ExactlyOneArgument()
.WithSuggestionsFrom(_ => Suggest.TargetFrameworksFromProjectFile())
.With(name: "FRAMEWORK")
@ -39,7 +40,7 @@ namespace Microsoft.DotNet.Cli
public static Option RuntimeOption() =>
Create.Option(
"-r|--runtime",
"Publish the project for a given runtime. This is used when creating self-contained deployment. Default is to publish a framework-dependent app.",
CommonLocalizableStrings.RuntimeOptionDescription,
Accept.ExactlyOneArgument()
.WithSuggestionsFrom(_ => Suggest.RunTimesFromProjectFile())
.With(name: "RUNTIME_IDENTIFIER")
@ -47,8 +48,8 @@ namespace Microsoft.DotNet.Cli
public static Option ConfigurationOption() =>
Create.Option(
"-c|--configuration",
"Configuration to use for building the project. Default for most projects is \"Debug\".",
"-c|--configuration",
CommonLocalizableStrings.ConfigurationOptionDescription,
Accept.ExactlyOneArgument()
.With(name: "CONFIGURATION")
.WithSuggestionsFrom("DEBUG", "RELEASE")
@ -57,7 +58,7 @@ namespace Microsoft.DotNet.Cli
public static Option VersionSuffixOption() =>
Create.Option(
"--version-suffix",
"Defines the value for the $(VersionSuffix) property in the project.",
CommonLocalizableStrings.CmdVersionSuffixDescription,
Accept.ExactlyOneArgument()
.With(name: "VERSION_SUFFIX")
.ForwardAsSingle(o => $"/p:VersionSuffix={o.Arguments.Single()}"));

View file

@ -23,8 +23,6 @@ namespace Microsoft.DotNet.Tools.Restore
{
DebugHelper.HandleDebugSwitch(ref args);
Reporter.Output.WriteLine(string.Join(" ", args));
var parser = Parser.Instance;
var result = parser.ParseFrom("dotnet restore", args);