-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support for install tool with prerelease flag
- Loading branch information
William Li
committed
Aug 11, 2021
1 parent
f27cb45
commit 8cedad2
Showing
11 changed files
with
291 additions
and
26 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
src/Cli/dotnet/commands/dotnet-tool/install/ParseResultExtension.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// 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 (prerelease) | ||
{ | ||
packageVersion = (packageVersion ?? "") + "*-*"; | ||
} | ||
|
||
VersionRange versionRange = null; | ||
if (!string.IsNullOrEmpty(packageVersion) && !VersionRange.TryParse(packageVersion, out versionRange)) | ||
{ | ||
throw new GracefulException( | ||
string.Format( | ||
LocalizableStrings.InvalidNuGetVersionRange, | ||
packageVersion)); | ||
} | ||
|
||
return versionRange; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.