-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Separate command parsing from implementation to reduce dotnet-watch dependencies #51624
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
Draft
Copilot
wants to merge
3
commits into
release/10.0.2xx
Choose a base branch
from
copilot/separate-parser-implementation
base: release/10.0.2xx
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.
Draft
Changes from all commits
Commits
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
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,95 @@ | ||
| // 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.Restore; | ||
| using Microsoft.DotNet.Cli.Extensions; | ||
|
|
||
| namespace Microsoft.DotNet.Cli.Commands.Build; | ||
|
|
||
| internal static class BuildCommandDefinition | ||
| { | ||
| public static readonly string DocsLink = "https://aka.ms/dotnet-build"; | ||
|
|
||
| public static readonly Argument<string[]> SlnOrProjectOrFileArgument = new(CliStrings.SolutionOrProjectOrFileArgumentName) | ||
| { | ||
| Description = CliStrings.SolutionOrProjectOrFileArgumentDescription, | ||
| Arity = ArgumentArity.ZeroOrMore | ||
| }; | ||
|
|
||
| public static readonly Option<string> OutputOption = new Option<string>("--output", "-o") | ||
| { | ||
| Description = CliCommandStrings.BuildOutputOptionDescription, | ||
| HelpName = CliCommandStrings.OutputOptionName | ||
| }.ForwardAsOutputPath("OutputPath"); | ||
|
|
||
| public static readonly Option<bool> NoIncrementalOption = new Option<bool>("--no-incremental") | ||
| { | ||
| Description = CliCommandStrings.NoIncrementalOptionDescription, | ||
| Arity = ArgumentArity.Zero | ||
| }.ForwardAs("--target:Rebuild"); | ||
|
|
||
| public static readonly Option<bool> NoDependenciesOption = new Option<bool>("--no-dependencies") | ||
| { | ||
| Description = CliCommandStrings.NoDependenciesOptionDescription, | ||
| Arity = ArgumentArity.Zero | ||
| }.ForwardAs("--property:BuildProjectReferences=false"); | ||
|
|
||
| public static readonly Option<bool> NoLogoOption = CommonOptions.NoLogoOption(); | ||
|
|
||
| public static readonly Option<bool> NoRestoreOption = CommonOptions.NoRestoreOption; | ||
|
|
||
| public static readonly Option<bool> SelfContainedOption = CommonOptions.SelfContainedOption; | ||
|
|
||
| public static readonly Option<bool> NoSelfContainedOption = CommonOptions.NoSelfContainedOption; | ||
|
|
||
| public static readonly Option<string> RuntimeOption = CommonOptions.RuntimeOption(CliCommandStrings.BuildRuntimeOptionDescription); | ||
|
|
||
| public static readonly Option<string> FrameworkOption = CommonOptions.FrameworkOption(CliCommandStrings.BuildFrameworkOptionDescription); | ||
|
|
||
| public static readonly Option<string?> ConfigurationOption = CommonOptions.ConfigurationOption(CliCommandStrings.BuildConfigurationOptionDescription); | ||
|
|
||
| /// <summary> | ||
| /// Build actually means 'run the default Target' generally in MSBuild | ||
| /// </summary> | ||
| public static readonly Option<string[]?> TargetOption = CommonOptions.MSBuildTargetOption(); | ||
|
|
||
| public static readonly Option<Utils.VerbosityOptions?> VerbosityOption = CommonOptions.VerbosityOption(); | ||
|
|
||
| public static Command Create() | ||
| { | ||
| Command command = new("build", CliCommandStrings.BuildAppFullName) | ||
| { | ||
| DocsLink = DocsLink | ||
| }; | ||
|
|
||
| command.Arguments.Add(SlnOrProjectOrFileArgument); | ||
| RestoreCommandDefinition.AddImplicitRestoreOptions(command, includeRuntimeOption: false, includeNoDependenciesOption: false); | ||
| command.Options.Add(FrameworkOption); | ||
| command.Options.Add(ConfigurationOption); | ||
| command.Options.Add(RuntimeOption); | ||
| command.Options.Add(CommonOptions.VersionSuffixOption); | ||
| command.Options.Add(NoRestoreOption); | ||
| command.Options.Add(CommonOptions.InteractiveMsBuildForwardOption); | ||
| command.Options.Add(VerbosityOption); | ||
| command.Options.Add(CommonOptions.DebugOption); | ||
| command.Options.Add(OutputOption); | ||
| command.Options.Add(CommonOptions.ArtifactsPathOption); | ||
| command.Options.Add(NoIncrementalOption); | ||
| command.Options.Add(NoDependenciesOption); | ||
| command.Options.Add(NoLogoOption); | ||
| command.Options.Add(SelfContainedOption); | ||
| command.Options.Add(NoSelfContainedOption); | ||
| command.Options.Add(CommonOptions.ArchitectureOption); | ||
| command.Options.Add(CommonOptions.OperatingSystemOption); | ||
| command.Options.Add(CommonOptions.DisableBuildServersOption); | ||
| command.Options.Add(TargetOption); | ||
| command.Options.Add(CommonOptions.GetPropertyOption); | ||
| command.Options.Add(CommonOptions.GetItemOption); | ||
| command.Options.Add(CommonOptions.GetTargetResultOption); | ||
| command.Options.Add(CommonOptions.GetResultOutputFileOption); | ||
|
|
||
| return command; | ||
| } | ||
| } | ||
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
27 changes: 27 additions & 0 deletions
27
src/Cli/dotnet/Commands/BuildServer/BuildServerCommandDefinition.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,27 @@ | ||
| // 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.BuildServer.Shutdown; | ||
| using Microsoft.DotNet.Cli.CommandLine; | ||
| using Microsoft.DotNet.Cli.Extensions; | ||
|
|
||
| namespace Microsoft.DotNet.Cli.Commands.BuildServer; | ||
|
|
||
| internal static class BuildServerCommandDefinition | ||
| { | ||
| public const string Name = "build-server"; | ||
| public static readonly string DocsLink = "https://aka.ms/dotnet-build-server"; | ||
|
|
||
| public static Command Create() | ||
| { | ||
| var command = new Command(Name, CliCommandStrings.BuildServerCommandDescription) | ||
| { | ||
| DocsLink = DocsLink | ||
| }; | ||
|
|
||
| command.Subcommands.Add(BuildServerShutdownCommandDefinition.Create()); | ||
|
|
||
| return command; | ||
| } | ||
| } |
18 changes: 3 additions & 15 deletions
18
src/Cli/dotnet/Commands/BuildServer/BuildServerCommandParser.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 |
|---|---|---|
| @@ -1,37 +1,25 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| #nullable disable | ||
|
|
||
| using System.CommandLine; | ||
| using Microsoft.DotNet.Cli.Commands.BuildServer.Shutdown; | ||
| using Microsoft.DotNet.Cli.CommandLine; | ||
| using Microsoft.DotNet.Cli.Extensions; | ||
|
|
||
| namespace Microsoft.DotNet.Cli.Commands.BuildServer; | ||
|
|
||
tmat marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| internal static class BuildServerCommandParser | ||
| { | ||
| public static readonly string DocsLink = "https://aka.ms/dotnet-build-server"; | ||
|
|
||
| private static readonly Command Command = ConstructCommand(); | ||
| private static readonly Command Command = SetAction(BuildServerCommandDefinition.Create()); | ||
|
|
||
| public static Command GetCommand() | ||
| { | ||
| return Command; | ||
| } | ||
|
|
||
| private static Command ConstructCommand() | ||
| private static Command SetAction(Command command) | ||
| { | ||
| var command = new Command("build-server", CliCommandStrings.BuildServerCommandDescription) | ||
| { | ||
| DocsLink = DocsLink | ||
| }; | ||
|
|
||
| command.Subcommands.Add(BuildServerShutdownCommandParser.GetCommand()); | ||
|
|
||
| command.SetAction((parseResult) => parseResult.HandleMissingCommand()); | ||
|
|
||
| command.Subcommands.Single(c => c.Name == BuildServerCommandDefinition.Name).SetAction((parseResult) => new BuildServerShutdownCommand(parseResult).Execute()); | ||
| return command; | ||
| } | ||
| } | ||
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
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
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.