コード例 #1
0
 private static Command Build() =>
 Command("build",
         ".NET Builder",
         HelpOption(),
         Option("-o|--output",
                "Output directory in which to place built artifacts.",
                ExactlyOneArgument
                .Named("OUTPUT_DIR")),
         Option("-f|--framework",
                "Target framework to build for. The target framework has to be specified in the project file.",
                AnyOneOf(FrameworksFromProjectFile())),
         Option("-r|--runtime",
                "Target runtime to build for. The default is to build a portable application.",
                AnyOneOf(RunTimesFromProjectFile())),
         Option("-c|--configuration",
                "Configuration to use for building the project. Default for most projects is  \"Debug\".",
                ExactlyOneArgument
                .Named("CONFIGURATION")
                .Default("DEBUG")),
         Option("--version-suffix", "Defines the value for the $(VersionSuffix) property in the project",
                ExactlyOneArgument
                .Named("VERSION_SUFFIX")),
         Option("--no-incremental", "Disables incremental build."),
         Option("--no-dependencies", "Set this flag to ignore project-to-project references and only build the root project"),
         VerbosityOption());
コード例 #2
0
 private static Command Restore() =>
 Command("restore",
         ".NET dependency restorer",
         HelpOption(),
         Option("-s|--source",
                "Specifies a NuGet package source to use during the restore.",
                ExactlyOneArgument
                .Named("SOURCE")),
         Option("-r|--runtime",
                "Target runtime to restore packages for.",
                AnyOneOf(RunTimesFromProjectFile())
                .Named("RUNTIME_IDENTIFIER")),
         Option("--packages",
                "Directory to install packages in.",
                ExactlyOneArgument
                .Named("PACKAGES_DIRECTORY")),
         Option("--disable-parallel",
                "Disables restoring multiple projects in parallel."),
         Option("--configfile",
                "The NuGet configuration file to use.",
                ExactlyOneArgument
                .Named("FILE")),
         Option("--no-cache",
                "Do not cache packages and http requests."),
         Option("--ignore-failed-sources",
                "Treat package source failures as warnings."),
         Option("--no-dependencies",
                "Set this flag to ignore project to project references and only restore the root project"),
         VerbosityOption());
コード例 #3
0
 private static Command Pack() =>
 Command("pack",
         ".NET Core NuGet Package Packer",
         HelpOption(),
         Option("-o|--output",
                "Directory in which to place built packages.",
                ExactlyOneArgument
                .Named("OUTPUT_DIR")),
         Option("--no-build",
                "Skip building the project prior to packing. By default, the project will be built."),
         Option("--include-symbols",
                "Include packages with symbols in addition to regular packages in output directory."),
         Option("--include-source",
                "Include PDBs and source files. Source files go into the src folder in the resulting nuget package"),
         Option("-c|--configuration",
                "Configuration to use for building the project.  Default for most projects is  \"Debug\".",
                ExactlyOneArgument
                .Named("CONFIGURATION")),
         Option("--version-suffix",
                "Defines the value for the $(VersionSuffix) property in the project.",
                ExactlyOneArgument
                .Named("VERSION_SUFFIX")),
         Option("-s|--serviceable",
                "Set the serviceable flag in the package. For more information, please see https://aka.ms/nupkgservicing."),
         VerbosityOption()
         );
コード例 #4
0
 private static Command Complete() =>
 Command("complete", "",
         ExactlyOneArgument
         .Named("path"),
         Option("--position", "",
                ExactlyOneArgument
                .Named("command"),
                o => int.Parse(o.Arguments.Single())));
コード例 #5
0
 public static ArgumentsRule AnyOneOf(params string[] values) =>
 ExactlyOneArgument
 .And(
     ParseRule(o => !values.Contains(
                   o.Arguments.Single(),
                   StringComparer.OrdinalIgnoreCase)
                                ? $"Argument '{o.Arguments.Single()}' not recognized. Must be one of:\n\t{string.Join("\n\t", values.Select(v => $"'{v}'"))}"
                                : "",
               values));
コード例 #6
0
 private static Command Reference() =>
 Command("reference",
         "Command to add project to project reference",
         OneOrMoreArguments,
         HelpOption(),
         Option("-f|--framework",
                "Add reference only when targetting a specific framework",
                ExactlyOneArgument
                .Named("FRAMEWORK")));
