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

support --prerelease for dotnet tool #19646

Merged
merged 1 commit into from
Aug 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -229,4 +229,7 @@ If you would like to create a manifest, use `dotnet new tool-manifest`, usually
<data name="InvalidRuntimeIdentifier" xml:space="preserve">
<value>The runtime identifier {0} is invalid. Valid runtime identifiers are: {1}.</value>
</data>
</root>
<data name="PrereleaseAndVersionAreNotSupportedAtTheSameTime" xml:space="preserve">
<value>The --prerelease and --version options are not supported in the same command</value>
</data>
</root>
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System.CommandLine.Parsing;
using Microsoft.DotNet.Cli;
using Microsoft.DotNet.Cli.Utils;
using NuGet.Versioning;

namespace Microsoft.DotNet.Tools.Tool.Install
{
internal static class ParseResultExtension
{
public static VersionRange GetVersionRange(this ParseResult parseResult)
{
string packageVersion = parseResult.ValueForOption<string>(ToolInstallCommandParser.VersionOption);
bool prerelease = parseResult.ValueForOption<bool>(ToolInstallCommandParser.PrereleaseOption);

if (!string.IsNullOrEmpty(packageVersion) && prerelease)
{
throw new GracefulException(
string.Format(
LocalizableStrings.PrereleaseAndVersionAreNotSupportedAtTheSameTime,
packageVersion));
}

if (prerelease)
{
packageVersion = "*-*";
}

VersionRange versionRange = null;
if (!string.IsNullOrEmpty(packageVersion) && !VersionRange.TryParse(packageVersion, out versionRange))
{
throw new GracefulException(
string.Format(
LocalizableStrings.InvalidNuGetVersionRange,
packageVersion));
}

return versionRange;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ internal static class ToolInstallCommandParser
ArgumentHelpName = LocalizableStrings.FrameworkOptionName
};

public static readonly Option<bool> PrereleaseOption = ToolSearchCommandParser.PrereleaseOption;

public static readonly Option<VerbosityOptions> VerbosityOption = CommonOptions.VerbosityOption();

// Don't use the common options version as we don't want this to be a forwarded option
Expand All @@ -54,6 +56,7 @@ public static Command GetCommand()
command.AddOption(ToolAppliedOption.ToolManifestOption(LocalizableStrings.ManifestPathOptionDescription, LocalizableStrings.ManifestPathOptionName));
command.AddOption(AddSourceOption);
command.AddOption(FrameworkOption);
command.AddOption(PrereleaseOption);
command.AddOption(ToolCommandRestorePassThroughOptions.DisableParallelOption);
command.AddOption(ToolCommandRestorePassThroughOptions.IgnoreFailedSourcesOption);
command.AddOption(ToolCommandRestorePassThroughOptions.NoCacheOption);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,7 @@ public override int Execute()
Path.GetFullPath(_configFilePath)));
}

VersionRange versionRange = null;
if (!string.IsNullOrEmpty(_packageVersion) && !VersionRange.TryParse(_packageVersion, out versionRange))
{
throw new GracefulException(
string.Format(
LocalizableStrings.InvalidNuGetVersionRange,
_packageVersion));
}
VersionRange versionRange = _parseResult.GetVersionRange();

DirectoryPath? toolPath = null;
if (!string.IsNullOrEmpty(_toolPath))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ namespace Microsoft.DotNet.Tools.Tool.Install
{
internal class ToolInstallLocalInstaller
{
private readonly ParseResult _parseResult;
public string TargetFrameworkToInstall { get; private set; }

private readonly IToolPackageInstaller _toolPackageInstaller;
Expand All @@ -27,6 +28,7 @@ public ToolInstallLocalInstaller(
ParseResult parseResult,
IToolPackageInstaller toolPackageInstaller = null)
{
_parseResult = parseResult;
_packageId = new PackageId(parseResult.ValueForArgument<string>(ToolInstallCommandParser.PackageIdArgument));
_packageVersion = parseResult.ValueForOption<string>(ToolInstallCommandParser.VersionOption);
_configFilePath = parseResult.ValueForOption<string>(ToolInstallCommandParser.ConfigOption);
Expand Down Expand Up @@ -60,14 +62,7 @@ public IToolPackage Install(FilePath manifestFile)
Path.GetFullPath(_configFilePath)));
}

VersionRange versionRange = null;
if (!string.IsNullOrEmpty(_packageVersion) && !VersionRange.TryParse(_packageVersion, out versionRange))
{
throw new GracefulException(
string.Format(
LocalizableStrings.InvalidNuGetVersionRange,
_packageVersion));
}
VersionRange versionRange = _parseResult.GetVersionRange();

