Repository navigation
Add dotnet sdk add and dotnet sdk remove commands #54577
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
Open
devlead
wants to merge
9
commits into
dotnet:main
Choose a base branch
from
devlead:feature/addRemoveSDK
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+3,260
−13
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
575838c
Add dotnet sdk add and dotnet sdk remove commands
devlead fa5c04a
Address PR feedback for dotnet sdk add/remove
devlead 4ce9445
Address PR feedback for dotnet sdk add/remove
devlead 9befb5c
Address PR feedback for dotnet sdk add parsing and global.json handling
devlead 9884ae9
Guard SDK identity parser against missing argument tokens
devlead ee1fd28
Address PR feedback for dotnet sdk remove and version resolution
devlead 5558fca
Align sdk remove identity parsing and tighten global.json version checks
devlead 2c86675
Address PR feedback for global.json parsing and interactive SDK versi…
devlead a6c4161
Keep SDK reference commands off dotnet sdk
devlead File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
17 changes: 17 additions & 0 deletions
17
src/Cli/Microsoft.DotNet.Cli.Definitions/Commands/Hidden/Add/Sdk/AddSdkCommandDefinition.cs
This file contains hidden or 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,17 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using System.CommandLine; | ||
| using Microsoft.DotNet.Cli.Commands.Sdk.Add; | ||
|
|
||
| namespace Microsoft.DotNet.Cli.Commands.Hidden.Add.Sdk; | ||
|
|
||
| internal sealed class AddSdkCommandDefinition() : SdkAddCommandDefinitionBase(Name) | ||
| { | ||
| public new const string Name = "sdk"; | ||
|
|
||
| public AddCommandDefinition Parent => (AddCommandDefinition)Parents.Single(); | ||
|
|
||
| public override Argument<string>? GetProjectOrFileArgument() | ||
| => Parent.ProjectOrFileArgument; | ||
| } |
This file contains hidden or 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
17 changes: 17 additions & 0 deletions
17
...Microsoft.DotNet.Cli.Definitions/Commands/Hidden/Remove/Sdk/RemoveSdkCommandDefinition.cs
This file contains hidden or 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,17 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using System.CommandLine; | ||
| using Microsoft.DotNet.Cli.Commands.Sdk.Remove; | ||
|
|
||
| namespace Microsoft.DotNet.Cli.Commands.Hidden.Remove.Sdk; | ||
|
|
||
| internal sealed class RemoveSdkCommandDefinition() : SdkRemoveCommandDefinitionBase(Name) | ||
| { | ||
| public new const string Name = "sdk"; | ||
|
|
||
| public RemoveCommandDefinition Parent => (RemoveCommandDefinition)Parents.Single(); | ||
|
|
||
| public override Argument<string>? GetProjectOrFileArgument() | ||
| => Parent.ProjectOrFileArgument; | ||
| } |
54 changes: 54 additions & 0 deletions
54
src/Cli/Microsoft.DotNet.Cli.Definitions/Commands/Sdk/SdkAddCommandDefinition.cs
This file contains hidden or 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,54 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using System.CommandLine; | ||
| using Microsoft.DotNet.Cli.CommandLine; | ||
| using Microsoft.DotNet.Cli.Commands.Package; | ||
|
|
||
| namespace Microsoft.DotNet.Cli.Commands.Sdk.Add; | ||
|
|
||
| internal abstract class SdkAddCommandDefinitionBase : Command | ||
| { | ||
| public static Option<string?> CreateVersionOption() => new Option<string?>("--version", "-v") | ||
| { | ||
| Description = CommandDefinitionStrings.CmdVersionDescription, | ||
| HelpName = CommandDefinitionStrings.CmdVersion, | ||
| }; | ||
|
|
||
| public static Option<bool> CreateNoRestoreOption() => new("--no-restore", "-n") | ||
| { | ||
| Description = CommandDefinitionStrings.SdkAddCmdNoRestoreDescription, | ||
| Arity = ArgumentArity.Zero | ||
| }; | ||
|
|
||
| public static Option<bool> CreateInteractiveOption() => CommonOptions.CreateInteractiveOption().ForwardIfEnabled("--interactive"); | ||
|
|
||
| public readonly Argument<SdkReferenceIdentity> SdkIdArgument = CommonArguments.CreateRequiredSdkReferenceIdentityArgument(); | ||
| public readonly Option<string?> VersionOption = CreateVersionOption(); | ||
| public readonly Option<bool> NoRestoreOption = CreateNoRestoreOption(); | ||
| public readonly Option<bool> InteractiveOption = CreateInteractiveOption(); | ||
| public readonly Option<string?> ProjectOption = PackageCommandDefinition.CreateProjectOption(); | ||
| public readonly Option<string?> FileOption = PackageCommandDefinition.CreateFileOption(); | ||
|
|
||
| public SdkAddCommandDefinitionBase(string name) | ||
| : base(name, CommandDefinitionStrings.SdkAddAppFullName) | ||
| { | ||
| VersionOption.Validators.Add(result => | ||
| { | ||
| if (result.Parent?.GetValue(SdkIdArgument).HasVersion == true) | ||
| { | ||
| result.AddError(CommandDefinitionStrings.ValidationFailedDuplicateVersion); | ||
| } | ||
| }); | ||
|
|
||
| Arguments.Add(SdkIdArgument); | ||
|
|
||
| Options.Add(VersionOption); | ||
| Options.Add(NoRestoreOption); | ||
| Options.Add(InteractiveOption); | ||
| Options.Add(ProjectOption); | ||
| Options.Add(FileOption); | ||
| } | ||
|
|
||
| public abstract Argument<string>? GetProjectOrFileArgument(); | ||
| } |
33 changes: 33 additions & 0 deletions
33
src/Cli/Microsoft.DotNet.Cli.Definitions/Commands/Sdk/SdkRemoveCommandDefinition.cs
This file contains hidden or 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,33 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using System.CommandLine; | ||
| using Microsoft.DotNet.Cli.CommandLine; | ||
| using Microsoft.DotNet.Cli.Commands.Package; | ||
|
|
||
| namespace Microsoft.DotNet.Cli.Commands.Sdk.Remove; | ||
|
|
||
| internal abstract class SdkRemoveCommandDefinitionBase : Command | ||
| { | ||
| public readonly Argument<string[]> SdkIdArgument = new(CommonArguments.SdkIdArgumentName) | ||
| { | ||
| Description = CommandDefinitionStrings.SdkRemoveAppHelpText, | ||
| HelpName = CommandDefinitionStrings.CmdSdk, | ||
| Arity = ArgumentArity.OneOrMore, | ||
| }; | ||
|
|
||
| public readonly Option<bool> InteractiveOption = CommonOptions.CreateInteractiveOption().ForwardIfEnabled("--interactive"); | ||
| public readonly Option<string?> ProjectOption = PackageCommandDefinition.CreateProjectOption(); | ||
| public readonly Option<string?> FileOption = PackageCommandDefinition.CreateFileOption(); | ||
|
|
||
| public SdkRemoveCommandDefinitionBase(string name) | ||
| : base(name, CommandDefinitionStrings.SdkRemoveAppFullName) | ||
| { | ||
| Arguments.Add(SdkIdArgument); | ||
| Options.Add(InteractiveOption); | ||
| Options.Add(ProjectOption); | ||
| Options.Add(FileOption); | ||
| } | ||
|
|
||
| public abstract Argument<string>? GetProjectOrFileArgument(); | ||
| } |
This file contains hidden or 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
42 changes: 41 additions & 1 deletion
42
src/Cli/Microsoft.DotNet.Cli.Definitions/xlf/CommandDefinitionStrings.cs.xlf
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.