コード例 #7
0
 private static Command List() =>
 Command("list", "",
         ExactlyOneArgument
         .Named("PROJECT")
         .Description(
             "The project file to operate on. If a file is not specified, the command will search the current directory for one."),
         HelpOption(),
         Command("reference", "Command to list project to project references",
                 ExactlyOneArgument
                 .Named("PROJECT")
                 .Description("The project file to operate on. If a file is not specified, the command will search the current directory for one."),
                 HelpOption()));
コード例 #8
0
 private static Command Clean() =>
 Command("clean",
         ".NET Clean Command",
         HelpOption(),
         Option("-o|--output", "Directory in which the build outputs have been placed.",
                ExactlyOneArgument
                .Named("OUTPUT_DIR")),
         Option("-f|--framework", "Clean a specific framework.",
                ExactlyOneArgument
                .Named("FRAMEWORK")),
         Option("-c|--configuration", "Clean a specific configuration.",
                ExactlyOneArgument
                .Named("CONFIGURATION")));
コード例 #9
0
 private static Command Remove() =>
 Command("remove",
         "",
         HelpOption(),
         Command("package",
                 "Command to remove package reference.",
                 HelpOption()),
         Command("reference",
                 "Command to remove project to project reference",
                 HelpOption(),
                 Option("-f|--framework",
                        "Remove reference only when targetting a specific framework",
                        ExactlyOneArgument
                        .Named("FRAMEWORK"))));
コード例 #10
0
 private static Command Sln() =>
 Command("sln",
         ".NET modify solution file command",
         HelpOption(),
         Command("add",
                 ".NET Add project(s) to a solution file Command",
                 ExactlyOneArgument
                 .Named("SLN_FILE"),
                 HelpOption()),
         Command("list",
                 "List all projects in the solution.",
                 ExactlyOneArgument
                 .Named("SLN_FILE"),
                 HelpOption()),
         Command("remove",
                 "Remove the specified project(s) from the solution. The project is not impacted."));
コード例 #11
0
 private static Command Test() =>
 Command("test",
         ".NET Test Driver",
         Option("-h|--help",
                "Show help information"),
         Option("-s|--settings",
                "Settings to use when running tests.",
                ExactlyOneArgument
                .Named("SETTINGS_FILE")),
         Option("-t|--list-tests",
                "Lists discovered tests"),
         Option("--filter",
                @"Run tests that match the given expression.
                                 Examples:
                                 Run tests with priority set to 1: --filter ""Priority = 1""
                                 Run a test with the specified full name: --filter ""FullyQualifiedName=Namespace.ClassName.MethodName""
                                 Run tests that contain the specified name: --filter ""FullyQualifiedName~Namespace.Class""
                                 More info on filtering support: https://aka.ms/vstest-filtering",
                ExactlyOneArgument.Named("EXPRESSION")),
         Option("-a|--test-adapter-path",
                "Use custom adapters from the given path in the test run.\r\n                          Example: --test-adapter-path <PATH_TO_ADAPTER>"),
         Option("-l|--logger",
                "Specify a logger for test results.\r\n                          Example: --logger \"trx[;LogFileName=<Defaults to unique file name>]\"",
                ExactlyOneArgument
                .Named("LoggerUri/FriendlyName")),
         Option("-c|--configuration", "Configuration to use for building the project.  Default for most projects is  \"Debug\".",
                ExactlyOneArgument
                .Named("CONFIGURATION")),
         Option("-f|--framework",
                "Looks for test binaries for a specific framework",
                ExactlyOneArgument
                .Named("FRAMEWORK")),
         Option("-o|--output",
                "Directory in which to find the binaries to be run",
                ExactlyOneArgument
                .Named("OUTPUT_DIR")),
         Option("-d|--diag",
                "Enable verbose logs for test platform.\r\n                          Logs are written to the provided file.",
                ExactlyOneArgument
                .Named("PATH_TO_FILE")),
         Option("--no-build",
                "Do not build project before testing."),
         VerbosityOption());
コード例 #12
0
        public void Suggestions_can_be_provided_in_the_absence_of_validation()
        {
            var command = Command("the-command", "",
                                  Option("-t", "",
                                         ExactlyOneArgument
                                         .WithSuggestionsFrom(s => new[]
            {
                "vegetable",
                "mineral",
                "animal"
            })));

            command.Parse("the-command -t m")
            .Suggestions()
            .Should()
            .BeEquivalentTo("animal",
                            "mineral");

            command.Parse("the-command -t something-else").Errors.Should().BeEmpty();
        }