FilePath? configFile = null;
if (!string.IsNullOrEmpty(_configFilePath))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ Pokud chcete vytvořit manifest, použijte příkaz dotnet new tool-manifest, ob
<target state="translated">Cílová architektura, pro kterou se má nástroj nainstalovat</target>
<note />
</trans-unit>
<trans-unit id="PrereleaseAndVersionAreNotSupportedAtTheSameTime">
<source>The --prerelease and --version options are not supported in the same command</source>
<target state="new">The --prerelease and --version options are not supported in the same command</target>
<note />
</trans-unit>
<trans-unit id="VersionOptionDescription">
<source>The version of the tool package to install.</source>
<target state="translated">Verze balíčku nástroje, který se má nainstalovat</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ Wenn Sie ein Manifest erstellen möchten, verwenden Sie "dotnet new tool-manifes
<target state="translated">Das Zielframework, für das das Tool installiert wird.</target>
<note />
</trans-unit>
<trans-unit id="PrereleaseAndVersionAreNotSupportedAtTheSameTime">
<source>The --prerelease and --version options are not supported in the same command</source>
<target state="new">The --prerelease and --version options are not supported in the same command</target>
<note />
</trans-unit>
<trans-unit id="VersionOptionDescription">
<source>The version of the tool package to install.</source>
<target state="translated">Die Version des zu installierenden Toolpakets.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ Si desea crear un manifiesto, utilice "dotnet new tool-manifest", normalmente en
<target state="translated">La plataforma de destino para la que se instala la herramienta.</target>
<note />
</trans-unit>
<trans-unit id="PrereleaseAndVersionAreNotSupportedAtTheSameTime">
<source>The --prerelease and --version options are not supported in the same command</source>
<target state="new">The --prerelease and --version options are not supported in the same command</target>
<note />
</trans-unit>
<trans-unit id="VersionOptionDescription">
<source>The version of the tool package to install.</source>
<target state="translated">La versión del paquete de herramientas para instalar.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ Si vous souhaitez créer un manifeste, utilisez 'dotnet new tool-manifest', gén
<target state="translated">Framework cible pour lequel l'outil doit être installé.</target>
<note />
</trans-unit>
<trans-unit id="PrereleaseAndVersionAreNotSupportedAtTheSameTime">
<source>The --prerelease and --version options are not supported in the same command</source>
<target state="new">The --prerelease and --version options are not supported in the same command</target>
<note />
</trans-unit>
<trans-unit id="VersionOptionDescription">
<source>The version of the tool package to install.</source>
<target state="translated">Version du package d'outils à installer.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ Se si vuole creare un manifesto, usare `dotnet new tool-manifest`, in genere nel
<target state="translated">Framework di destinazione per cui installare lo strumento.</target>
<note />
</trans-unit>
<trans-unit id="PrereleaseAndVersionAreNotSupportedAtTheSameTime">
<source>The --prerelease and --version options are not supported in the same command</source>
<target state="new">The --prerelease and --version options are not supported in the same command</target>
<note />
</trans-unit>
<trans-unit id="VersionOptionDescription">
<source>The version of the tool package to install.</source>
<target state="translated">Versione del pacchetto dello strumento da installare.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ If you would like to create a manifest, use `dotnet new tool-manifest`, usually
<target state="translated">ツールをインストールするターゲット フレームワーク。</target>
<note />
</trans-unit>
<trans-unit id="PrereleaseAndVersionAreNotSupportedAtTheSameTime">
<source>The --prerelease and --version options are not supported in the same command</source>
<target state="new">The --prerelease and --version options are not supported in the same command</target>
<note />
</trans-unit>
<trans-unit id="VersionOptionDescription">
<source>The version of the tool package to install.</source>
<target state="translated">インストールするツール パッケージのバージョン。</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ If you would like to create a manifest, use `dotnet new tool-manifest`, usually
<target state="translated">도구를 설치할 대상 프레임워크입니다.</target>
<note />
</trans-unit>
<trans-unit id="PrereleaseAndVersionAreNotSupportedAtTheSameTime">
<source>The --prerelease and --version options are not supported in the same command</source>
<target state="new">The --prerelease and --version options are not supported in the same command</target>
<note />
</trans-unit>
<trans-unit id="VersionOptionDescription">
<source>The version of the tool package to install.</source>
<target state="translated">설치할 도구 패키지 버전입니다.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ Jeśli chcesz utworzyć manifest, użyj polecenia „dotnet new tool-manifest”
<target state="translated">Docelowa platforma, dla której ma zostać zainstalowane narzędzie.</target>
<note />
</trans-unit>
<trans-unit id="PrereleaseAndVersionAreNotSupportedAtTheSameTime">
<source>The --prerelease and --version options are not supported in the same command</source>
<target state="new">The --prerelease and --version options are not supported in the same command</target>
<note />
</trans-unit>
<trans-unit id="VersionOptionDescription">
<source>The version of the tool package to install.</source>
<target state="translated">Wersja pakietu narzędzia do zainstalowania.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ Se quiser criar um manifesto, use `dotnet new tool-manifest`, normalmente no dir
<target state="translated">A estrutura de destino para a qual instalar a ferramenta.</target>
<note />
</trans-unit>
<trans-unit id="PrereleaseAndVersionAreNotSupportedAtTheSameTime">
<source>The --prerelease and --version options are not supported in the same command</source>
<target state="new">The --prerelease and --version options are not supported in the same command</target>
<note />
</trans-unit>
<trans-unit id="VersionOptionDescription">
<source>The version of the tool package to install.</source>
<target state="translated">A versão do pacote da ferramenta a ser instalada.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ If you would like to create a manifest, use `dotnet new tool-manifest`, usually
<target state="translated">Целевая платформа для установки инструмента.</target>
<note />
</trans-unit>
<trans-unit id="PrereleaseAndVersionAreNotSupportedAtTheSameTime">
<source>The --prerelease and --version options are not supported in the same command</source>
<target state="new">The --prerelease and --version options are not supported in the same command</target>
<note />
</trans-unit>
<trans-unit id="VersionOptionDescription">
<source>The version of the tool package to install.</source>
<target state="translated">Версия устанавливаемого пакета инструмента.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ Bir bildirim oluşturmak istiyorsanız 'dotnet new tool-manifest' ifadesini kull
<target state="translated">Aracın yükleneceği hedef çerçeve.</target>
<note />
</trans-unit>
<trans-unit id="PrereleaseAndVersionAreNotSupportedAtTheSameTime">
<source>The --prerelease and --version options are not supported in the same command</source>
<target state="new">The --prerelease and --version options are not supported in the same command</target>
<note />
</trans-unit>
<trans-unit id="VersionOptionDescription">
<source>The version of the tool package to install.</source>
<target state="translated">Yüklenecek araç paketinin sürümü.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ If you would like to create a manifest, use `dotnet new tool-manifest`, usually
<target state="translated">要安装工具的目标框架。</target>
<note />
</trans-unit>
<trans-unit id="PrereleaseAndVersionAreNotSupportedAtTheSameTime">
<source>The --prerelease and --version options are not supported in the same command</source>
<target state="new">The --prerelease and --version options are not supported in the same command</target>
<note />
</trans-unit>
<trans-unit id="VersionOptionDescription">
<source>The version of the tool package to install.</source>
<target state="translated">要安装的工具包版本。</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ If you would like to create a manifest, use `dotnet new tool-manifest`, usually
<target state="translated">要為工具安裝的目標 Framework。</target>
<note />
</trans-unit>
<trans-unit id="PrereleaseAndVersionAreNotSupportedAtTheSameTime">
<source>The --prerelease and --version options are not supported in the same command</source>
<target state="new">The --prerelease and --version options are not supported in the same command</target>
<note />
</trans-unit>
<trans-unit id="VersionOptionDescription">
<source>The version of the tool package to install.</source>
<target state="translated">要安裝之工具套件的版本。</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ internal static class ToolUpdateCommandParser

