/// Runs source code without any explicit compile or launch commands.
///
@@ -3074,14 +3145,14 @@ public IStartInfo GetStartInfo(IHost host)
.WithVars(Vars.ToArray())
.AddArgs("run")
.AddNotEmptyArgs(Project.ToArg())
- .AddArgs(Arch.ToArgs("--arch"))
- .AddArgs(Configuration.ToArgs("--configuration"))
- .AddArgs(Framework.ToArgs("--framework"))
- .AddArgs(LaunchProfile.ToArgs("--launch-profile"))
- .AddArgs(OS.ToArgs("--os"))
- .AddArgs(Runtime.ToArgs("--runtime"))
- .AddArgs(TerminalLogger.ToArgs("--tl"))
- .AddArgs(Verbosity.ToArgs("--verbosity"))
+ .AddArgs(Arch.ToArgs("--arch", ""))
+ .AddArgs(Configuration.ToArgs("--configuration", ""))
+ .AddArgs(Framework.ToArgs("--framework", ""))
+ .AddArgs(LaunchProfile.ToArgs("--launch-profile", ""))
+ .AddArgs(OS.ToArgs("--os", ""))
+ .AddArgs(Runtime.ToArgs("--runtime", ""))
+ .AddArgs(TerminalLogger.ToArgs("--tl", ""))
+ .AddArgs(Verbosity.ToArgs("--verbosity", ""))
.AddBooleanArgs(
("--force", Force),
("--no-build", NoBuild),
@@ -3098,3 +3169,4 @@ public IStartInfo GetStartInfo(IHost host)
public override string ToString() => "".GetShortName(ShortName, "run", Project.ToArg());
}
+
diff --git a/CSharpInteractive.HostApi/SimpleDotNetCommands.tt b/CSharpInteractive.HostApi/DotNetCommands.tt
similarity index 50%
rename from CSharpInteractive.HostApi/SimpleDotNetCommands.tt
rename to CSharpInteractive.HostApi/DotNetCommands.tt
index 934db24d..728c01ca 100644
--- a/CSharpInteractive.HostApi/SimpleDotNetCommands.tt
+++ b/CSharpInteractive.HostApi/DotNetCommands.tt
@@ -1,216 +1,195 @@
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Collections.Generic" #>
+// ReSharper disable UnusedMember.Global
// ReSharper disable InconsistentNaming
namespace HostApi;
<#
const string ps = "
";
const string pf = "
";
- string CreateRef(string command)
- {
- return $"
.NET CLI command
";
- }
- bool IsCollection(string type)
+ string CreateCliRef(string command) =>
+ $"
.NET CLI command
";
+
+ var projectArg = new Arg("Project", "", "string", "The project or solution file to operate on. If not specified, the command searches the current directory for one. If more than one solution or project is found, an error is thrown.") { IsProject = true };
+ var propsArg = new Arg("Props", "--property", "IEnumerable<(string name, string value)>", "MSBuild options for setting properties.") { IsCollection = true };
+ var verbosityArg = new Arg("Verbosity", "--verbosity", "DotNetVerbosity?", "Sets the verbosity level of the command. Allowed values are , , , , and . The default is . For more information, see .");
+ var pathToApplicationArg = new Arg("PathToApplication", "", "string", "Specifies the path to an application .dll file to run the application. To run the application means to find and execute the entry point, which in the case of console apps is the Main method. For example, dotnet myapp. dll runs the myapp application.") { IsProject = true };
+ var rollForwardArg = new Arg("RollForward", "--roll-forward", "DotNetRollForward?", "Controls how roll forward is applied to the app. The SETTING can be one of the following values. If not specified, is the default.");
+ var additionalProbingPathsArg = new Arg("AdditionalProbingPaths", "--additionalprobingpath", "IEnumerable", "Paths containing probing policy and assemblies to probe.") { IsCollection = true };
+ var additionalDepsArg = new Arg("AdditionalDeps", "--additional-deps", "string", "Path to an additional .deps.json file. A deps.json file contains a list of dependencies, compilation dependencies, and version information used to address assembly conflicts.");
+ var fxVersionArg = new Arg("FxVersion", "--fx-version", "string", "Version of the .NET runtime to use to run the application.");
+ var frameworkArg = new Arg("Framework", "--framework", "string", "Builds and runs the app using the specified framework. The framework must be specified in the project file.");
+ var configurationArg = new Arg("Configuration", "--configuration", "string", "Defines the build configuration. The default for most projects is Debug, but you can override the build configuration settings in your project.");
+ var runtimeArg = new Arg("Runtime", "--runtime", "string", "Specifies the target runtime to restore packages for. For a list of Runtime Identifiers (RIDs), see the RID catalog. -r short option available since .NET Core 3.0 SDK.");
+ var noBuildArg = new Arg("NoBuild", "--no-build", "bool?", "Doesn't build the project before running. It also implicit sets the --no-restore flag.");
+ var noRestoreArg = new Arg("NoRestore", "--no-restore", "bool?", "Adds a package reference without performing a restore preview and compatibility check.");
+ var noDependenciesArg = new Arg("NoDependencies", "--no-dependencies", "bool?", "When restoring a project with project-to-project (P2P) references, restores the root project and not the references.");
+ var noIncrementalArg = new Arg("NoIncremental", "--no-incremental", "bool?", "Marks the build as unsafe for incremental build. This flag turns off incremental compilation and forces a clean rebuild of the project's dependency graph.");
+ var noLogoArg = new Arg("NoLogo", "--nologo", "bool?", "Doesn't display the startup banner or the copyright message.");
+ var noSelfContainedArg = new Arg("NoSelfContained", "--no-self-contained", "bool?", "Publishes the application as a framework dependent application. A compatible .NET runtime must be installed on the target machine to run the application. Available since .NET 6 SDK.");
+ var selfContainedArg = new Arg("SelfContained", "--self-contained", "bool?", "Publishes the .NET runtime with the application so the runtime doesn't need to be installed on the target machine. The default is true if a runtime identifier is specified. Available since .NET 6.");
+ var forceArg = new Arg("Force", "--force", "bool?", "Forces all dependencies to be resolved even if the last restore was successful. Specifying this flag is the same as deleting the project.assets.json file.");
+ var archArg = new Arg("Arch", "--arch", "string", "Specifies the target architecture. This is a shorthand syntax for setting the Runtime Identifier (RID), where the provided value is combined with the default RID. For example, on a win-x64 machine, specifying --arch x86 sets the RID to win-x86. If you use this option, don't use the -r|--runtime option. Available since .NET 6 Preview 7.");
+ var osArg = new Arg("OS", "--os", "string", "Specifies the target operating system (OS). This is a shorthand syntax for setting the Runtime Identifier (RID), where the provided value is combined with the default RID. For example, on a win-x64 machine, specifying --os linux sets the RID to linux-x64. If you use this option, don't use the -r|--runtime option. Available since .NET 6.");
+ var terminalLoggerArg = new Arg("TerminalLogger", "--tl", "DotNetTerminalLogger?", "Specifies whether the terminal logger should be used for the build output.");
+ var artifactsPathArg = new Arg("ArtifactsPath", "--artifacts-path", "string", "All build output files from the executed command will go in subfolders under the specified path, separated by project.");
+ var disableBuildServersArg = new Arg("DisableBuildServers", "--disable-build-servers", "bool?", "Forces the command to ignore any persistent build servers. This option provides a consistent way to disable all use of build caching, which forces a build from scratch. A build that doesn't rely on caches is useful when the caches might be corrupted or incorrect for some reason. Available since .NET 7 SDK.");
+ var outputArg = new Arg("Output", "--output", "string", "Directory in which to place the built binaries. If not specified, the default path is ./bin/<configuration>/<framework>/. For projects with multiple target frameworks (via the TargetFrameworks property), you also need to define --framework when you specify this option.");
+ var useCurrentRuntimeArg = new Arg("UseCurrentRuntime", "--use-current-runtime", "bool?", "Sets the RuntimeIdentifier to a platform portable RuntimeIdentifier based on the one of your machine. This happens implicitly with properties that require a RuntimeIdentifier, such as SelfContained, PublishAot, PublishSelfContained, PublishSingleFile, and PublishReadyToRun. If the property is set to false, that implicit resolution will no longer occur.");
+ var versionSuffixArg = new Arg("VersionSuffix", "--version-suffix", "string", "Sets the value of the $(VersionSuffix) property to use when building the project. This only works if the $(Version) property isn't set. Then, $(Version) is set to the $(VersionPrefix) combined with the $(VersionSuffix), separated by a dash.");
+ var templateNameArg = new Arg("TemplateName", "", "string", "The template to instantiate when the command is invoked. Each template might have specific options you can pass.") { IsProject = true };
+ var languageArg = new Arg("Language", "--language", "DotNetLanguage?", "");
+ var ownersArg = new Arg("Owners", "--owners", "IEnumerable", "List of trusted owners to further restrict the trust of a repository.") { IsCollection = true, CollectionSeparator = ","};
+ var allowUntrustedRootArg = new Arg("AllowUntrustedRoot", "--allow-untrusted-root", "bool?", "Specifies if the certificate for the trusted signer should be allowed to chain to an untrusted root. This is not recommended.");
+
+ var commands = new Command[]
{
- return type.StartsWith("IEnumerable<") || type.StartsWith("IReadOnlyCollection<");
- }
-
- (string PropertyName, string ArgName, string Type, bool IsProject, string Comments)[] commonArgs =
- [
- ("Project", "", "string", true, "The project or solution file to operate on. If not specified, the command searches the current directory for one. If more than one solution or project is found, an error is thrown."),
- ("Props", "--property", "IEnumerable<(string name, string value)>", false, "MSBuild options for setting properties."),
- ("Verbosity", "--verbosity", "DotNetVerbosity?", false, "Sets the verbosity level of the command. Allowed values are , , , , and . The default is . For more information, see ."),
- ("PathToApplication", "", "string", true, "Specifies the path to an application .dll file to run the application. To run the application means to find and execute the entry point, which in the case of console apps is the Main method. For example, dotnet myapp. dll runs the myapp application."),
- ("RollForward", "--roll-forward", "DotNetRollForward?", false, "Controls how roll forward is applied to the app. The SETTING can be one of the following values. If not specified, is the default."),
- ("AdditionalProbingPaths", "--additionalprobingpath", "IEnumerable", false, "Paths containing probing policy and assemblies to probe."),
- ("AdditionalDeps", "--additional-deps", "string", false, "Path to an additional .deps.json file. A deps.json file contains a list of dependencies, compilation dependencies, and version information used to address assembly conflicts."),
- ("FxVersion", "--fx-version", "string", false, "Version of the .NET runtime to use to run the application."),
- ("Framework", "--framework", "string", false, "Builds and runs the app using the specified framework. The framework must be specified in the project file."),
- ("Configuration", "--configuration", "string", false, "Defines the build configuration. The default for most projects is Debug, but you can override the build configuration settings in your project."),
- ("Runtime", "--runtime", "string", false, "Specifies the target runtime to restore packages for. For a list of Runtime Identifiers (RIDs), see the RID catalog. -r short option available since .NET Core 3.0 SDK."),
- ("NoBuild", "--no-build", "bool?", false, "Doesn't build the project before running. It also implicit sets the --no-restore flag."),
- ("NoRestore", "--no-restore", "bool?", false, "Adds a package reference without performing a restore preview and compatibility check."),
- ("NoDependencies", "--no-dependencies", "bool?", false, "When restoring a project with project-to-project (P2P) references, restores the root project and not the references."),
- ("NoIncremental", "--no-incremental", "bool?", false, "Marks the build as unsafe for incremental build. This flag turns off incremental compilation and forces a clean rebuild of the project's dependency graph."),
- ("NoLogo", "--nologo", "bool?", false, "Doesn't display the startup banner or the copyright message."),
- ("NoSelfContained", "--no-self-contained", "bool?", false, "Publishes the application as a framework dependent application. A compatible .NET runtime must be installed on the target machine to run the application. Available since .NET 6 SDK."),
- ("SelfContained", "--self-contained", "bool?", false, "Publishes the .NET runtime with the application so the runtime doesn't need to be installed on the target machine. The default is true if a runtime identifier is specified. Available since .NET 6."),
- ("Force", "--force", "bool?", false, "Forces all dependencies to be resolved even if the last restore was successful. Specifying this flag is the same as deleting the project.assets.json file."),
- ("Arch", "--arch", "string", false, "Specifies the target architecture. This is a shorthand syntax for setting the Runtime Identifier (RID), where the provided value is combined with the default RID. For example, on a win-x64 machine, specifying --arch x86 sets the RID to win-x86. If you use this option, don't use the -r|--runtime option. Available since .NET 6 Preview 7."),
- ("OS", "--os", "string", false, "Specifies the target operating system (OS). This is a shorthand syntax for setting the Runtime Identifier (RID), where the provided value is combined with the default RID. For example, on a win-x64 machine, specifying --os linux sets the RID to linux-x64. If you use this option, don't use the -r|--runtime option. Available since .NET 6."),
- ("TerminalLogger", "--tl", "DotNetTerminalLogger?", false, "Specifies whether the terminal logger should be used for the build output."),
- ("ArtifactsPath", "--artifacts-path", "string", false, "All build output files from the executed command will go in subfolders under the specified path, separated by project."),
- ("DisableBuildServers", "--disable-build-servers", "bool?", false, "Forces the command to ignore any persistent build servers. This option provides a consistent way to disable all use of build caching, which forces a build from scratch. A build that doesn't rely on caches is useful when the caches might be corrupted or incorrect for some reason. Available since .NET 7 SDK."),
- ("Output", "--output", "string", false, "Directory in which to place the built binaries. If not specified, the default path is ./bin/<configuration>/<framework>/. For projects with multiple target frameworks (via the TargetFrameworks property), you also need to define --framework when you specify this option."),
- ("UseCurrentRuntime", "--use-current-runtime", "bool?", false, "Sets the RuntimeIdentifier to a platform portable RuntimeIdentifier based on the one of your machine. This happens implicitly with properties that require a RuntimeIdentifier, such as SelfContained, PublishAot, PublishSelfContained, PublishSingleFile, and PublishReadyToRun. If the property is set to false, that implicit resolution will no longer occur."),
- ("VersionSuffix", "--version-suffix", "string", false, "Sets the value of the $(VersionSuffix) property to use when building the project. This only works if the $(Version) property isn't set. Then, $(Version) is set to the $(VersionPrefix) combined with the $(VersionSuffix), separated by a dash."),
- ("TemplateName", "", "string", true, "The template to instantiate when the command is invoked. Each template might have specific options you can pass."),
- ("Language", "--language", "DotNetLanguage?", false, ""),
- ];
-
- var commands = new (
- string Name,
- string[] Comments,
- string[] CommandArgs,
- (string PropertyName, string ArgName, string Type, bool IsProject, string Comments)[] Args,
- bool IsBuild,
- bool IsTests,
- string[] AdditionalArgs)
- [] {
- (
+ new(
"DotNet",
[
"Runs a dotnet application.",
ps,
"You specify the path to an application .dll file to run the application. To run the application means to find and execute the entry point, which in the case of console apps is the Main method. For example, dotnet myapp.dll runs the myapp application.",
pf,
- CreateRef("dotnet")
+ CreateCliRef("dotnet")
],
["$PathToApplication"],
[
- ("#AdditionalProbingPaths", "", "", false, ""),
- ("#PathToApplication", "", "", false, ""),
- ("#AdditionalDeps", "", "", false, ""),
- ("#FxVersion", "", "", false, ""),
- ("#RollForward", "", "RollForward", false, "")
- ],
- false, false, []
+ additionalProbingPathsArg,
+ pathToApplicationArg,
+ additionalDepsArg,
+ fxVersionArg,
+ rollForwardArg
+ ]
),
- (
+ new(
"DotNetExec",
[
"Executes a dotnet application.",
ps,
"You specify the path to an application .dll file to run the application. To run the application means to find and execute the entry point, which in the case of console apps is the Main method. For example, dotnet myapp.dll runs the myapp application.",
pf,
- CreateRef("dotnet")
+ CreateCliRef("dotnet")
],
["exec", "$PathToApplication"],
[
- ("#AdditionalProbingPaths", "", "", false, ""),
- ("#PathToApplication", "", "", false, ""),
- ("DepsFile", "--depsfile", "string", false, "Path to a deps.json file. A deps.json file is a configuration file that contains information about dependencies necessary to run the application. This file is generated by the .NET SDK."),
- ("#AdditionalDeps", "", "", false, ""),
- ("#FxVersion", "", "", false, ""),
- ("#RollForward", "", "RollForward", false, ""),
- ("RuntimeConfig", "--runtimeconfig", "string", false, "Path to a runtimeconfig.json file. A runtimeconfig.json file contains run-time settings and is typically named <applicationname>.runtimeconfig.json."),
- ],
- false, false, []
+ additionalProbingPathsArg,
+ pathToApplicationArg,
+ new Arg("DepsFile", "--depsfile", "string", "Path to a deps.json file. A deps.json file is a configuration file that contains information about dependencies necessary to run the application. This file is generated by the .NET SDK."),
+ additionalDepsArg,
+ fxVersionArg,
+ rollForwardArg,
+ new Arg("RuntimeConfig", "--runtimeconfig", "string", "Path to a runtimeconfig.json file. A runtimeconfig.json file contains run-time settings and is typically named <applicationname>.runtimeconfig.json.")
+ ]
),
- (
+ new(
"DotNetAddPackage",
[
"Adds or updates a package reference in a project file.",
ps,
"This command provides a convenient option to add or update a package reference in a project file. When you run the command, there's a compatibility check to ensure the package is compatible with the frameworks in the project. If the check passes and the package isn't referenced in the project file, a <PackageReference> element is added to the project file. If the check passes and the package is already referenced in the project file, the <PackageReference> element is updated to the latest compatible version. After the project file is updated, dotnet restore is run.",
pf,
- CreateRef("dotnet-add-package")
+ CreateCliRef("dotnet-add-package")
],
["add", "$Project", "package", "$PackageName"],
[
- ("Sources", "--source", "IEnumerable", false, "The URI of the NuGet package source to use during the restore operation."),
- ("#Project", "", "", false, ""),
- ("PackageName", "", "string", false, "The package reference to add."),
- ("#Framework", "", "", false, "Adds a package reference only when targeting a specific framework."),
- ("#NoRestore", "", "", false, ""),
- ("PackageDirectory", "--package-directory", "string", false, @"The directory where to restore the packages. The default package restore location is %userprofile%\.nuget\packages on Windows and ~/.nuget/packages on macOS and Linux."),
- ("Prerelease", "--prerelease", "bool?", false, "Allows prerelease packages to be installed. Available since .NET Core 5 SDK."),
- ("Version", "--version", "string", false, "Version of the package"),
- ],
- false, false, []
+ new Arg("Sources", "--source", "IEnumerable", "The URI of the NuGet package source to use during the restore operation.") { IsCollection = true },
+ projectArg,
+ new Arg("PackageName", "", "string", "The package reference to add."),
+ frameworkArg with { Comments = "Adds a package reference only when targeting a specific framework." },
+ noRestoreArg,
+ new Arg("PackageDirectory", "--package-directory", "string", @"The directory where to restore the packages. The default package restore location is %userprofile%\.nuget\packages on Windows and ~/.nuget/packages on macOS and Linux."),
+ new Arg("Prerelease", "--prerelease", "bool?", "Allows prerelease packages to be installed. Available since .NET Core 5 SDK."),
+ new Arg("Version", "--version", "string", "Version of the package")
+ ]
),
- (
+ new(
"DotNetListPackage",
[
"Lists the package references for a project or solution.",
ps,
"This command provides a convenient option to list all NuGet package references for a specific project or a solution. You first need to build the project in order to have the assets needed for this command to process.",
pf,
- CreateRef("dotnet-list-package")
+ CreateCliRef("dotnet-list-package")
],
["list", "$Project", "package"],
[
- ("Frameworks", "--framework", "IEnumerable", false, "Displays only the packages applicable for the specified target framework."),
- ("Sources", "--source", "IEnumerable", false, "The NuGet sources to use when searching for newer packages. Requires the --outdated or --deprecated option."),
- ("#Project", "", "", false, ""),
- ("Config", "--config", "string", false, "The NuGet sources to use when searching for newer packages. Requires the --outdated option."),
- ("Deprecated", "--deprecated", "bool?", false, "Displays packages that have been deprecated."),
- ("HighestMinor", "--highest-minor", "bool?", false, "Considers only the packages with a matching major version number when searching for newer packages. Requires the --outdated or --deprecated option."),
- ("HighestPatch", "--highest-patch", "bool?", false, "Considers only the packages with a matching major and minor version numbers when searching for newer packages. Requires the --outdated or --deprecated option."),
- ("IncludePrerelease", "--include-prerelease", "bool?", false, "Considers packages with prerelease versions when searching for newer packages. Requires the --outdated or --deprecated option."),
- ("IncludeTransitive", "--include-transitive", "bool?", false, "Lists transitive packages, in addition to the top-level packages. When specifying this option, you get a list of packages that the top-level packages depend on."),
- ("Outdated", "--outdated", "bool?", false, "Lists packages that have newer versions available."),
- ("#Verbosity", "", "", false, ""),
- ],
- false, false, []
+ new Arg("Frameworks", "--framework", "IEnumerable", "Displays only the packages applicable for the specified target framework.") { IsCollection = true },
+ new Arg("Sources", "--source", "IEnumerable", "The NuGet sources to use when searching for newer packages. Requires the --outdated or --deprecated option.") { IsCollection = true },
+ projectArg,
+ new Arg("Config", "--config", "string", "The NuGet sources to use when searching for newer packages. Requires the --outdated option."),
+ new Arg("Deprecated", "--deprecated", "bool?", "Displays packages that have been deprecated."),
+ new Arg("HighestMinor", "--highest-minor", "bool?", "Considers only the packages with a matching major version number when searching for newer packages. Requires the --outdated or --deprecated option."),
+ new Arg("HighestPatch", "--highest-patch", "bool?", "Considers only the packages with a matching major and minor version numbers when searching for newer packages. Requires the --outdated or --deprecated option."),
+ new Arg("IncludePrerelease", "--include-prerelease", "bool?", "Considers packages with prerelease versions when searching for newer packages. Requires the --outdated or --deprecated option."),
+ new Arg("IncludeTransitive", "--include-transitive", "bool?", "Lists transitive packages, in addition to the top-level packages. When specifying this option, you get a list of packages that the top-level packages depend on."),
+ new Arg("Outdated", "--outdated", "bool?", "Lists packages that have newer versions available."),
+ verbosityArg
+ ]
),
- (
+ new(
"DotNetRemovePackage",
[
"Removes package reference from a project file.",
ps,
"This command provides a convenient option to remove a NuGet package reference from a project.",
pf,
- CreateRef("dotnet-remove-package")
+ CreateCliRef("dotnet-remove-package")
],
["remove", "$Project", "package", "$PackageName"],
[
- ("#Project", "", "", false, ""),
- ("PackageName", "", "string", false, "The package reference to add."),
- ],
- false, false, []
+ projectArg,
+ new Arg("PackageName", "", "string", "The package reference to add.")
+ ]
),
- (
+ new(
"DotNetAddReference",
[
"Adds project-to-project (P2P) references.",
ps,
"This command provides a convenient option to add project references to a project. After running the command, the <ProjectReference> elements are added to the project file.",
pf,
- CreateRef("dotnet-add-reference")
+ CreateCliRef("dotnet-add-reference")
],
["add", "$Project", "reference", "$References"],
[
- ("References", "--source", "IEnumerable", false, "Project-to-project (P2P) references to add. Specify one or more projects. Glob patterns are supported on Unix/Linux-based systems."),
- ("#Project", "", "", false, ""),
- ("#Framework", "", "", false, "Adds project references only when targeting a specific framework using the TFM format.")
- ],
- false, false, []
+ new Arg("References", "--source", "IEnumerable", "Project-to-project (P2P) references to add. Specify one or more projects. Glob patterns are supported on Unix/Linux-based systems.") { IsCollection = true },
+ projectArg,
+ frameworkArg with { Comments = "Adds project references only when targeting a specific framework using the TFM format." }
+ ]
),
- (
+ new(
"DotNetListReference",
[
"Lists project-to-project references.",
ps,
"This command provides a convenient option to list project references for a given project.",
pf,
- CreateRef("dotnet-list-reference")
+ CreateCliRef("dotnet-list-reference")
],
["list", "$Project"],
[
- ("#Project", "", "", false, ""),
- ],
- false, false, []
+ projectArg
+ ]
),
- (
+ new(
"DotNetRemoveReference",
[
"Removes project-to-project (P2P) references.",
ps,
"This command provides a convenient option to remove project references from a project.",
pf,
- CreateRef("dotnet-remove-reference")
+ CreateCliRef("dotnet-remove-reference")
],
["remove", "$Project", "reference", "$References"],
[
- ("References", "--source", "IEnumerable", false, "Project-to-project (P2P) references to remove. You can specify one or multiple projects. Glob patterns are supported on Unix/Linux based terminals."),
- ("#Project", "", "", false, ""),
- ("#Framework", "", "", false, "Removes the reference only when targeting a specific framework using the TFM format.")
- ],
- false, false, []
+ new Arg("References", "--source", "IEnumerable", "Project-to-project (P2P) references to remove. You can specify one or multiple projects. Glob patterns are supported on Unix/Linux based terminals.") { IsCollection = true },
+ projectArg,
+ frameworkArg with { Comments = "Removes the reference only when targeting a specific framework using the TFM format." }
+ ]
),
- (
+ new(
"DotNetBuild",
[
"Builds a project and all of its dependencies.",
@@ -229,74 +208,73 @@ namespace HostApi;
" .Build().EnsureSuccess();",
"",
"",
- CreateRef("dotnet-build")
+ CreateCliRef("dotnet-build")
],
["build", "$Project"],
[
- ("Sources", "--source", "IEnumerable", false, "The URI of the NuGet package source to use during the restore operation."),
- ("#Project", "", "", false, ""),
- ("#Arch", "", "", false, ""),
- ("#ArtifactsPath", "", "", false, ""),
- ("#Configuration", "", "", false, ""),
- ("#DisableBuildServers", "", "", false, ""),
- ("#Framework", "", "", false, ""),
- ("#Force", "", "", false, ""),
- ("#NoDependencies", "", "", false, ""),
- ("#NoIncremental", "", "", false, ""),
- ("#NoRestore", "", "", false, ""),
- ("#NoLogo", "", "", false, ""),
- ("#NoSelfContained", "", "", false, ""),
- ("#Output", "", "", false, ""),
- ("#OS", "", "", false, ""),
- ("#Runtime", "", "", false, ""),
- ("#SelfContained", "", "", false, ""),
- ("#TerminalLogger", "", "", false, ""),
- ("#Verbosity", "", "", false, ""),
- ("#UseCurrentRuntime", "", "", false, ""),
- ("#VersionSuffix", "", "", false, ""),
- ],
- true, false, []
+ new Arg("Sources", "--source", "IEnumerable", "The URI of the NuGet package source to use during the restore operation.") { IsCollection = true },
+ projectArg,
+ archArg,
+ artifactsPathArg,
+ configurationArg,
+ disableBuildServersArg,
+ frameworkArg,
+ forceArg,
+ noDependenciesArg,
+ noIncrementalArg,
+ noRestoreArg,
+ noLogoArg,
+ noSelfContainedArg,
+ outputArg,
+ osArg,
+ runtimeArg,
+ selfContainedArg,
+ terminalLoggerArg,
+ verbosityArg,
+ useCurrentRuntimeArg,
+ versionSuffixArg
+ ],
+ CommandTypes.Build
),
- (
+ new(
"DotNetBuildServerShutdown",
[
"Shuts down build servers that are started from dotnet.",
ps,
"By default, all servers are shut down.",
pf,
- CreateRef("dotnet-build-server")
+ CreateCliRef("dotnet-build-server")
],
["build-server", "shutdown"],
[
- ("Servers", "", "IEnumerable", false, "Shuts down build servers that are started from dotnet. By default, all servers are shut down."),
- ],
- false, false, []
+ new Arg("Servers", "", "IEnumerable", "Shuts down build servers that are started from dotnet. By default, all servers are shut down.") { IsCollection = true }
+ ]
),
- (
+ new(
"DotNetClean",
[
"Cleans the output of a project.",
ps,
"This command cleans the output of the previous build. It's implemented as an MSBuild target, so the project is evaluated when the command is run. Only the outputs created during the build are cleaned. Both intermediate (obj) and final output (bin) folders are cleaned.",
pf,
- CreateRef("dotnet-clean")
+ CreateCliRef("dotnet-clean")
],
["clean", "$Project"],
[
- ("#Props", "", "", false, ""),
- ("#Project", "", "", false, ""),
- ("#ArtifactsPath", "", "", false, ""),
- ("#Configuration", "", "", false, ""),
- ("#Framework", "", "", false, ""),
- ("#NoLogo", "", "", false, ""),
- ("#Output", "", "", false, ""),
- ("#Runtime", "", "", false, ""),
- ("#TerminalLogger", "", "", false, ""),
- ("#Verbosity", "", "", false, ""),
- ],
- true, false, []
+ propsArg,
+ projectArg,
+ artifactsPathArg,
+ configurationArg,
+ frameworkArg,
+ noLogoArg,
+ outputArg,
+ runtimeArg,
+ terminalLoggerArg,
+ verbosityArg
+ ],
+ CommandTypes.Build
),
- (
+ new(
"DotNetDevCertsHttps",
[
"Generates a self-signed certificate to enable HTTPS use in development.",
@@ -308,524 +286,518 @@ namespace HostApi;
"
- Exporting a certificate in various formats so that it can be used by other tools.",
"
- Importing an existing certificate generated by the tool into the local machine.",
pf,
- CreateRef("dotnet-dev-certs")
+ CreateCliRef("dotnet-dev-certs")
],
["dev-certs", "https"],
[
- ("Check", "--check", "bool?", false, "Checks for the existence of the development certificate but doesn't perform any action. Use this option with the --trust option to check if the certificate is not only valid but also trusted."),
- ("Clean", "--clean", "bool?", false, "Removes all HTTPS development certificates from the certificate store by using the .NET certificate store API. Doesn't remove any physical files that were created by using the --export-path option. On macOS in .NET 7.0, the dotnet dev-certs command creates the certificate on a path on disk, and the clean operation removes that certificate file."),
- ("ExportPath", "--export-path", "string", false, "Exports the certificate to a file so that it can be used by other tools. Specify the full path to the exported certificate file, including the file name."),
- ("Format", "--format", "string", false, "When used with --export-path, specifies the format of the exported certificate file. Valid values are PFX and PEM, case-insensitive. PFX is the default. The file format is independent of the file name extension. For example, if you specify --format pfx and --export-path ./cert.pem, you'll get a file named cert.pem in PFX format."),
- ("Import", "--import", "string", false, "Imports the provided HTTPS development certificate into the local machine. Requires that you also specify the --clean option, which clears out any existing HTTPS developer certificates."),
- ("NoPassword", "--no-password", "bool?", false, "Doesn't use a password for the key when exporting a certificate to PEM format files. The key file is exported in plain text. This option is not applicable to PFX files and is intended for internal testing use only."),
- ("Password", "--password", "bool?", false, "Specifies the password to use."),
- ("Quiet", "--quiet", "bool?", false, "Display warnings and errors only."),
- ("Trust", "--trust", "bool?", false, "rusts the certificate on the local machine. If this option isn't specified, the certificate is added to the certificate store but not to a trusted list. When combined with the --check option, validates that the certificate is trusted."),
- ("Verbose", "--verbose", "bool?", false, "Display debug information."),
- ],
- false, false, []
+ new Arg("Check", "--check", "bool?", "Checks for the existence of the development certificate but doesn't perform any action. Use this option with the --trust option to check if the certificate is not only valid but also trusted."),
+ new Arg("Clean", "--clean", "bool?", "Removes all HTTPS development certificates from the certificate store by using the .NET certificate store API. Doesn't remove any physical files that were created by using the --export-path option. On macOS in .NET 7.0, the dotnet dev-certs command creates the certificate on a path on disk, and the clean operation removes that certificate file."),
+ new Arg("ExportPath", "--export-path", "string", "Exports the certificate to a file so that it can be used by other tools. Specify the full path to the exported certificate file, including the file name."),
+ new Arg("Format", "--format", "string", "When used with --export-path, specifies the format of the exported certificate file. Valid values are PFX and PEM, case-insensitive. PFX is the default. The file format is independent of the file name extension. For example, if you specify --format pfx and --export-path ./cert.pem, you'll get a file named cert.pem in PFX format."),
+ new Arg("Import", "--import", "string", "Imports the provided HTTPS development certificate into the local machine. Requires that you also specify the --clean option, which clears out any existing HTTPS developer certificates."),
+ new Arg("NoPassword", "--no-password", "bool?", "Doesn't use a password for the key when exporting a certificate to PEM format files. The key file is exported in plain text. This option is not applicable to PFX files and is intended for internal testing use only."),
+ new Arg("Password", "--password", "bool?", "Specifies the password to use."),
+ new Arg("Quiet", "--quiet", "bool?", "Display warnings and errors only."),
+ new Arg("Trust", "--trust", "bool?", "rusts the certificate on the local machine. If this option isn't specified, the certificate is added to the certificate store but not to a trusted list. When combined with the --check option, validates that the certificate is trusted."),
+ new Arg("Verbose", "--verbose", "bool?", "Display debug information.")
+ ]
),
- (
+ new(
"DotNetNew",
[
"Creates a new project, configuration file, or solution based on the specified template.",
ps,
"This command creates a .NET project or other artifacts based on a template. The command calls the template engine to create the artifacts on disk based on the specified template and options.",
pf,
- CreateRef("dotnet-new")
+ CreateCliRef("dotnet-new")
],
["new", "$TemplateName"],
[
- ("#TemplateName", "", "", false, "The template to instantiate when the command is invoked. Each template might have specific options you can pass."),
- ("DryRun", "--dry-run", "bool?", false, "Displays a summary of what would happen if the given command were run if it would result in a template creation. Available since .NET Core 2.2 SDK."),
- ("Force", "--force", "bool?", false, "Forces content to be generated even if it would change existing files. This is required when the template chosen would override existing files in the output directory."),
- ("#Language", "", "", false, "The language of the template to create. The language accepted varies by the template (see defaults in the arguments section). Not valid for some templates."),
- ("Name", "--name", "string", false, "The name for the created output. If no name is specified, the name of the current directory is used."),
- ("#Framework", "", "", false, "Specifies the target framework. It expects a target framework moniker (TFM). Examples: \"net6.0\", \"net7.0-macos\". This value will be reflected in the project file."),
- ("NoUpdateCheck", "-no-update-check", "bool?", false, "Disables checking for template package updates when instantiating a template. Available since .NET SDK 6.0.100."),
- ("#Output", "", "", false, "Location to place the generated output. The default is the current directory."),
- ("Project", "--project", "string", false, "The project that the template is added to. This project is used for context evaluation. If not specified, the project in the current or parent directories will be used. Available since .NET SDK 7.0.100."),
- ("#Verbosity", "", "", false, ""),
- ],
- false, false, []
+ templateNameArg with { Comments = "The template to instantiate when the command is invoked. Each template might have specific options you can pass." },
+ new Arg("DryRun", "--dry-run", "bool?", "Displays a summary of what would happen if the given command were run if it would result in a template creation. Available since .NET Core 2.2 SDK."),
+ new Arg("Force", "--force", "bool?", "Forces content to be generated even if it would change existing files. This is required when the template chosen would override existing files in the output directory."),
+ languageArg with { Comments = "The language of the template to create. The language accepted varies by the template (see defaults in the arguments section). Not valid for some templates." },
+ new Arg("Name", "--name", "string", "The name for the created output. If no name is specified, the name of the current directory is used."),
+ frameworkArg with { Comments = "Specifies the target framework. It expects a target framework moniker (TFM). Examples: \"net6.0\", \"net7.0-macos\". This value will be reflected in the project file." },
+ new Arg("NoUpdateCheck", "-no-update-check", "bool?", "Disables checking for template package updates when instantiating a template. Available since .NET SDK 6.0.100."),
+ outputArg with { Comments = "Location to place the generated output. The default is the current directory." },
+ new Arg("Project", "--project", "string", "The project that the template is added to. This project is used for context evaluation. If not specified, the project in the current or parent directories will be used. Available since .NET SDK 7.0.100."),
+ verbosityArg
+ ]
),
- (
+ new(
"DotNetNewList",
[
"Lists available templates to be run using dotnet new.",
ps,
"This command lists available templates to use with dotnet new. If the <TEMPLATE_NAME> is specified, lists templates containing the specified name. This option lists only default and installed templates. To find templates in NuGet that you can install locally, use the search command.",
pf,
- CreateRef("dotnet-new-list")
+ CreateCliRef("dotnet-new-list")
],
["new", "list", "$TemplateName"],
[
- ("Columns", "--columns", "IEnumerable", false, "Columns to display in the output."),
- ("#TemplateName", "", "", false, "If the argument is specified, only the templates containing TEMPLATE_NAME in template name or short name will be shown."),
- ("Author", "--author", "string", false, "Filters templates based on template author. Partial match is supported. Available since .NET SDK 5.0.300."),
- ("ColumnsAll", "--columns-all", "bool?", false, "Displays all columns in the output. Available since .NET SDK 5.0.300."),
- ("IgnoreConstraints", "--ignore-constraints", "bool?", false, "Disables checking if the template meets the constraints to be run. Available since .NET SDK 7.0.100."),
- ("#Language", "", "", false, "Filters templates based on language supported by the template. The language accepted varies by the template. Not valid for some templates."),
- ("#Output", "", "", false, "Location to place the generated output. The default is the current directory. For the list command, it might be necessary to specify the output directory to correctly evaluate constraints for the template. Available since .NET SDK 7.0.100."),
- ("Project", "--project", "string", false, "The project that the template is added to. For the list command, it might be needed to specify the project the template is being added to to correctly evaluate constraints for the template. Available since .NET SDK 7.0.100."),
- ("Tag", "--tag", "string", false, "Filters templates based on template tags. To be selected, a template must have at least one tag that exactly matches the criteria. Available since .NET SDK 5.0.300."),
- ("Type", "--type", "DotNetTemplateType?", false, "Filters templates based on template type."),
- ("#Verbosity", "", "", false, ""),
- ],
- false, false, []
+ new Arg("Columns", "--columns", "IEnumerable", "Columns to display in the output.") { IsCollection = true },
+ templateNameArg with { Comments = "If the argument is specified, only the templates containing TEMPLATE_NAME in template name or short name will be shown." },
+ new Arg("Author", "--author", "string", "Filters templates based on template author. Partial match is supported. Available since .NET SDK 5.0.300."),
+ new Arg("ColumnsAll", "--columns-all", "bool?", "Displays all columns in the output. Available since .NET SDK 5.0.300."),
+ new Arg("IgnoreConstraints", "--ignore-constraints", "bool?", "Disables checking if the template meets the constraints to be run. Available since .NET SDK 7.0.100."),
+ languageArg with { Comments = "Filters templates based on language supported by the template. The language accepted varies by the template. Not valid for some templates." },
+ outputArg with { Comments = "Location to place the generated output. The default is the current directory. For the list command, it might be necessary to specify the output directory to correctly evaluate constraints for the template. Available since .NET SDK 7.0.100." },
+ new Arg("Project", "--project", "string", "The project that the template is added to. For the list command, it might be needed to specify the project the template is being added to to correctly evaluate constraints for the template. Available since .NET SDK 7.0.100."),
+ new Arg("Tag", "--tag", "string", "Filters templates based on template tags. To be selected, a template must have at least one tag that exactly matches the criteria. Available since .NET SDK 5.0.300."),
+ new Arg("Type", "--type", "DotNetTemplateType?", "Filters templates based on template type."),
+ verbosityArg
+ ]
),
- (
+ new(
"DotNetNewSearch",
[
"Searches for the templates supported by dotnet new on NuGet.org.",
ps,
"This command searches for templates supported by dotnet new on NuGet.org. When the <TEMPLATE_NAME> is specified, searches for templates containing the specified name.",
pf,
- CreateRef("dotnet-new-search")
+ CreateCliRef("dotnet-new-search")
],
["new", "search", "$TemplateName"],
[
- ("Columns", "--columns", "IEnumerable", false, "Columns to display in the output."),
- ("#TemplateName", "", "", false, "If the argument is specified, only the templates containing TEMPLATE_NAME in template name or short name will be shown."),
- ("Author", "--author", "string", false, "Filters templates based on template author. Partial match is supported. Available since .NET SDK 5.0.300."),
- ("ColumnsAll", "--columns-all", "bool?", false, "Displays all columns in the output. Available since .NET SDK 5.0.300."),
- ("#Language", "", "", false, "Filters templates based on language supported by the template."),
- ("Package", "--package", "string", false, "Filters templates based on NuGet package ID. A partial match is supported."),
- ("Tag", "--tag", "string", false, "Filters templates based on template tags. To be selected, a template must have at least one tag that exactly matches the criteria."),
- ("Type", "--type", "DotNetTemplateType?", false, "Filters templates based on template type."),
- ("#Verbosity", "", "", false, ""),
- ],
- false, false, []
+ new Arg("Columns", "--columns", "IEnumerable", "Columns to display in the output.") { IsCollection = true },
+ templateNameArg with { Comments = "If the argument is specified, only the templates containing TEMPLATE_NAME in template name or short name will be shown." },
+ new Arg("Author", "--author", "string", "Filters templates based on template author. Partial match is supported. Available since .NET SDK 5.0.300."),
+ new Arg("ColumnsAll", "--columns-all", "bool?", "Displays all columns in the output. Available since .NET SDK 5.0.300."),
+ languageArg with { Comments = "Filters templates based on language supported by the template." },
+ new Arg("Package", "--package", "string", "Filters templates based on NuGet package ID. A partial match is supported."),
+ new Arg("Tag", "--tag", "string", "Filters templates based on template tags. To be selected, a template must have at least one tag that exactly matches the criteria."),
+ new Arg("Type", "--type", "DotNetTemplateType?", "Filters templates based on template type."),
+ verbosityArg
+ ]
),
- (
+ new(
"DotNetNewDetails",
[
"Displays template package metadata.",
ps,
"This command displays the metadata of the template package from the package name provided. By default, the command searches for the latest available version. If the package is installed locally or is found on the official NuGet website, it also displays the templates that the package contains, otherwise it only displays basic metadata.",
pf,
- CreateRef("dotnet-new-details")
+ CreateCliRef("dotnet-new-details")
],
["new", "details", "$TemplateName"],
[
- ("Sources", "--add-source", "IEnumerable", false, "By default, dotnet new details uses the hierarchy of NuGet configuration files from the current directory to determine the NuGet source the package can be installed from. If --nuget-source is specified, the source is added to the list of sources to be checked."),
- ("#TemplateName", "", "", false, "If the argument is specified, only the templates containing TEMPLATE_NAME in template name or short name will be shown."),
- ("#Force", "", "", false, ""),
- ("#Verbosity", "", "", false, ""),
- ],
- false, false, []
+ new Arg("Sources", "--add-source", "IEnumerable", "By default, dotnet new details uses the hierarchy of NuGet configuration files from the current directory to determine the NuGet source the package can be installed from. If --nuget-source is specified, the source is added to the list of sources to be checked.") { IsCollection = true },
+ templateNameArg with { Comments = "If the argument is specified, only the templates containing TEMPLATE_NAME in template name or short name will be shown." },
+ forceArg,
+ verbosityArg
+ ]
),
- (
+ new(
"DotNetNewInstall",
[
"Installs a template package.",
ps,
"This command installs a template package from the PATH or NUGET_ID provided. If you want to install a specific version or prerelease version of a template package, specify the version in the format <package-name>::<package-version>. By default, dotnet new passes * for the version, which represents the latest stable package version.",
pf,
- CreateRef("dotnet-new-install")
+ CreateCliRef("dotnet-new-install")
],
["new", "install", "$Package"],
[
- ("Sources", "--add-source", "IEnumerable", false, "By default, dotnet new details uses the hierarchy of NuGet configuration files from the current directory to determine the NuGet source the package can be installed from. If --nuget-source is specified, the source is added to the list of sources to be checked."),
- ("Package", "", "string", true, "The folder on the file system or the NuGet package identifier to install the template package from. dotnet new attempts to install the NuGet package from the NuGet sources available for the current working directory and the sources specified via the --add-source option. If you want to install a specific version or prerelease version of a template package from NuGet source, specify the version in the format <package-name>::<package-version>."),
- ("#Force", "", "", false, ""),
- ("#Verbosity", "", "", false, ""),
- ],
- false, false, []
+ new Arg("Sources", "--add-source", "IEnumerable", "By default, dotnet new details uses the hierarchy of NuGet configuration files from the current directory to determine the NuGet source the package can be installed from. If --nuget-source is specified, the source is added to the list of sources to be checked.") { IsCollection = true },
+ new Arg("Package", "", "string", "The folder on the file system or the NuGet package identifier to install the template package from. dotnet new attempts to install the NuGet package from the NuGet sources available for the current working directory and the sources specified via the --add-source option. If you want to install a specific version or prerelease version of a template package from NuGet source, specify the version in the format <package-name>::<package-version>.") { IsProject = true },
+ forceArg,
+ verbosityArg
+ ]
),
- (
+ new(
"DotNetNewUninstall",
[
"Uninstalls a template package.",
ps,
"This command uninstalls a template package at the PATH or NUGET_ID provided. When the <PATH|NUGET_ID> value isn't specified, all currently installed template packages and their associated templates are displayed. When specifying NUGET_ID, don't include the version number.",
pf,
- CreateRef("dotnet-new-uninstall")
+ CreateCliRef("dotnet-new-uninstall")
],
["new", "uninstall", "$Package"],
[
- ("Package", "", "string", true, "The folder on the file system or the NuGet package identifier the package was installed from. Note that the version for the NuGet package should not be specified."),
- ("#Verbosity", "", "", false, ""),
- ],
- false, false, []
+ new Arg("Package", "", "string", "The folder on the file system or the NuGet package identifier the package was installed from. Note that the version for the NuGet package should not be specified.") { IsProject = true },
+ verbosityArg
+ ]
),
- (
+ new(
"DotNetNewUpdate",
[
"Updates installed template packages.",
ps,
"This command updates installed template packages. The dotnet new update command with --check-only option checks for available updates for installed template packages without applying them.",
pf,
- CreateRef("dotnet-new-update")
+ CreateCliRef("dotnet-new-update")
],
["new", "update"],
[
- ("Sources", "--add-source", "IEnumerable", false, "By default, dotnet new install uses the hierarchy of NuGet configuration files from the current directory to determine the NuGet source the package can be installed from. If Sources is specified, the source will be added to the list of sources to be checked. To check the configured sources for the current directory use dotnet nuget list source. Available since .NET SDK 7.0.100."),
- ("CheckOnly", "--check-only", "bool?", false, "Only checks for updates and displays the template packages to be updated, without applying any updates."),
- ("DryRun", "--dry-run", "bool?", false, "Only checks for updates and displays the template packages to be updated, without applying any updates."),
- ("#Verbosity", "", "", false, ""),
- ],
- false, false, []
+ new Arg("Sources", "--add-source", "IEnumerable", "By default, dotnet new install uses the hierarchy of NuGet configuration files from the current directory to determine the NuGet source the package can be installed from. If Sources is specified, the source will be added to the list of sources to be checked. To check the configured sources for the current directory use dotnet nuget list source. Available since .NET SDK 7.0.100.") { IsCollection = true },
+ new Arg("CheckOnly", "--check-only", "bool?", "Only checks for updates and displays the template packages to be updated, without applying any updates."),
+ new Arg("DryRun", "--dry-run", "bool?", "Only checks for updates and displays the template packages to be updated, without applying any updates."),
+ verbosityArg
+ ]
),
- (
+ new(
"DotNetNuGetDelete",
[
"Deletes or unlists a package from the server.",
ps,
"This command deletes or unlists a package from the server. For nuget.org, the action is to unlist the package.",
pf,
- CreateRef("dotnet-nuget-delete")
+ CreateCliRef("dotnet-nuget-delete")
],
["nuget", "delete", "$PackageName", "$PackageVersion"],
[
- ("PackageName", "", "string", true, "Name/ID of the package to delete."),
- ("PackageVersion", "", "string", true, "Version of the package to delete."),
- ("ForceEnglishOutput", "--force-english-output", "bool?", false, "Forces the application to run using an invariant, English-based culture."),
- ("ApiKey", "--api-key", "string", false, "The API key for the server."),
- ("NoServiceEndpoint", "--no-service-endpoint", "bool?", false, "Doesn't append \"api/v2/package\" to the source URL."),
- ("Source", "--source", "string", false, "Specifies the server URL. NuGet identifies a UNC or local folder source and simply copies the file there instead of pushing it using HTTP."),
+ new Arg("PackageName", "", "string", "Name/ID of the package to delete.") { IsProject = true },
+ new Arg("PackageVersion", "", "string", "Version of the package to delete.") { IsProject = true },
+ new Arg("ForceEnglishOutput", "--force-english-output", "bool?", "Forces the application to run using an invariant, English-based culture."),
+ new Arg("ApiKey", "--api-key", "string", "The API key for the server."),
+ new Arg("NoServiceEndpoint", "--no-service-endpoint", "bool?", "Doesn't append \"api/v2/package\" to the source URL."),
+ new Arg("Source", "--source", "string", "Specifies the server URL. NuGet identifies a UNC or local folder source and simply copies the file there instead of pushing it using HTTP.")
],
- false, false, ["--non-interactive"]
+ CommandTypes.Default,
+ "--non-interactive"
),
- (
+ new(
"DotNetNuGetLocalsClear",
[
"Clears local NuGet resources.",
ps,
"This command clears local NuGet resources in the http-request cache, temporary cache, or machine-wide global packages folder.",
pf,
- CreateRef("dotnet-nuget-locals")
+ CreateCliRef("dotnet-nuget-locals")
],
["nuget", "locals", "$CacheLocation"],
[
- ("CacheLocation", "", "NuGetCacheLocation?", true, "The cache location to clear."),
- ("ForceEnglishOutput", "--force-english-output", "bool?", false, "Forces the application to run using an invariant, English-based culture."),
+ new Arg("CacheLocation", "", "NuGetCacheLocation?", "The cache location to clear.") { IsProject = true },
+ new Arg("ForceEnglishOutput", "--force-english-output", "bool?", "Forces the application to run using an invariant, English-based culture.")
],
- false, false, ["--clear"]
+ CommandTypes.Default,
+ "--clear"
),
- (
+ new(
"DotNetNuGetLocalsList",
[
"Lists local NuGet resources.",
ps,
"This command lists local NuGet resources in the http-request cache, temporary cache, or machine-wide global packages folder.",
pf,
- CreateRef("dotnet-nuget-locals")
+ CreateCliRef("dotnet-nuget-locals")
],
["nuget", "locals", "$CacheLocation"],
[
- ("CacheLocation", "", "NuGetCacheLocation?", true, "The cache location to list."),
- ("ForceEnglishOutput", "--force-english-output", "bool?", false, "Forces the application to run using an invariant, English-based culture."),
+ new Arg("CacheLocation", "", "NuGetCacheLocation?", "The cache location to list.") { IsProject = true },
+ new Arg("ForceEnglishOutput", "--force-english-output", "bool?", "Forces the application to run using an invariant, English-based culture.")
],
- false, false, ["--list"]
+ CommandTypes.Default,
+ "--list"
),
- (
+ new(
"DotNetNuGetPush",
[
"Pushes a package to the server and publishes it.",
ps,
@"This command pushes a package to the server and publishes it. The push command uses server and credential details found in the system's NuGet config file or chain of config files. NuGet's default configuration is obtained by loading %AppData%\NuGet\NuGet.config (Windows) or $HOME/.nuget/NuGet/NuGet.Config (Linux/macOS), then loading any nuget.config or .nuget\nuget.config starting from the root of drive and ending in the current directory.",
pf,
- CreateRef("dotnet-nuget-push")
+ CreateCliRef("dotnet-nuget-push")
],
["nuget", "push", "$Package"],
[
- ("Package", "", "string", true, "Specifies the file path to the package to be pushed."),
- ("DisableBuffering", "--disable-buffering", "bool?", false, "Disables buffering when pushing to an HTTP(S) server to reduce memory usage."),
- ("ForceEnglishOutput", "--force-english-output", "bool?", false, "Forces the application to run using an invariant, English-based culture."),
- ("ApiKey", "--api-key", "string", false, "The API key for the server."),
- ("NoSymbols", "--no-symbols", "bool?", false, "Doesn't push symbols (even if present)."),
- ("NoServiceEndpoint", "--no-service-endpoint", "bool?", false, "Doesn't append \"api/v2/package\" to the source URL."),
- ("Source", "--source", "string", false, "Specifies the server URL. NuGet identifies a UNC or local folder source and simply copies the file there instead of pushing it using HTTP."),
- ("SkipDuplicate", "--skip-duplicate", "bool?", false, "When pushing multiple packages to an HTTP(S) server, treats any 409 Conflict response as a warning so that other pushes can continue."),
- ("SymbolApiKey", "--symbol-api-key", "string", false, "The API key for the symbol server."),
- ("SymbolSource", "--symbol-source", "string", false, "Specifies the symbol server URL."),
- ("Timeout", "--timeout", "int?", false, "Specifies the timeout for pushing to a server in seconds. Defaults to 300 seconds (5 minutes). Specifying 0 applies the default value."),
- ("#Verbosity", "", "", false, ""),
- ],
- false, false, []
+ new Arg("Package", "", "string", "Specifies the file path to the package to be pushed.") { IsProject = true },
+ new Arg("DisableBuffering", "--disable-buffering", "bool?", "Disables buffering when pushing to an HTTP(S) server to reduce memory usage."),
+ new Arg("ForceEnglishOutput", "--force-english-output", "bool?", "Forces the application to run using an invariant, English-based culture."),
+ new Arg("ApiKey", "--api-key", "string", "The API key for the server."),
+ new Arg("NoSymbols", "--no-symbols", "bool?", "Doesn't push symbols (even if present)."),
+ new Arg("NoServiceEndpoint", "--no-service-endpoint", "bool?", "Doesn't append \"api/v2/package\" to the source URL."),
+ new Arg("Source", "--source", "string", "Specifies the server URL. NuGet identifies a UNC or local folder source and simply copies the file there instead of pushing it using HTTP."),
+ new Arg("SkipDuplicate", "--skip-duplicate", "bool?", "When pushing multiple packages to an HTTP(S) server, treats any 409 Conflict response as a warning so that other pushes can continue."),
+ new Arg("SymbolApiKey", "--symbol-api-key", "string", "The API key for the symbol server."),
+ new Arg("SymbolSource", "--symbol-source", "string", "Specifies the symbol server URL."),
+ new Arg("Timeout", "--timeout", "int?", "Specifies the timeout for pushing to a server in seconds. Defaults to 300 seconds (5 minutes). Specifying 0 applies the default value."),
+ verbosityArg
+ ]
),
- (
+ new(
"DotNetNuGetAddSource",
[
"Add a NuGet source.",
ps,
"This command adds a new package source to your NuGet configuration files. When adding multiple package sources, be careful not to introduce a dependency confusion vulnerability.",
pf,
- CreateRef("dotnet-nuget-add-source")
+ CreateCliRef("dotnet-nuget-add-source")
],
["nuget", "add", "source", "$PackageSourcePath"],
[
- ("ValidAuthenticationTypes", "--valid-authentication-types", "IEnumerable", false, "List of valid authentication types for this source. Set this to basic if the server advertises NTLM or Negotiate and your credentials must be sent using the Basic mechanism, for instance when using a PAT with on-premises Azure DevOps Server. Other valid values include negotiate, kerberos, ntlm, and digest, but these values are unlikely to be useful."),
- ("PackageSourcePath", "", "string", true, "Path to the package source."),
- ("ConfigFile", "--configfile", "string", false, "The NuGet configuration file (nuget.config) to use. If specified, only the settings from this file will be used. If not specified, the hierarchy of configuration files from the current directory will be used."),
- ("AllowInsecureConnections", "--allow-insecure-connections", "bool?", false, "Allows HTTP connections for adding or updating packages. This method is not secure. Available since .NET 9 SDK."),
- ("Name", "--name", "string", false, "Name of the source."),
- ("Password", "--password", "string", false, "Password to be used when connecting to an authenticated source."),
- ("StorePasswordInClearText", "--store-password-in-clear-text", "bool?", false, "Enables storing portable package source credentials by disabling password encryption. Storing passwords in clear text is strongly discouraged."),
- ("Username", "--username", "string", false, "Username to be used when connecting to an authenticated source."),
- ],
- false, false, []
+ new Arg("ValidAuthenticationTypes", "--valid-authentication-types", "IEnumerable", "List of valid authentication types for this source. Set this to basic if the server advertises NTLM or Negotiate and your credentials must be sent using the Basic mechanism, for instance when using a PAT with on-premises Azure DevOps Server. Other valid values include negotiate, kerberos, ntlm, and digest, but these values are unlikely to be useful.") { IsCollection = true },
+ new Arg("PackageSourcePath", "", "string", "Path to the package source.") { IsProject = true },
+ new Arg("ConfigFile", "--configfile", "string", "The NuGet configuration file (nuget.config) to use. If specified, only the settings from this file will be used. If not specified, the hierarchy of configuration files from the current directory will be used."),
+ new Arg("AllowInsecureConnections", "--allow-insecure-connections", "bool?", "Allows HTTP connections for adding or updating packages. This method is not secure. Available since .NET 9 SDK."),
+ new Arg("Name", "--name", "string", "Name of the source."),
+ new Arg("Password", "--password", "string", "Password to be used when connecting to an authenticated source."),
+ new Arg("StorePasswordInClearText", "--store-password-in-clear-text", "bool?", "Enables storing portable package source credentials by disabling password encryption. Storing passwords in clear text is strongly discouraged."),
+ new Arg("Username", "--username", "string", "Username to be used when connecting to an authenticated source.")
+ ]
),
- (
+ new(
"DotNetNuGetDisableSource",
[
"Disable a NuGet source.",
ps,
"This command disables an existing source in your NuGet configuration files.",
pf,
- CreateRef("dotnet-nuget-disable-source")
+ CreateCliRef("dotnet-nuget-disable-source")
],
["nuget", "disable", "source", "$Name"],
[
- ("Name", "--name", "string", true, "Name of the source."),
- ("ConfigFile", "--configfile", "string", false, "The NuGet configuration file (nuget.config) to use. If specified, only the settings from this file will be used. If not specified, the hierarchy of configuration files from the current directory will be used. For more information, see Common NuGet Configurations."),
- ],
- false, false, []
+ new Arg("Name", "--name", "string", "Name of the source.") { IsProject = true },
+ new Arg("ConfigFile", "--configfile", "string", "The NuGet configuration file (nuget.config) to use. If specified, only the settings from this file will be used. If not specified, the hierarchy of configuration files from the current directory will be used. For more information, see Common NuGet Configurations.")
+ ]
),
- (
+ new(
"DotNetNuGetEnableSource",
[
"Enable a NuGet source.",
ps,
"This command enables an existing source in your NuGet configuration files.",
pf,
- CreateRef("dotnet-nuget-enable-source")
+ CreateCliRef("dotnet-nuget-enable-source")
],
["nuget", "enable", "source", "$Name"],
[
- ("Name", "--name", "string", true, "Name of the source."),
- ("ConfigFile", "--configfile", "string", false, "The NuGet configuration file (nuget.config) to use. If specified, only the settings from this file will be used. If not specified, the hierarchy of configuration files from the current directory will be used."),
- ],
- false, false, []
+ new Arg("Name", "--name", "string", "Name of the source.") { IsProject = true },
+ new Arg("ConfigFile", "--configfile", "string", "The NuGet configuration file (nuget.config) to use. If specified, only the settings from this file will be used. If not specified, the hierarchy of configuration files from the current directory will be used.")
+ ]
),
- (
+ new(
"DotNetNuGetListSource",
[
"Lists all configured NuGet sources.",
ps,
"This command lists all existing sources from your NuGet configuration files.",
pf,
- CreateRef("dotnet-nuget-list-source")
+ CreateCliRef("dotnet-nuget-list-source")
],
["nuget", "list", "source"],
[
- ("ConfigFile", "--configfile", "string", false, "The NuGet configuration file (nuget.config) to use. If specified, only the settings from this file will be used. If not specified, the hierarchy of configuration files from the current directory will be used. For more information, see Common NuGet Configurations."),
- ("Format", "--format", "NuGetListFormat?", false, "The format of the list command output: Detailed (the default) and Short."),
- ],
- false, false, []
+ new Arg("ConfigFile", "--configfile", "string", "The NuGet configuration file (nuget.config) to use. If specified, only the settings from this file will be used. If not specified, the hierarchy of configuration files from the current directory will be used. For more information, see Common NuGet Configurations."),
+ new Arg("Format", "--format", "NuGetListFormat?", "The format of the list command output: Detailed (the default) and Short.")
+ ]
),
- (
+ new(
"DotNetNuGetRemoveSource",
[
"Remove a NuGet source.",
ps,
"This command removes an existing source from your NuGet configuration files.",
pf,
- CreateRef("dotnet-nuget-remove-source")
+ CreateCliRef("dotnet-nuget-remove-source")
],
["nuget", "remove", "source", "$Name"],
[
- ("Name", "--name", "string", true, "Name of the source."),
- ("ConfigFile", "--configfile", "string", false, "The NuGet configuration file (nuget.config) to use. If specified, only the settings from this file will be used. If not specified, the hierarchy of configuration files from the current directory will be used. For more information, see Common NuGet Configurations."),
- ],
- false, false, []
+ new Arg("Name", "--name", "string", "Name of the source.") { IsProject = true },
+ new Arg("ConfigFile", "--configfile", "string", "The NuGet configuration file (nuget.config) to use. If specified, only the settings from this file will be used. If not specified, the hierarchy of configuration files from the current directory will be used. For more information, see Common NuGet Configurations.")
+ ]
),
- (
+ new(
"DotNetNuGetUpdateSource",
[
"Update a NuGet source.",
ps,
"This command updates an existing source in your NuGet configuration files.",
pf,
- CreateRef("dotnet-nuget-update-source")
+ CreateCliRef("dotnet-nuget-update-source")
],
["nuget", "update", "source", "$Name"],
[
- ("ValidAuthenticationTypes", "--valid-authentication-types", "IEnumerable", false, "List of valid authentication types for this source. Set this to basic if the server advertises NTLM or Negotiate and your credentials must be sent using the Basic mechanism, for instance when using a PAT with on-premises Azure DevOps Server. Other valid values include negotiate, kerberos, ntlm, and digest, but these values are unlikely to be useful."),
- ("Name", "--name", "string", true, "Name of the source."),
- ("ConfigFile", "--configfile", "string", false, "The NuGet configuration file (nuget.config) to use. If specified, only the settings from this file will be used. If not specified, the hierarchy of configuration files from the current directory will be used."),
- ("Password", "--password", "string", false, "Password to be used when connecting to an authenticated source."),
- ("Source", "", "string", true, "Path to the package source."),
- ("StorePasswordInClearText", "--store-password-in-clear-text", "bool?", false, "Enables storing portable package source credentials by disabling password encryption. Storing passwords in clear text is strongly discouraged."),
- ("Username", "--username", "string", false, "Username to be used when connecting to an authenticated source."),
- ],
- false, false, []
+ new Arg("ValidAuthenticationTypes", "--valid-authentication-types", "IEnumerable", "List of valid authentication types for this source. Set this to basic if the server advertises NTLM or Negotiate and your credentials must be sent using the Basic mechanism, for instance when using a PAT with on-premises Azure DevOps Server. Other valid values include negotiate, kerberos, ntlm, and digest, but these values are unlikely to be useful.") { IsCollection = true },
+ new Arg("Name", "--name", "string", "Name of the source.") { IsProject = true },
+ new Arg("ConfigFile", "--configfile", "string", "The NuGet configuration file (nuget.config) to use. If specified, only the settings from this file will be used. If not specified, the hierarchy of configuration files from the current directory will be used."),
+ new Arg("Password", "--password", "string", "Password to be used when connecting to an authenticated source."),
+ new Arg("Source", "--source", "string", "Path to the package source."),
+ new Arg("StorePasswordInClearText", "--store-password-in-clear-text", "bool?", "Enables storing portable package source credentials by disabling password encryption. Storing passwords in clear text is strongly discouraged."),
+ new Arg("Username", "--username", "string", "Username to be used when connecting to an authenticated source.")
+ ]
),
- (
+ new(
"DotNetNuGetVerify",
[
"Verifies a signed NuGet package.",
ps,
"This command verifies a signed NuGet package. This command requires a certificate root store that is valid for both code signing and timestamping. Also, this command may not be supported on some combinations of operating system and .NET SDK.",
pf,
- CreateRef("dotnet-nuget-verify")
+ CreateCliRef("dotnet-nuget-verify")
],
["nuget", "verify", "$Packages"],
[
- ("Packages", "", "IEnumerable", false, "Specifies the file path to the package(s) to be verified."),
- ("Fingerprints", "--certificate-fingerprint", "IEnumerable", false, "Verify that the signer certificate matches with one of the specified SHA256 fingerprints. This option can be supplied multiple times to provide multiple fingerprints."),
- ("All", "--all", "bool?", false, "Specifies that all verifications possible should be performed on the package(s). By default, only signatures are verified."),
- ("ConfigFile", "--configfile", "string", false, "The NuGet configuration file (nuget.config) to use. If specified, only the settings from this file will be used. If not specified, the hierarchy of configuration files from the current directory will be used."),
- ("#Verbosity", "", "", false, ""),
- ],
- false, false, []
+ new Arg("Packages", "", "IEnumerable", "Specifies the file path to the package(s) to be verified.") { IsCollection = true },
+ new Arg("Fingerprints", "--certificate-fingerprint", "IEnumerable", "Verify that the signer certificate matches with one of the specified SHA256 fingerprints. This option can be supplied multiple times to provide multiple fingerprints.") { IsCollection = true },
+ new Arg("All", "--all", "bool?", "Specifies that all verifications possible should be performed on the package(s). By default, only signatures are verified."),
+ new Arg("ConfigFile", "--configfile", "string", "The NuGet configuration file (nuget.config) to use. If specified, only the settings from this file will be used. If not specified, the hierarchy of configuration files from the current directory will be used."),
+ verbosityArg
+ ]
),
- (
+ new(
"DotNetNuGetTrustList",
[
"Lists all the trusted signers in the configuration.",
ps,
"This option will include all the certificates (with fingerprint and fingerprint algorithm) each signer has. If a certificate has a preceding [U], it means that certificate entry has allowUntrustedRoot set as true.",
pf,
- CreateRef("dotnet-nuget-trust#list")
+ CreateCliRef("dotnet-nuget-trust#list")
],
["nuget", "trust", "list"],
[
- ("ConfigFile", "--configfile", "string", false, "The NuGet configuration file (nuget.config) to use. If specified, only the settings from this file will be used. If not specified, the hierarchy of configuration files from the current directory will be used."),
- ("#Verbosity", "", "", false, ""),
- ],
- false, false, []
+ new Arg("ConfigFile", "--configfile", "string", "The NuGet configuration file (nuget.config) to use. If specified, only the settings from this file will be used. If not specified, the hierarchy of configuration files from the current directory will be used."),
+ verbosityArg
+ ]
),
- (
+ new(
"DotNetNuGetTrustSync",
[
"Deletes the current list of certificates and replaces them with an up-to-date list from the repository.",
- CreateRef("dotnet-nuget-trust#sync")
+ CreateCliRef("dotnet-nuget-trust#sync")
],
["nuget", "trust", "sync", "$Name"],
[
- ("Name", "", "string", true, "The name of the existing trusted signer to sync."),
- ("ConfigFile", "--configfile", "string", false, "The NuGet configuration file (nuget.config) to use. If specified, only the settings from this file will be used. If not specified, the hierarchy of configuration files from the current directory will be used."),
- ("#Verbosity", "", "", false, ""),
- ],
- false, false, []
+ new Arg("Name", "", "string", "The name of the existing trusted signer to sync.") { IsProject = true },
+ new Arg("ConfigFile", "--configfile", "string", "The NuGet configuration file (nuget.config) to use. If specified, only the settings from this file will be used. If not specified, the hierarchy of configuration files from the current directory will be used."),
+ verbosityArg
+ ]
),
- (
+ new(
"DotNetNuGetTrustRemove",
[
"Removes any trusted signers that match the given name.",
- CreateRef("dotnet-nuget-trust#sync")
+ CreateCliRef("dotnet-nuget-trust#sync")
],
["nuget", "trust", "remove", "$Name"],
[
- ("Name", "", "string", true, "The name of the existing trusted signer to remove."),
- ("ConfigFile", "--configfile", "string", false, "The NuGet configuration file (nuget.config) to use. If specified, only the settings from this file will be used. If not specified, the hierarchy of configuration files from the current directory will be used."),
- ("#Verbosity", "", "", false, ""),
- ],
- false, false, []
+ new Arg("Name", "", "string", "The name of the existing trusted signer to remove.") { IsProject = true },
+ new Arg("ConfigFile", "--configfile", "string", "The NuGet configuration file (nuget.config) to use. If specified, only the settings from this file will be used. If not specified, the hierarchy of configuration files from the current directory will be used."),
+ verbosityArg
+ ]
),
- (
+ new(
"DotNetNuGetTrustAuthor",
[
"Adds a trusted signer with the given name, based on the author signature of the package.",
- CreateRef("dotnet-nuget-trust#author")
+ CreateCliRef("dotnet-nuget-trust#author")
],
["nuget", "trust", "author", "$Name", "$Package"],
[
- ("Name", "", "string", true, "The name of the trusted signer to add. If NAME already exists in the configuration, the signature is appended."),
- ("Package", "", "string", true, "The given PACKAGE should be a local path to the signed .nupkg file."),
- ("AllowUntrustedRoot", "--allow-untrusted-root", "bool?", false, "Specifies if the certificate for the trusted signer should be allowed to chain to an untrusted root. This is not recommended."),
- ("ConfigFile", "--configfile", "string", false, "The NuGet configuration file (nuget.config) to use. If specified, only the settings from this file will be used. If not specified, the hierarchy of configuration files from the current directory will be used."),
- ("#Verbosity", "", "", false, ""),
- ],
- false, false, []
+ new Arg("Name", "", "string", "The name of the trusted signer to add. If NAME already exists in the configuration, the signature is appended.") { IsProject = true },
+ new Arg("Package", "", "string", "The given PACKAGE should be a local path to the signed .nupkg file.") { IsProject = true },
+ allowUntrustedRootArg,
+ new Arg("ConfigFile", "--configfile", "string", "The NuGet configuration file (nuget.config) to use. If specified, only the settings from this file will be used. If not specified, the hierarchy of configuration files from the current directory will be used."),
+ verbosityArg
+ ]
),
- (
+ new(
"DotNetNuGetTrustRepository",
[
"Adds a trusted signer with the given name, based on the repository signature or countersignature of a signed package.",
- CreateRef("dotnet-nuget-trust#repository")
+ CreateCliRef("dotnet-nuget-trust#repository")
],
["nuget", "trust", "repository", "$Name", "$Package"],
[
- ("Owners", "--owners", "IReadOnlyCollection", false, "List of trusted owners to further restrict the trust of a repository."),
- ("Name", "", "string", true, "The name of the trusted signer to add. If NAME already exists in the configuration, the signature is appended."),
- ("Package", "", "string", true, "The given PACKAGE should be a local path to the signed .nupkg file."),
- ("AllowUntrustedRoot", "--allow-untrusted-root", "bool?", false, "Specifies if the certificate for the trusted signer should be allowed to chain to an untrusted root. This is not recommended."),
- ("ConfigFile", "--configfile", "string", false, "The NuGet configuration file (nuget.config) to use. If specified, only the settings from this file will be used. If not specified, the hierarchy of configuration files from the current directory will be used."),
- ("#Verbosity", "", "", false, ""),
- ],
- false, false, []
+ ownersArg,
+ new Arg("Name", "", "string", "The name of the trusted signer to add. If NAME already exists in the configuration, the signature is appended.") { IsProject = true },
+ new Arg("Package", "", "string", "The given PACKAGE should be a local path to the signed .nupkg file.") { IsProject = true },
+ allowUntrustedRootArg,
+ new Arg("ConfigFile", "--configfile", "string", "The NuGet configuration file (nuget.config) to use. If specified, only the settings from this file will be used. If not specified, the hierarchy of configuration files from the current directory will be used."),
+ verbosityArg
+ ]
),
- (
+ new(
"DotNetNuGetTrustCertificate",
[
"Adds a trusted signer with the given name, based on a certificate fingerprint.",
- CreateRef("dotnet-nuget-trust#certificate")
+ CreateCliRef("dotnet-nuget-trust#certificate")
],
["nuget", "trust", "certificate", "$Name", "$Fingerprint"],
[
- ("Name", "", "string", true, "The name of the trusted signer to add. If a trusted signer with the given name already exists, the certificate item is added to that signer. Otherwise a trusted author is created with a certificate item from the given certificate information."),
- ("Fingerprint", "", "string", true, "The fingerprint of the certificate."),
- ("Algorithm", "--algorithm", "NuGetCertificateAlgorithm?", false, "Specifies the hash algorithm used to calculate the certificate fingerprint. Defaults to SHA256. Values supported are SHA256, SHA384 and SHA512."),
- ("AllowUntrustedRoot", "--allow-untrusted-root", "bool?", false, "Specifies if the certificate for the trusted signer should be allowed to chain to an untrusted root. This is not recommended."),
- ("ConfigFile", "--configfile", "string", false, "The NuGet configuration file (nuget.config) to use. If specified, only the settings from this file will be used. If not specified, the hierarchy of configuration files from the current directory will be used."),
- ("#Verbosity", "", "", false, ""),
- ],
- false, false, []
+ new Arg("Name", "", "string", "The name of the trusted signer to add. If a trusted signer with the given name already exists, the certificate item is added to that signer. Otherwise a trusted author is created with a certificate item from the given certificate information.") { IsProject = true },
+ new Arg("Fingerprint", "", "string", "The fingerprint of the certificate.") { IsProject = true },
+ new Arg("Algorithm", "--algorithm", "NuGetCertificateAlgorithm?", "Specifies the hash algorithm used to calculate the certificate fingerprint. Defaults to SHA256. Values supported are SHA256, SHA384 and SHA512."),
+ allowUntrustedRootArg,
+ new Arg("ConfigFile", "--configfile", "string", "The NuGet configuration file (nuget.config) to use. If specified, only the settings from this file will be used. If not specified, the hierarchy of configuration files from the current directory will be used."),
+ verbosityArg
+ ]
),
- (
+ new(
"DotNetNuGetTrustSource",
[
"Adds a trusted signer based on a given package source.",
- CreateRef("dotnet-nuget-trust#source")
+ CreateCliRef("dotnet-nuget-trust#source")
],
["nuget", "trust", "source", "$Name" ],
[
- ("Owners", "--owners", "IReadOnlyCollection", false, "List of trusted owners to further restrict the trust of a repository."),
- ("Name", "", "string", true, "The name of the trusted signer to add. If only <NAME> is provided without --<source-url>, the package source from your NuGet configuration files with the same name is added to the trusted list. If <NAME> already exists in the configuration, the package source is appended to it."),
- ("ConfigFile", "--configfile", "string", false, "The NuGet configuration file (nuget.config) to use. If specified, only the settings from this file will be used. If not specified, the hierarchy of configuration files from the current directory will be used."),
- ("SourceUrl", "--source-url", "string", false, "If a source-url is provided, it must be a v3 package source URL (like https://api.nuget.org/v3/index.json). Other package source types are not supported."),
- ("#Verbosity", "", "", false, ""),
- ],
- false, false, []
+ ownersArg,
+ new Arg("Name", "", "string", "The name of the trusted signer to add. If only <NAME> is provided without --<source-url>, the package source from your NuGet configuration files with the same name is added to the trusted list. If <NAME> already exists in the configuration, the package source is appended to it.") { IsProject = true },
+ new Arg("ConfigFile", "--configfile", "string", "The NuGet configuration file (nuget.config) to use. If specified, only the settings from this file will be used. If not specified, the hierarchy of configuration files from the current directory will be used."),
+ new Arg("SourceUrl", "--source-url", "string", "If a source-url is provided, it must be a v3 package source URL (like https://api.nuget.org/v3/index.json). Other package source types are not supported."),
+ verbosityArg
+ ]
),
- (
+ new(
"DotNetNuGetSign",
[
"Signs all the NuGet packages matching the first argument with a certificate.",
ps,
"This command signs all the packages matching the first argument with a certificate. The certificate with the private key can be obtained from a file or from a certificate installed in a certificate store by providing a subject name or a SHA-1 fingerprint. This command requires a certificate root store that is valid for both code signing and timestamping. Also, this command may not be supported on some combinations of operating system and .NET SDK.",
pf,
- CreateRef("dotnet-nuget-sign")
+ CreateCliRef("dotnet-nuget-sign")
],
["nuget", "sign", "$Packages"],
[
- ("Packages", "--owners", "IEnumerable", true, "Specifies the file path to the packages to be signed."),
- ("CertificatePath", "--certificate-path", "string", false, "Specifies the file path to the certificate to be used in signing the package. This option currently supports only PKCS12 (PFX) files that contain the certificate's private key."),
- ("CertificateStoreName", "--certificate-store-name", "string", false, "Specifies the name of the X.509 certificate store to use to search for the certificate. Defaults to \"My\", the X.509 certificate store for personal certificates. This option should be used when specifying the certificate via --certificate-subject-name or --certificate-fingerprint options."),
- ("CertificateStoreLocation", "--certificate-store-location", "string", false, "Specifies the name of the X.509 certificate store use to search for the certificate. Defaults to \"CurrentUser\", the X.509 certificate store used by the current user. This option should be used when specifying the certificate via --certificate-subject-name or --certificate-fingerprint options."),
- ("CertificateSubjectName", "--certificate-subject-name", "string", false, "Specifies the subject name of the certificate used to search a local certificate store for the certificate. The search is a case-insensitive string comparison using the supplied value, which finds all certificates with the subject name containing that string, regardless of other subject values. The certificate store can be specified by --certificate-store-name and --certificate-store-location options. This option currently supports only a single matching certificate in the result. If there are multiple matching certificates in the result, or no matching certificate in the result, the sign command will fail."),
- ("CertificateFingerprint", "--certificate-fingerprint", "string", false, "Specifies the fingerprint of the certificate used to search a local certificate store for the certificate. Starting with .NET 9, this option can be used to specify the SHA-1, SHA-256, SHA-384, or SHA-512 fingerprint of the certificate. However, a NU3043 warning is raised when a SHA-1 certificate fingerprint is used because it is no longer considered secure. All the previous versions of the .NET SDK continue to accept only SHA-1 certificate fingerprint."),
- ("CertificatePassword", "--certificate-password", "string", false, "Specifies the certificate password, if needed. If a certificate is password protected but no password is provided, the sign command will fail."),
- ("HashAlgorithm", "--hash-algorithm", "NuGetCertificateAlgorithm?", false, "Hash algorithm to be used to sign the package. Defaults to SHA256. Possible values are SHA256, SHA384, and SHA512."),
- ("Output", "--output", "string", false, "Specifies the directory where the signed package should be saved. If this option isn't specified, by default the original package is overwritten by the signed package."),
- ("Overwrite", "--overwrite", "bool?", false, "Indicate that the current signature should be overwritten. By default the command will fail if the package already has a signature."),
- ("TimestampHashAlgorithm", "--timestamp-hash-algorithm", "NuGetCertificateAlgorithm?", false, "Hash algorithm to be used by the RFC 3161 timestamp server. Defaults to SHA256."),
- ("TimestampingServer", "--timestamper", "string", false, "URL to an RFC 3161 timestamping server."),
- ("#Verbosity", "", "", false, ""),
- ],
- false, false, []
+ new Arg("Packages", "", "IEnumerable", "Specifies the file path to the packages to be signed.") { IsProject = true, IsCollection = true },
+ new Arg("CertificatePath", "--certificate-path", "string", "Specifies the file path to the certificate to be used in signing the package. This option currently supports only PKCS12 (PFX) files that contain the certificate's private key."),
+ new Arg("CertificateStoreName", "--certificate-store-name", "string", "Specifies the name of the X.509 certificate store to use to search for the certificate. Defaults to \"My\", the X.509 certificate store for personal certificates. This option should be used when specifying the certificate via --certificate-subject-name or --certificate-fingerprint options."),
+ new Arg("CertificateStoreLocation", "--certificate-store-location", "string", "Specifies the name of the X.509 certificate store use to search for the certificate. Defaults to \"CurrentUser\", the X.509 certificate store used by the current user. This option should be used when specifying the certificate via --certificate-subject-name or --certificate-fingerprint options."),
+ new Arg("CertificateSubjectName", "--certificate-subject-name", "string", "Specifies the subject name of the certificate used to search a local certificate store for the certificate. The search is a case-insensitive string comparison using the supplied value, which finds all certificates with the subject name containing that string, regardless of other subject values. The certificate store can be specified by --certificate-store-name and --certificate-store-location options. This option currently supports only a single matching certificate in the result. If there are multiple matching certificates in the result, or no matching certificate in the result, the sign command will fail."),
+ new Arg("CertificateFingerprint", "--certificate-fingerprint", "string", "Specifies the fingerprint of the certificate used to search a local certificate store for the certificate. Starting with .NET 9, this option can be used to specify the SHA-1, SHA-256, SHA-384, or SHA-512 fingerprint of the certificate. However, a NU3043 warning is raised when a SHA-1 certificate fingerprint is used because it is no longer considered secure. All the previous versions of the .NET SDK continue to accept only SHA-1 certificate fingerprint."),
+ new Arg("CertificatePassword", "--certificate-password", "string", "Specifies the certificate password, if needed. If a certificate is password protected but no password is provided, the sign command will fail."),
+ new Arg("HashAlgorithm", "--hash-algorithm", "NuGetCertificateAlgorithm?", "Hash algorithm to be used to sign the package. Defaults to SHA256. Possible values are SHA256, SHA384, and SHA512."),
+ new Arg("Output", "--output", "string", "Specifies the directory where the signed package should be saved. If this option isn't specified, by default the original package is overwritten by the signed package."),
+ new Arg("Overwrite", "--overwrite", "bool?", "Indicate that the current signature should be overwritten. By default the command will fail if the package already has a signature."),
+ new Arg("TimestampHashAlgorithm", "--timestamp-hash-algorithm", "NuGetCertificateAlgorithm?", "Hash algorithm to be used by the RFC 3161 timestamp server. Defaults to SHA256."),
+ new Arg("TimestampingServer", "--timestamper", "string", "URL to an RFC 3161 timestamping server."),
+ verbosityArg
+ ]
),
- (
+ new(
"DotNetNuGetWhy",
[
"Shows the dependency graph for a particular package.",
ps,
@"This command shows the dependency graph for a particular package for a given project or solution. Starting from the .NET 9 SDK, it's possible to pass a NuGet assets file in place of the project file, in order to use the command with projects that can't be restored with the .NET SDK. First, restore the project in Visual Studio, or msbuild.exe. By default the assets file is in the project's obj\ directory, but you can find the location with msbuild.exe path\to\project.proj -getProperty:ProjectAssetsFile. Finally, run dotnet nuget why path\to\project.assets.json SomePackage.",
pf,
- CreateRef("dotnet-nuget-why")
+ CreateCliRef("dotnet-nuget-why")
],
["nuget", "why", "$Project", "$Package"],
[
- ("Frameworks", "--framework", "IEnumerable", false, "The target frameworks for which dependency graphs are shown."),
- ("Project", "", "string", true, "The project or solution file to operate on. If a directory is specified, the command searches the directory for a project or solution file. If more than one project or solution is found, an error is thrown."),
- ("Package", "", "string", true, "The package name to look up in the dependency graph."),
+ new Arg("Frameworks", "--framework", "IEnumerable", "The target frameworks for which dependency graphs are shown.") { IsCollection = true },
+ new Arg("Project", "", "string", "The project or solution file to operate on. If a directory is specified, the command searches the directory for a project or solution file. If more than one project or solution is found, an error is thrown.") { IsProject = true },
+ new Arg("Package", "", "string", "The package name to look up in the dependency graph.") { IsProject = true }
+ ]
+ ),
+ new(
+ "DotNetNuConfigGet",
+ [
+ "Gets the NuGet configuration settings that will be applied.",
+ ps,
+ "This command gets the NuGet configuration settings that will be applied from the config section.",
+ pf,
+ CreateCliRef("dotnet-nuget-config-get")
],
- false, false, []
+ ["nuget", "config", "get", "$ConfigKey"],
+ [
+ new Arg("ConfigKey", "", "string", "ALL gets all merged NuGet configuration settings from multiple NuGet configuration files that will be applied, when invoking NuGet command from the working directory path. Otherwise gets the effective value of the specified configuration settings of the config section.") { IsProject = true },
+ new Arg("ShowPath", "--show-path", "bool?", "Indicate that the NuGet configuration file path will be shown beside the configuration settings."),
+ new Arg("Directory", "--working-directory", "string", "Specifies the directory to start from when listing configuration files. If not specified, the current directory is used.")
+ ]
),
- (
+ new(
"DotNetRun",
[
"Runs source code without any explicit compile or launch commands.",
@@ -845,51 +817,34 @@ namespace HostApi;
" .Build().EnsureSuccess();",
"",
"",
- CreateRef("dotnet-run")
+ CreateCliRef("dotnet-run")
],
["run", "$Project"],
[
- ("#Props", "", "", false, ""),
- ("#Project", "", "", false, ""),
- ("#Arch", "", "", false, ""),
- ("#Configuration", "", "", false, ""),
- ("#Framework", "", "", false, ""),
- ("#Force", "", "", false, ""),
- ("LaunchProfile", "--launch-profile", "string", false, "The name of the launch profile (if any) to use when launching the application. Launch profiles are defined in the launchSettings.json file and are typically called Development, Staging, and Production."),
- ("#NoBuild", "", "", false, ""),
- ("#NoDependencies", "", "", false, ""),
- ("NoLaunchProfile", "--no-launch-profile", "bool?", false, "Doesn't try to use launchSettings.json to configure the application."),
- ("#NoRestore", "", "", false, ""),
- ("#OS", "", "", false, ""),
- ("#Runtime", "", "", false, ""),
- ("#TerminalLogger", "", "", false, ""),
- ("#Verbosity", "", "", false, ""),
- ],
- false, false, []
+ propsArg,
+ projectArg,
+ archArg,
+ configurationArg,
+ frameworkArg,
+ forceArg,
+ new Arg("LaunchProfile", "--launch-profile", "string", "The name of the launch profile (if any) to use when launching the application. Launch profiles are defined in the launchSettings.json file and are typically called Development, Staging, and Production."),
+ noBuildArg,
+ noDependenciesArg,
+ new Arg("NoLaunchProfile", "--no-launch-profile", "bool?", "Doesn't try to use launchSettings.json to configure the application."),
+ noRestoreArg,
+ osArg,
+ runtimeArg,
+ terminalLoggerArg,
+ verbosityArg
+ ]
)
};
#>
using Internal.DotNet;
<#
- var args = commonArgs.ToDictionary(i => i.PropertyName, i => i);
foreach (var command in commands)
{
- for (var i = 0; i < command.Args.Length; i++)
- {
- var arg = command.Args[i];
- if (arg.PropertyName.StartsWith("#") && args.TryGetValue(arg.PropertyName.Substring(1), out var newArg))
- {
- var comments = arg.Comments;
- if (!string.IsNullOrWhiteSpace(comments))
- {
- newArg.Comments = comments;
- }
-
- command.Args[i] = newArg;
- }
- }
-
var name = command.Name;
var commandArgs = new List();
foreach (var arg in command.CommandArgs)
@@ -897,8 +852,8 @@ using Internal.DotNet;
if (arg.StartsWith("$"))
{
var curArg = arg.Substring(1);
- var notEmpty = command.Args.FirstOrDefault(i => i.PropertyName == curArg && IsCollection(i.Type));
- if (!string.IsNullOrWhiteSpace(notEmpty.PropertyName))
+ var notEmpty = command.Args.FirstOrDefault(i => i.PropertyName == curArg && i.IsCollection);
+ if (notEmpty is not null && !string.IsNullOrWhiteSpace(notEmpty.PropertyName))
{
var compositeArg = $"new [] {{{string.Join(", ", commandArgs)}}}.Concat({curArg}).ToArray()";
commandArgs.Clear();
@@ -917,33 +872,33 @@ using Internal.DotNet;
#>
///
<#
- foreach (var comment in command.Comments)
- {
+ foreach (var comment in command.Comments)
+ {
#>
/// <#= comment #>
<#
- }
+ }
#>
///
/// Specifies the set of command line arguments to use when starting the tool.
/// Specifies the set of environment variables that apply to this process and its child processes.
<#
- foreach (var arg in command.Args.Where(i => IsCollection(i.Type)))
- {
+ foreach (var arg in command.Args.Where(i => i.IsCollection))
+ {
#>
/// <#= arg.Comments #>
<#
- }
+ }
#>
/// Overrides the tool executable path.
/// Specifies the working directory for the tool to be started.
<#
- foreach (var arg in command.Args.Where(i => !IsCollection(i.Type)))
- {
+ foreach (var arg in command.Args.Where(i => !i.IsCollection))
+ {
#>
/// <#= arg.Comments #>
<#
- }
+ }
#>
/// Enables diagnostic output.
/// Specifies a short name for this operation.
@@ -952,27 +907,27 @@ public partial record <#= command.Name #>(
IEnumerable Args,
IEnumerable<(string name, string value)> Vars,
<#
- var initializer = string.Join(", ", new [] {"args", "[]"}.Concat(Enumerable.Repeat("[]", command.Args.Count(i => IsCollection(i.Type)))));
- var fullInitializer = string.Join(", ", new [] {"[]", "[]"}.Concat(Enumerable.Repeat("[]", command.Args.Count(i => IsCollection(i.Type)))));
- foreach (var arg in command.Args)
- {
- var type = arg.Type;
- var defaultValue = "";
- if (type == "string")
- {
- defaultValue = " = \"\"";
- }
- else
+ var initializer = string.Join(", ", new[] {"args", "[]"}.Concat(Enumerable.Repeat("[]", command.Args.Count(i => i.IsCollection))));
+ var fullInitializer = string.Join(", ", new[] {"[]", "[]"}.Concat(Enumerable.Repeat("[]", command.Args.Count(i => i.IsCollection))));
+ foreach (var arg in command.Args)
{
- if (!IsCollection(type))
+ var type = arg.Type;
+ var defaultValue = "";
+ if (type == "string")
{
- defaultValue = " = default";
+ defaultValue = " = \"\"";
+ }
+ else
+ {
+ if (!arg.IsCollection)
+ {
+ defaultValue = " = default";
+ }
}
- }
#>
<#= type #> <#= arg.PropertyName #><#= defaultValue #>,
<#
- }
+ }
#>
string ExecutablePath = "",
string WorkingDirectory = "",
@@ -1005,84 +960,84 @@ public partial record <#= command.Name #>(
.WithWorkingDirectory(WorkingDirectory)
.WithVars(Vars.ToArray())
<#
- foreach (var arg in command.CommandArgs)
- {
- if (arg.StartsWith("$"))
+ foreach (var arg in command.CommandArgs)
{
- var notEmptyArg = arg.Substring(1);
- var notEmpty = command.Args.FirstOrDefault(i => i.PropertyName == notEmptyArg && IsCollection(i.Type));
- if (!string.IsNullOrWhiteSpace(notEmpty.PropertyName))
+ if (arg.StartsWith("$"))
{
- notEmptyArg = $"{notEmptyArg}.ToArray()";
- }
+ var notEmptyArg = arg.Substring(1);
+ var notEmpty = command.Args.FirstOrDefault(i => i.PropertyName == notEmptyArg && i.IsCollection);
+ if (notEmpty is not null && !string.IsNullOrWhiteSpace(notEmpty.PropertyName))
+ {
+ notEmptyArg = $"{notEmptyArg}.ToArray()";
+ }
#>
.AddNotEmptyArgs(<#= notEmptyArg #>.ToArg())
<#
- }
- else
- {
+ }
+ else
+ {
#>
.AddArgs("<#= arg #>")
<#
+ }
}
- }
#>
<#
- if (command.IsBuild)
- {
+ if ((command.CommandTypes & CommandTypes.Build) == CommandTypes.Build)
+ {
#>
.AddMSBuildLoggers(host, Verbosity)
<#
- }
+ }
- if (command.IsTests)
- {
+ if ((command.CommandTypes & CommandTypes.Test) == CommandTypes.Test)
+ {
#>
.AddTestLoggers(host, Loggers)
<#
- }
-
- foreach (var additionalArg in command.AdditionalArgs)
- {
+ }
+
+ foreach (var additionalArg in command.AdditionalArgs)
+ {
#>
.AddArgs("<#= additionalArg #>")
<#
- }
+ }
- foreach (var arg in command.Args.Where(i => !i.IsProject).Where(i => IsCollection(i.Type) && i.ArgName != "--property"))
- {
+ foreach (var arg in command.Args.Where(i => !i.IsProject).Where(i => i.IsCollection && i.ArgName != "--property"))
+ {
#>
- .AddArgs(<#= arg.PropertyName #>.ToArgs("<#= arg.ArgName #>"))
+ .AddArgs(<#= arg.PropertyName #>.ToArgs("<#= arg.ArgName #>", "<#= arg.CollectionSeparator #>"))
<#
- }
+ }
- foreach(var arg in command.Args.Where(i => !i.IsProject).Where(i => !string.IsNullOrWhiteSpace(i.ArgName) && !i.Type.StartsWith("bool") && !IsCollection(i.Type)))
- {
+ foreach (var arg in command.Args.Where(i => !i.IsProject).Where(i => !string.IsNullOrWhiteSpace(i.ArgName) && !i.Type.StartsWith("bool") && !i.IsCollection))
+ {
#>
- .AddArgs(<#= arg.PropertyName #>.ToArgs("<#= arg.ArgName #>"))
+ .AddArgs(<#= arg.PropertyName #>.ToArgs("<#= arg.ArgName #>", "<#= arg.CollectionSeparator #>"))
<#
- }
+ }
#>
.AddBooleanArgs(
<#
- var boolArgs = command.Args.Where(i => !string.IsNullOrWhiteSpace(i.ArgName) && i.Type.StartsWith("bool")).ToArray();
- for (var i = 0; i < boolArgs.Length; i++)
- {
- var arg = boolArgs[i];
+ var boolArgs = command.Args.Where(i => !string.IsNullOrWhiteSpace(i.ArgName) && i.Type.StartsWith("bool")).ToArray();
+ for (var i = 0; i < boolArgs.Length; i++)
+ {
+ var arg = boolArgs[i];
#>
("<#= arg.ArgName #>", <#= arg.PropertyName #>),
<#
- }
+ }
#>
("--diagnostics", Diagnostics)
)
<#
- foreach (var arg in command.Args.Where(i => !string.IsNullOrWhiteSpace(i.ArgName) && IsCollection(i.Type) && i.ArgName == "--property").ToArray())
- {
+ foreach (var arg in command.Args.Where(i => !string.IsNullOrWhiteSpace(i.ArgName) && i.IsCollection && i.ArgName == "--property").ToArray())
+ {
#>
.AddProps("--property", <#= arg.PropertyName #>.ToArray())
<#
- }
+ }
#>
.AddArgs(Args.ToArray());
}
@@ -1094,3 +1049,44 @@ public partial record <#= command.Name #>(
<#
}
#>
+
+<#+
+ public record Arg(
+ string PropertyName,
+ string ArgName,
+ string Type,
+ string Comments)
+ {
+ public string PropertyName { get; } = PropertyName;
+ public string ArgName { get; } = ArgName;
+ public string Type { get; } = Type;
+ public string Comments { get; set; } = Comments;
+ public bool IsProject { get; set; }
+ public bool IsCollection { get; set; }
+ public string CollectionSeparator { get; set; } = "";
+ }
+
+ [Flags]
+ public enum CommandTypes
+ {
+ Default = 0,
+ Build = 1,
+ Test = 2
+ }
+
+ public record Command(
+ string Name,
+ string[] Comments,
+ string[] CommandArgs,
+ Arg[] Args,
+ CommandTypes CommandTypes = CommandTypes.Default,
+ params string[] AdditionalArgs)
+ {
+ public string Name { get; } = Name;
+ public string[] Comments { get; } = Comments;
+ public string[] CommandArgs { get; } = CommandArgs;
+ public Arg[] Args { get; } = Args;
+ public CommandTypes CommandTypes { get; } = CommandTypes;
+ public string[] AdditionalArgs { get; } = AdditionalArgs;
+ }
+#>
\ No newline at end of file
diff --git a/CSharpInteractive.HostApi/DotNetLanguage.cs b/CSharpInteractive.HostApi/DotNetLanguage.cs
index 7ab8b169..9cae78a5 100644
--- a/CSharpInteractive.HostApi/DotNetLanguage.cs
+++ b/CSharpInteractive.HostApi/DotNetLanguage.cs
@@ -23,12 +23,12 @@ public enum DotNetLanguage
///
/// SQL
///
- SQL,
+ Sql,
///
/// JSON
///
- JSON,
+ Json,
///
/// TypeScript
@@ -38,14 +38,15 @@ public enum DotNetLanguage
internal static class DotNetLanguageExtensions
{
- public static string[] ToArgs(this DotNetLanguage? language, string name) =>
+ // ReSharper disable once UnusedParameter.Global
+ public static string[] ToArgs(this DotNetLanguage? language, string name, string collectionSeparator) =>
language switch
{
DotNetLanguage.CSharp => [name, "\"C#\""],
DotNetLanguage.FSharp => [name, "\"F#\""],
DotNetLanguage.VisualBasic => [name, "VB"],
- DotNetLanguage.SQL => [name, "VB"],
- DotNetLanguage.JSON => [name, "JSON"],
+ DotNetLanguage.Sql => [name, "VB"],
+ DotNetLanguage.Json => [name, "JSON"],
DotNetLanguage.TypeScript => [name, "TypeScript"],
_ => []
};
diff --git a/CSharpInteractive.HostApi/DotNetNewListColumn.cs b/CSharpInteractive.HostApi/DotNetNewListColumn.cs
index f18d7438..016d01ff 100644
--- a/CSharpInteractive.HostApi/DotNetNewListColumn.cs
+++ b/CSharpInteractive.HostApi/DotNetNewListColumn.cs
@@ -1,4 +1,5 @@
-namespace HostApi;
+// ReSharper disable UnusedMember.Global
+namespace HostApi;
///
///
@@ -28,7 +29,8 @@ public enum DotNetNewListColumn
internal static class DotNetNewListColumnExtensions
{
- public static string[] ToArgs(this IEnumerable columns, string name)
+ // ReSharper disable once UnusedParameter.Global
+ public static string[] ToArgs(this IEnumerable columns, string name, string collectionSeparator)
{
var columnsStr = string.Join(",", columns.Select(i => i.ToString()));
return string.IsNullOrWhiteSpace(columnsStr) ? [] : [name, columnsStr];
diff --git a/CSharpInteractive.HostApi/DotNetRollForward.cs b/CSharpInteractive.HostApi/DotNetRollForward.cs
index f97eab93..705e22b1 100644
--- a/CSharpInteractive.HostApi/DotNetRollForward.cs
+++ b/CSharpInteractive.HostApi/DotNetRollForward.cs
@@ -1,4 +1,5 @@
-namespace HostApi;
+// ReSharper disable UnusedMember.Global
+namespace HostApi;
///
/// Controls how roll forward is applied to the app.
diff --git a/CSharpInteractive.HostApi/DotNetTemplateType.cs b/CSharpInteractive.HostApi/DotNetTemplateType.cs
index 08d5f66c..73b3ba68 100644
--- a/CSharpInteractive.HostApi/DotNetTemplateType.cs
+++ b/CSharpInteractive.HostApi/DotNetTemplateType.cs
@@ -1,4 +1,5 @@
-namespace HostApi;
+// ReSharper disable UnusedMember.Global
+namespace HostApi;
///
/// Template type.
diff --git a/CSharpInteractive.HostApi/DotNetTerminalLogger.cs b/CSharpInteractive.HostApi/DotNetTerminalLogger.cs
index 5b7bb3c1..44d1b9cf 100644
--- a/CSharpInteractive.HostApi/DotNetTerminalLogger.cs
+++ b/CSharpInteractive.HostApi/DotNetTerminalLogger.cs
@@ -1,4 +1,5 @@
-namespace HostApi;
+// ReSharper disable UnusedMember.Global
+namespace HostApi;
///
/// Terminal logger modes.
diff --git a/CSharpInteractive.HostApi/Internal/DotNet/DotNetCommandLineExtensions.cs b/CSharpInteractive.HostApi/Internal/DotNet/DotNetCommandLineExtensions.cs
index a963181e..ea68d1db 100644
--- a/CSharpInteractive.HostApi/Internal/DotNet/DotNetCommandLineExtensions.cs
+++ b/CSharpInteractive.HostApi/Internal/DotNet/DotNetCommandLineExtensions.cs
@@ -138,20 +138,23 @@ public static CommandLine AddProps(this CommandLine cmd, string propertyName, pa
cmd.AddArgs(props.Select(i => $"{propertyName}:{i.name}={i.value}")
.ToArray());
- public static string[] ToArgs(this T value, string name)
+ // ReSharper disable once UnusedParameter.Global
+ public static string[] ToArgs(this T value, string name, string collectionSeparator)
{
var valueStr = value?.ToString();
return string.IsNullOrWhiteSpace(valueStr) ? [] : [name, valueStr!];
}
- public static string[] ToArgs(this IEnumerable values, string name) =>
- values.SelectMany(value => string.IsNullOrWhiteSpace(value) ? [] : new [] {name, value}).ToArray();
-
- public static string[] ToArgs(this IReadOnlyCollection values, string name)
+ public static string[] ToArgs(this IEnumerable values, string name, string collectionSeparator)
{
- var str = string.Join(",", values);
+ if (string.IsNullOrWhiteSpace(collectionSeparator))
+ {
+ return values.SelectMany(value => string.IsNullOrWhiteSpace(value) ? [] : new[] {name, value}).ToArray();
+ }
+
+ var str = string.Join(collectionSeparator, values);
return string.IsNullOrWhiteSpace(str) ? [] : [name, str];
}
-
+
public static string ToArg(this T value) => value?.ToString() ?? "";
}
\ No newline at end of file
diff --git a/CSharpInteractive.HostApi/NuGetAuthenticationType.cs b/CSharpInteractive.HostApi/NuGetAuthenticationType.cs
index e94053f6..b1bf5e1f 100644
--- a/CSharpInteractive.HostApi/NuGetAuthenticationType.cs
+++ b/CSharpInteractive.HostApi/NuGetAuthenticationType.cs
@@ -1,4 +1,5 @@
-namespace HostApi;
+// ReSharper disable UnusedMember.Global
+namespace HostApi;
///
/// NuGet authentication types.
@@ -33,7 +34,8 @@ public enum NuGetAuthenticationType
internal static class NuGetAuthenticationTypeExtensions
{
- public static string[] ToArgs(this IEnumerable authenticationTypes, string name)
+ // ReSharper disable once UnusedParameter.Global
+ public static string[] ToArgs(this IEnumerable authenticationTypes, string name, string collectionSeparator)
{
var authenticationTypesStr = string.Join(",", authenticationTypes.Select(i => i.ToString().ToLowerInvariant()));
return string.IsNullOrWhiteSpace(authenticationTypesStr) ? [] : [name, authenticationTypesStr];
diff --git a/CSharpInteractive.HostApi/NuGetCertificateAlgorithm.cs b/CSharpInteractive.HostApi/NuGetCertificateAlgorithm.cs
index 84ec59c9..1a04c0e7 100644
--- a/CSharpInteractive.HostApi/NuGetCertificateAlgorithm.cs
+++ b/CSharpInteractive.HostApi/NuGetCertificateAlgorithm.cs
@@ -1,29 +1,31 @@
-namespace HostApi;
+// ReSharper disable UnusedMember.Global
+namespace HostApi;
///
-///
+/// NuGet certificate algorithm.
///
public enum NuGetCertificateAlgorithm
{
///
- ///
+ /// Sha256
///
Sha256,
///
- ///
+ /// Sha384
///
Sha384,
///
- ///
+ /// Sha512
///
Sha512
}
internal static class NuGetCertificateAlgorithmExtensions
{
- public static string[] ToArgs(this NuGetCertificateAlgorithm? algorithm, string name)
+ // ReSharper disable once UnusedParameter.Global
+ public static string[] ToArgs(this NuGetCertificateAlgorithm? algorithm, string name, string collectionSeparator)
{
var algorithmStr = algorithm?.ToString().ToUpperInvariant();
return algorithmStr is null ? [] : [name, algorithmStr];
diff --git a/CSharpInteractive.HostApi/NuGetListFormat.cs b/CSharpInteractive.HostApi/NuGetListFormat.cs
index 53db024c..f62b3dee 100644
--- a/CSharpInteractive.HostApi/NuGetListFormat.cs
+++ b/CSharpInteractive.HostApi/NuGetListFormat.cs
@@ -1,4 +1,5 @@
-namespace HostApi;
+// ReSharper disable UnusedMember.Global
+namespace HostApi;
///
/// The format of the nuget list command output.
diff --git a/CSharpInteractive.Tests/README_TEMPLATE.md b/CSharpInteractive.Tests/README_TEMPLATE.md
index e3f72789..96051856 100644
--- a/CSharpInteractive.Tests/README_TEMPLATE.md
+++ b/CSharpInteractive.Tests/README_TEMPLATE.md
@@ -486,15 +486,16 @@ var result = new DockerRun(cmd, "mcr.microsoft.com/dotnet/sdk")
using HostApi;
// Creates a new library project, running a command like: "dotnet new classlib -n MyLib --force"
-new DotNetNew("xunit", "-n", "MyLib", "--force")
- .Build()
- .EnsureSuccess();
+new DotNetNew()
+ .WithTemplateName("xunit")
+ .WithName("MyLib")
+ .WithForce(true)
+ .Build().EnsureSuccess();
// Builds the library project, running a command like: "dotnet build" from the directory "MyLib"
var result = new DotNetBuild()
.WithWorkingDirectory("MyLib")
- .Build()
- .EnsureSuccess();
+ .Build().EnsureSuccess();
// The "result" variable provides details about a build
result.Errors.Any(message => message.State == BuildMessageState.StdError).ShouldBeFalse();
@@ -522,25 +523,25 @@ result.Tests.Count(test => test.State == TestState.Finished).ShouldBe(1);
using HostApi;
// Creates a new library project, running a command like: "dotnet new classlib -n MyLib --force"
-var result = new DotNetNew("classlib", "-n", "MyLib", "--force")
- .Build()
- .EnsureSuccess();
+var result = new DotNetNew()
+ .WithTemplateName("classlib")
+ .WithName("MyLib")
+ .WithForce(true)
+ .Build().EnsureSuccess();
result.ExitCode.ShouldBe(0);
// Builds the library project, running a command like: "dotnet build" from the directory "MyLib"
result = new DotNetBuild()
.WithWorkingDirectory("MyLib")
- .Build()
- .EnsureSuccess();
+ .Build().EnsureSuccess();
result.ExitCode.ShouldBe(0);
// Clean the project, running a command like: "dotnet clean" from the directory "MyLib"
result = new DotNetClean()
.WithWorkingDirectory("MyLib")
- .Build()
- .EnsureSuccess();
+ .Build().EnsureSuccess();
// The "result" variable provides details about a build
result.ExitCode.ShouldBe(0);
@@ -576,23 +577,24 @@ version.ShouldNotBeNull();
using HostApi;
// Creates a new test project, running a command like: "dotnet new mstest -n MyTests --force"
-var result = new DotNetNew("mstest", "-n", "MyTests", "--force")
- .Build()
- .EnsureSuccess();
+var result = new DotNetNew()
+ .WithTemplateName("mstest")
+ .WithName("MyTests")
+ .WithForce(true)
+ .Build().EnsureSuccess();
-result.ExitCode.ShouldBe(0);
+result.ExitCode.ShouldBe(0, result.ToString());
// Runs tests via a command like: "dotnet msbuild /t:VSTest" from the directory "MyTests"
result = new MSBuild()
.WithTarget("VSTest")
.WithWorkingDirectory("MyTests")
- .Build()
- .EnsureSuccess();
+ .Build().EnsureSuccess();
// The "result" variable provides details about a build
-result.ExitCode.ShouldBe(0);
-result.Summary.Tests.ShouldBe(1);
-result.Tests.Count(test => test.State == TestState.Finished).ShouldBe(1);
+result.ExitCode.ShouldBe(0, result.ToString());
+result.Summary.Tests.ShouldBe(1, result.ToString());
+result.Tests.Count(test => test.State == TestState.Finished).ShouldBe(1, result.ToString());
```
@@ -606,9 +608,11 @@ result.Tests.Count(test => test.State == TestState.Finished).ShouldBe(1);
using HostApi;
// Creates a new library project, running a command like: "dotnet new classlib -n MyLib --force"
-var result = new DotNetNew("classlib", "-n", "MyLib", "--force")
- .Build()
- .EnsureSuccess();
+var result = new DotNetNew()
+ .WithTemplateName("classlib")
+ .WithName("MyLib")
+ .WithForce(true)
+ .Build().EnsureSuccess();
result.ExitCode.ShouldBe(0);
@@ -616,8 +620,7 @@ result.ExitCode.ShouldBe(0);
result = new DotNetPack()
.WithWorkingDirectory("MyLib")
.AddProps(("version", "1.2.3"))
- .Build()
- .EnsureSuccess();
+ .Build().EnsureSuccess();
result.ExitCode.ShouldBe(0);
```
@@ -633,9 +636,12 @@ result.ExitCode.ShouldBe(0);
using HostApi;
// Creates a new library project, running a command like: "dotnet new classlib -n MyLib --force"
-var result = new DotNetNew("classlib", "-n", "MyLib", "--force", "-f", "net8.0")
- .Build()
- .EnsureSuccess();
+var result = new DotNetNew()
+ .WithTemplateName("classlib")
+ .AddArgs("-f", "net8.0")
+ .WithName("MyLib")
+ .WithForce(true)
+ .Build().EnsureSuccess();
result.ExitCode.ShouldBe(0);
@@ -643,8 +649,7 @@ result.ExitCode.ShouldBe(0);
result = new DotNetPublish()
.WithWorkingDirectory("MyLib")
.WithFramework("net8.0")
- .Build()
- .EnsureSuccess();
+ .Build().EnsureSuccess();
result.ExitCode.ShouldBe(0);
```
@@ -660,17 +665,18 @@ result.ExitCode.ShouldBe(0);
using HostApi;
// Creates a new library project, running a command like: "dotnet new classlib -n MyLib --force"
-var result = new DotNetNew("classlib", "-n", "MyLib", "--force")
- .Build()
- .EnsureSuccess();
+var result = new DotNetNew()
+ .WithTemplateName("classlib")
+ .WithName("MyLib")
+ .WithForce(true)
+ .Build().EnsureSuccess();
result.ExitCode.ShouldBe(0);
// Restore the project, running a command like: "dotnet restore" from the directory "MyLib"
result = new DotNetRestore()
.WithWorkingDirectory("MyLib")
- .Build()
- .EnsureSuccess();
+ .Build().EnsureSuccess();
result.ExitCode.ShouldBe(0);
```
@@ -686,9 +692,11 @@ result.ExitCode.ShouldBe(0);
using HostApi;
// Creates a new console project, running a command like: "dotnet new console -n MyApp --force"
-var result = new DotNetNew("console", "-n", "MyApp", "--force")
- .Build()
- .EnsureSuccess();
+var result = new DotNetNew()
+ .WithTemplateName("console")
+ .WithName("MyApp")
+ .WithForce(true)
+ .Build().EnsureSuccess();
result.ExitCode.ShouldBe(0);
@@ -715,9 +723,11 @@ stdOut.ShouldBe(new[] {"Hello, World!"});
using HostApi;
// Creates a new test project, running a command like: "dotnet new mstest -n MyTests --force"
-var result = new DotNetNew("mstest", "-n", "MyTests", "--force")
- .Build()
- .EnsureSuccess();
+var result = new DotNetNew()
+ .WithTemplateName("mstest")
+ .WithName("MyTests")
+ .WithForce(true)
+ .Build().EnsureSuccess();
result.ExitCode.ShouldBe(0);
@@ -744,20 +754,21 @@ result.Tests.Count(test => test.State == TestState.Finished).ShouldBe(1);
using HostApi;
// Creates a new test project, running a command like: "dotnet new mstest -n MyTests --force"
-new DotNetNew("mstest", "-n", "MyTests", "--force")
- .Run()
- .EnsureSuccess();
+new DotNetNew()
+ .WithTemplateName("mstest")
+ .WithName("MyTests")
+ .WithForce(true)
+ .Run().EnsureSuccess();
// Creates the tool manifest and installs the dotCover tool locally
// It is better to run the following 2 commands manually
// and commit these changes to a source control
-new DotNetNew("tool-manifest")
- .Run()
- .EnsureSuccess();
+new DotNetNew()
+ .WithTemplateName("tool-manifest")
+ .Run().EnsureSuccess();
new DotNetCustom("tool", "install", "--local", "JetBrains.dotCover.GlobalTool")
- .Run()
- .EnsureSuccess();
+ .Run().EnsureSuccess();
// Creates a test command
var test = new DotNetTest()
@@ -778,8 +789,7 @@ var testUnderDotCover = test.Customize(cmd =>
// Runs tests under dotCover via a command like: "dotnet dotcover test ..."
var result = testUnderDotCover
- .Build()
- .EnsureSuccess();
+ .Build().EnsureSuccess();
// The "result" variable provides details about a build
result.ExitCode.ShouldBe(0);
@@ -807,7 +817,8 @@ var projectDir = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()[..4]
Directory.CreateDirectory(projectDir);
// Creates a local tool manifest
-new DotNetNew("tool-manifest")
+new DotNetNew()
+ .WithTemplateName("tool-manifest")
.WithWorkingDirectory(projectDir)
.Run()
.EnsureSuccess();
@@ -830,9 +841,11 @@ new DotNetToolRestore()
using HostApi;
// Creates a new test project, running a command like: "dotnet new mstest -n MyTests --force"
-var result = new DotNetNew("mstest", "-n", "MyTests", "--force")
- .Build()
- .EnsureSuccess();
+var result = new DotNetNew()
+ .WithTemplateName("mstest")
+ .WithName("MyTests")
+ .WithForce(true)
+ .Build().EnsureSuccess();
result.ExitCode.ShouldBe(0);
@@ -841,8 +854,7 @@ result = new DotNetBuild()
.WithWorkingDirectory("MyTests")
.WithConfiguration("Release")
.WithOutput("MyOutput")
- .Build()
- .EnsureSuccess();
+ .Build().EnsureSuccess();
result.ExitCode.ShouldBe(0);
@@ -850,8 +862,7 @@ result.ExitCode.ShouldBe(0);
result = new VSTest()
.AddTestFileNames(Path.Combine("MyOutput", "MyTests.dll"))
.WithWorkingDirectory("MyTests")
- .Build()
- .EnsureSuccess();
+ .Build().EnsureSuccess();
// The "result" variable provides details about a build
result.ExitCode.ShouldBe(0);
@@ -870,9 +881,11 @@ result.Tests.Count(test => test.State == TestState.Finished).ShouldBe(1);
using HostApi;
// Creates a new library project, running a command like: "dotnet new classlib -n MyLib --force"
-var result = new DotNetNew("classlib", "-n", "MyLib", "--force")
- .Build()
- .EnsureSuccess();
+var result = new DotNetNew()
+ .WithTemplateName("classlib")
+ .WithName("MyLib")
+ .WithForce(true)
+ .Build().EnsureSuccess();
result.ExitCode.ShouldBe(0);
@@ -883,8 +896,7 @@ result = new MSBuild()
.WithRestore(true)
.AddProps(("configuration", "Release"))
.WithVerbosity(DotNetVerbosity.Detailed)
- .Build()
- .EnsureSuccess();
+ .Build().EnsureSuccess();
// The "result" variable provides details about a build
result.Errors.Any(message => message.State == BuildMessageState.StdError).ShouldBeFalse();
diff --git a/CSharpInteractive.Tests/README_TEMPLATE.tt b/CSharpInteractive.Tests/README_TEMPLATE.tt
index 119cfac3..4ad63b1b 100644
--- a/CSharpInteractive.Tests/README_TEMPLATE.tt
+++ b/CSharpInteractive.Tests/README_TEMPLATE.tt
@@ -48,7 +48,7 @@
{
var parts = str.Substring(4, str.Length - 4).Split([
'='
- ], 2, StringSplitOptions.RemoveEmptyEntries);
+ ], 2, StringSplitOptions.RemoveEmptyEntries);
if (parts.Length == 2)
{
var key = parts[0];