コード例 #13
0
 private static Command Package() =>
 Command("package",
         ".NET Add Package reference Command",
         ExactlyOneArgument
         .WithSuggestionsFrom(QueryNuGet),
         HelpOption(),
         Option("-v|--version",
                "Version for the package to be added.",
                ExactlyOneArgument
                .Named("VERSION")),
         Option("-f|--framework",
                "Add reference only when targetting a specific framework",
                ExactlyOneArgument
                .Named("FRAMEWORK")),
         Option("-n|--no-restore ",
                "Add reference without performing restore preview and compatibility check."),
         Option("-s|--source",
                "Use specific NuGet package sources to use during the restore."),
         Option("--package-directory",
                "Restore the packages to this Directory .",
                ExactlyOneArgument
                .Named("PACKAGE_DIRECTORY")));
コード例 #14
0
 private static Command Publish() =>
 Command("publish",
         ".NET Publisher",
         ExactlyOneArgument,
         HelpOption(),
         Option("-f|--framework",
                "Target framework to publish for. The target framework has to be specified in the project file.",
                ExactlyOneArgument
                .Named("FRAMEWORK")),
         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.",
                ExactlyOneArgument
                .Named("RUNTIME_IDENTIFIER")),
         Option("-o|--output",
                "Output directory in which to place the published artifacts.",
                ExactlyOneArgument
                .Named("OUTPUT_DIR")),
         Option("-c|--configuration", "Configuration to use for building the project.  Default for most projects is  \"Debug\".",
                ExactlyOneArgument
                .Named("CONFIGURATION")),
         Option("--version-suffix", "Defines the value for the $(VersionSuffix) property in the project.",
                ExactlyOneArgument
                .Named("VERSION_SUFFIX")),
         VerbosityOption());
コード例 #15
0
 private static Command NuGet() =>
 Command("nuget",
         "NuGet Command Line 4.0.0.0",
         HelpOption(),
         Option("--version",
                "Show version information"),
         Option("-v|--verbosity",
                "The verbosity of logging to use. Allowed values: Debug, Verbose, Information, Minimal, Warning, Error.",
                ExactlyOneArgument.Named("verbosity")),
         Command("delete",
                 "Deletes a package from the server.",
                 ExactlyOneArgument
                 .Named("root")
                 .Description("The Package Id and version."),
                 HelpOption(),
                 Option("--force-english-output",
                        "Forces the application to run using an invariant, English-based culture."),
                 Option("-s|--source",
                        "Specifies the server URL",
                        ExactlyOneArgument
                        .Named("source")),
                 Option("--non-interactive",
                        "Do not prompt for user input or confirmations."),
                 Option("-k|--api-key",
                        "The API key for the server.",
                        ExactlyOneArgument
                        .Named("apiKey"))),
         Command("locals",
                 "Clears or lists local NuGet resources such as http requests cache, packages cache or machine-wide global packages folder.",
                 AnyOneOf(@"all", @"http-cache", @"global-packages", @"temp")
                 .Description("Cache Location(s)  Specifies the cache location(s) to list or clear."),
                 HelpOption(),
                 Option("--force-english-output",
                        "Forces the application to run using an invariant, English-based culture."),
                 Option("-c|--clear", "Clear the selected local resources or cache location(s)."),
                 Option("-l|--list", "List the selected local resources or cache location(s).")),
         Command("push",
                 "Pushes a package to the server and publishes it.",
                 HelpOption(),
                 Option("--force-english-output",
                        "Forces the application to run using an invariant, English-based culture."),
                 Option("-s|--source",
                        "Specifies the server URL",
                        ExactlyOneArgument
                        .Named("source")),
                 Option("-ss|--symbol-source",
                        "Specifies the symbol server URL. If not specified, nuget.smbsrc.net is used when pushing to nuget.org.",
                        ExactlyOneArgument
                        .Named("source")),
                 Option("-t|--timeout",
                        "Specifies the timeout for pushing to a server in seconds. Defaults to 300 seconds (5 minutes).",
                        ExactlyOneArgument
                        .Named("timeout")),
                 Option("-k|--api-key", "The API key for the server.",
                        ExactlyOneArgument
                        .Named("apiKey")),
                 Option("-sk|--symbol-api-key", "The API key for the symbol server.",
                        ExactlyOneArgument
                        .Named("apiKey")),
                 Option("-d|--disable-buffering",
                        "Disable buffering when pushing to an HTTP(S) server to decrease memory usage."),
                 Option("-n|--no-symbols",
                        "If a symbols package exists, it will not be pushed to a symbols server.")));