public static readonly Option<string> ToolManifestOption = ToolAppliedOption.ToolManifestOption(LocalizableStrings.ManifestPathOptionDescription, LocalizableStrings.ManifestPathOptionName);

public static readonly Option<bool> PrereleaseOption = ToolSearchCommandParser.PrereleaseOption;

public static readonly Option<VerbosityOptions> VerbosityOption = ToolInstallCommandParser.VerbosityOption;

public static Command GetCommand()
Expand All @@ -42,6 +44,7 @@ public static Command GetCommand()
command.AddOption(FrameworkOption);
command.AddOption(VersionOption);
command.AddOption(ToolManifestOption);
command.AddOption(PrereleaseOption);
command.AddOption(ToolCommandRestorePassThroughOptions.DisableParallelOption);
command.AddOption(ToolCommandRestorePassThroughOptions.IgnoreFailedSourcesOption);
command.AddOption(ToolCommandRestorePassThroughOptions.NoCacheOption);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,7 @@ public override int Execute()
toolPath = new DirectoryPath(_toolPath);
}

VersionRange versionRange = null;
if (!string.IsNullOrEmpty(_packageVersion) && !VersionRange.TryParse(_packageVersion, out versionRange))
{
throw new GracefulException(
string.Format(
LocalizableStrings.InvalidNuGetVersionRange,
_packageVersion));
}
VersionRange versionRange = _parseResult.GetVersionRange();

(IToolPackageStore toolPackageStore,
IToolPackageStoreQuery toolPackageStoreQuery,
Expand Down
Loading