diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 0513212e..f0f5e68c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,4 +1,4 @@ -name: Pure.DI check +name: CSharpInteractive check on: [ push, pull_request ] diff --git a/.run/Get version.run.xml b/.run/Get version.run.xml new file mode 100644 index 00000000..f31683a8 --- /dev/null +++ b/.run/Get version.run.xml @@ -0,0 +1,20 @@ + + + + \ No newline at end of file diff --git a/Build/Program.cs b/Build/Program.cs index 3bf17f33..5e0c599a 100644 --- a/Build/Program.cs +++ b/Build/Program.cs @@ -58,7 +58,7 @@ false) }; -new DotNetToolRestore().WithShortName("Restoring tools").Run().EnsureSuccess(); +new DotNetToolRestore().Run().EnsureSuccess(); new DotNetClean() .WithProject(solutionFile) @@ -173,8 +173,9 @@ } } -var uninstallTool = new DotNetCustom("tool", "uninstall", toolPackageId, "-g") - .WithShortName("Uninstalling tool"); +var uninstallTool = new DotNetToolUninstall() + .WithPackage(toolPackageId) + .WithGlobal(true); if (uninstallTool.Run(_ => { }).ExitCode != 0) { @@ -191,8 +192,15 @@ Environment.SetEnvironmentVariable("PATH", pathEnvVar); } -var installTool = new DotNetCustom("tool", "install", toolPackageId, "-g", "--version", packageVersion.ToString(), "--add-source", Path.Combine(outputDir, "CSharpInteractive.Tool")) - .WithShortName("Installing tool"); +await new DotNetBuild() + .WithProject(Path.Combine("Samples", "MySampleLib")) + .BuildAsync().EnsureSuccess(); + +var installTool = new DotNetToolInstall() + .WithPackage(toolPackageId) + .WithGlobal(true) + .WithVersion(packageVersion.ToString()) + .AddSources(Path.Combine(outputDir, "CSharpInteractive.Tool")); installTool.Run(output => { @@ -200,10 +208,10 @@ WriteLine(output.Line); }).EnsureSuccess(_ => true); -new DotNetCustom("csi", "/?").WithShortName("Checking tool").Run().EnsureSuccess(); +new DotNetCsi().WithVersion(true).WithShortName("Checking csi tool").Run().EnsureSuccess(); -var uninstallTemplates = new DotNetCustom("new", "uninstall", templatesPackageId) - .WithShortName("Uninstalling template"); +var uninstallTemplates = new DotNetNewUninstall() + .WithPackage(templatesPackageId); uninstallTemplates.Run(output => { @@ -211,10 +219,11 @@ WriteLine(output.Line); }).EnsureSuccess(_ => true); -var installTemplates = new DotNetCustom("new", "install", $"{templatesPackageId}::{packageVersion.ToString()}", "--nuget-source", templateOutputDir) - .WithShortName("Installing template"); +var installTemplates = new DotNetNewInstall() + .WithPackage($"{templatesPackageId}::{packageVersion.ToString()}") + .AddSources(templateOutputDir); -installTemplates.WithShortName(installTemplates.ShortName).Run().EnsureSuccess(); +installTemplates.Run().EnsureSuccess(); foreach (var framework in frameworks) { await CheckCompatibilityAsync(framework, packageVersion, defaultNuGetSource, outputDir); @@ -222,11 +231,10 @@ if (!string.IsNullOrWhiteSpace(apiKey) && packageVersion.Release != "dev" && packageVersion.Release != "dev") { - var push = new DotNetNuGetPush().WithApiKey(apiKey).WithSources(defaultNuGetSource); + var push = new DotNetNuGetPush().WithApiKey(apiKey).WithSource(defaultNuGetSource); foreach (var package in packages.Where(i => i.Publish)) { push.WithPackage(package.Package) - .WithShortName($"Pushing {Path.GetFileName(package.Package)}") .Build().EnsureSuccess(); } } @@ -269,27 +277,28 @@ async Task CheckCompatibilityAsync( try { var sampleProjectDir = Path.Combine("Samples", "MySampleLib", "MySampleLib.Tests"); - await new DotNetNew("build", $"--version={nuGetVersion}", "-T", framework, "--no-restore") + await new DotNetNew() + .WithTemplateName("build") + .WithNoRestore(true) + .WithArgs($"--version={nuGetVersion}", "-T", framework) .WithWorkingDirectory(buildProjectDir) - .WithShortName($"Creating a new {sampleProjectName}") .RunAsync().EnsureSuccess(); await new DotNetBuild() .WithProject(buildProjectDir) .WithSources(nuGetSource, Path.Combine(output, "CSharpInteractive")) - .WithShortName($"Building the {sampleProjectName}") .BuildAsync().EnsureSuccess(); await new DotNetRun() - .WithProject(buildProjectDir) + .WithWorkingDirectory(buildProjectDir) + .WithNoRestore(true) .WithNoBuild(true) - .WithWorkingDirectory(sampleProjectDir) - .WithShortName($"Running a build for the {sampleProjectName}") + .WithFramework(framework) .RunAsync().EnsureSuccess(); - await new DotNetCustom("csi", Path.Combine(buildProjectDir, "Program.csx")) + await new DotNetCsi() + .WithScript(Path.Combine(buildProjectDir, "Program.csx")) .WithWorkingDirectory(sampleProjectDir) - .WithShortName($"Running a build as a C# script for the {sampleProjectName}") .RunAsync().EnsureSuccess(); } finally diff --git a/CSharpInteractive.HostApi/CSharpInteractive.HostApi.csproj b/CSharpInteractive.HostApi/CSharpInteractive.HostApi.csproj index 3f9f4ec1..0ef20de6 100644 --- a/CSharpInteractive.HostApi/CSharpInteractive.HostApi.csproj +++ b/CSharpInteractive.HostApi/CSharpInteractive.HostApi.csproj @@ -30,15 +30,20 @@ - True True + True CommandLines.tt - + + DotNetCommands.cs + TextTemplatingFileGenerator + + + True True - CommandLines.tt + DotNetCommands.tt diff --git a/CSharpInteractive.HostApi/CommandLines.cs b/CSharpInteractive.HostApi/CommandLines.cs index b255a3f4..e06c7086 100644 --- a/CSharpInteractive.HostApi/CommandLines.cs +++ b/CSharpInteractive.HostApi/CommandLines.cs @@ -1,6 +1,6 @@ // ReSharper disable InconsistentNaming namespace HostApi; - + [ExcludeFromCodeCoverage] public partial record CommandLine: ICommandLine { @@ -70,7 +70,7 @@ public partial record CommandLine: ICommandLine } [ExcludeFromCodeCoverage] -public partial record DotNetBuild: ICommandLine +public partial record DotNetCustom: ICommandLine { /// /// Appends an argument. @@ -78,7 +78,7 @@ public partial record DotNetBuild: ICommandLine /// The command to which an argument will be added. /// Argument to add. /// Returns a new command with the corresponding changes. - public static DotNetBuild operator +(DotNetBuild command, string arg) => command.AddArgs(arg); + public static DotNetCustom operator +(DotNetCustom command, string arg) => command.AddArgs(arg); /// /// Removes an argument by its name. @@ -86,7 +86,7 @@ public partial record DotNetBuild: ICommandLine /// The command to which an argument will be removed. /// Argument to remove. /// Returns a new command with the corresponding changes. - public static DotNetBuild operator -(DotNetBuild command, string arg) => command.RemoveArgs(arg); + public static DotNetCustom operator -(DotNetCustom command, string arg) => command.RemoveArgs(arg); /// /// Appends arguments. @@ -94,7 +94,7 @@ public partial record DotNetBuild: ICommandLine /// The command to which arguments will be added. /// Arguments to add. /// Returns a new command with the corresponding changes. - public static DotNetBuild operator +(DotNetBuild command, IEnumerable args) => command.AddArgs(args); + public static DotNetCustom operator +(DotNetCustom command, IEnumerable args) => command.AddArgs(args); /// /// Removes arguments by their name. @@ -102,7 +102,7 @@ public partial record DotNetBuild: ICommandLine /// The command to which arguments will be removed. /// Arguments to remove. /// Returns a new command with the corresponding changes. - public static DotNetBuild operator -(DotNetBuild command, IEnumerable args) => command.RemoveArgs(args); + public static DotNetCustom operator -(DotNetCustom command, IEnumerable args) => command.RemoveArgs(args); /// /// Appends an environment variable. @@ -110,7 +110,7 @@ public partial record DotNetBuild: ICommandLine /// The command to which an environment variable will be added. /// Environment variable to add. /// Returns a new command with the corresponding changes. - public static DotNetBuild operator +(DotNetBuild command, (string name, string value) var) => command.AddVars(var); + public static DotNetCustom operator +(DotNetCustom command, (string name, string value) var) => command.AddVars(var); /// /// Removes environment variable by its name and value. @@ -118,7 +118,7 @@ public partial record DotNetBuild: ICommandLine /// The command to which an environment variable will be removed. /// Environment variable to remove. /// Returns a new command with the corresponding changes. - public static DotNetBuild operator -(DotNetBuild command, (string name, string value) var) => command.RemoveVars(var); + public static DotNetCustom operator -(DotNetCustom command, (string name, string value) var) => command.RemoveVars(var); /// /// Appends environment variables. @@ -126,7 +126,7 @@ public partial record DotNetBuild: ICommandLine /// The command to which environment variables will be added. /// Environment variables to add. /// Returns a new command with the corresponding changes. - public static DotNetBuild operator +(DotNetBuild command, IEnumerable<(string name, string value)> vars) => command.AddVars(vars); + public static DotNetCustom operator +(DotNetCustom command, IEnumerable<(string name, string value)> vars) => command.AddVars(vars); /// /// Removes environment variables by their name and value. @@ -134,11 +134,11 @@ public partial record DotNetBuild: ICommandLine /// The command to which environment variables will be removed. /// environment variables to remove. /// Returns a new command with the corresponding changes. - public static DotNetBuild operator -(DotNetBuild command, IEnumerable<(string name, string value)> vars) => command.RemoveVars(vars); + public static DotNetCustom operator -(DotNetCustom command, IEnumerable<(string name, string value)> vars) => command.RemoveVars(vars); } [ExcludeFromCodeCoverage] -public partial record DotNetBuildServerShutdown: ICommandLine +public partial record DotNet: ICommandLine { /// /// Appends an argument. @@ -146,7 +146,7 @@ public partial record DotNetBuildServerShutdown: ICommandLine /// The command to which an argument will be added. /// Argument to add. /// Returns a new command with the corresponding changes. - public static DotNetBuildServerShutdown operator +(DotNetBuildServerShutdown command, string arg) => command.AddArgs(arg); + public static DotNet operator +(DotNet command, string arg) => command.AddArgs(arg); /// /// Removes an argument by its name. @@ -154,7 +154,7 @@ public partial record DotNetBuildServerShutdown: ICommandLine /// The command to which an argument will be removed. /// Argument to remove. /// Returns a new command with the corresponding changes. - public static DotNetBuildServerShutdown operator -(DotNetBuildServerShutdown command, string arg) => command.RemoveArgs(arg); + public static DotNet operator -(DotNet command, string arg) => command.RemoveArgs(arg); /// /// Appends arguments. @@ -162,7 +162,7 @@ public partial record DotNetBuildServerShutdown: ICommandLine /// The command to which arguments will be added. /// Arguments to add. /// Returns a new command with the corresponding changes. - public static DotNetBuildServerShutdown operator +(DotNetBuildServerShutdown command, IEnumerable args) => command.AddArgs(args); + public static DotNet operator +(DotNet command, IEnumerable args) => command.AddArgs(args); /// /// Removes arguments by their name. @@ -170,7 +170,7 @@ public partial record DotNetBuildServerShutdown: ICommandLine /// The command to which arguments will be removed. /// Arguments to remove. /// Returns a new command with the corresponding changes. - public static DotNetBuildServerShutdown operator -(DotNetBuildServerShutdown command, IEnumerable args) => command.RemoveArgs(args); + public static DotNet operator -(DotNet command, IEnumerable args) => command.RemoveArgs(args); /// /// Appends an environment variable. @@ -178,7 +178,7 @@ public partial record DotNetBuildServerShutdown: ICommandLine /// The command to which an environment variable will be added. /// Environment variable to add. /// Returns a new command with the corresponding changes. - public static DotNetBuildServerShutdown operator +(DotNetBuildServerShutdown command, (string name, string value) var) => command.AddVars(var); + public static DotNet operator +(DotNet command, (string name, string value) var) => command.AddVars(var); /// /// Removes environment variable by its name and value. @@ -186,7 +186,7 @@ public partial record DotNetBuildServerShutdown: ICommandLine /// The command to which an environment variable will be removed. /// Environment variable to remove. /// Returns a new command with the corresponding changes. - public static DotNetBuildServerShutdown operator -(DotNetBuildServerShutdown command, (string name, string value) var) => command.RemoveVars(var); + public static DotNet operator -(DotNet command, (string name, string value) var) => command.RemoveVars(var); /// /// Appends environment variables. @@ -194,7 +194,7 @@ public partial record DotNetBuildServerShutdown: ICommandLine /// The command to which environment variables will be added. /// Environment variables to add. /// Returns a new command with the corresponding changes. - public static DotNetBuildServerShutdown operator +(DotNetBuildServerShutdown command, IEnumerable<(string name, string value)> vars) => command.AddVars(vars); + public static DotNet operator +(DotNet command, IEnumerable<(string name, string value)> vars) => command.AddVars(vars); /// /// Removes environment variables by their name and value. @@ -202,11 +202,11 @@ public partial record DotNetBuildServerShutdown: ICommandLine /// The command to which environment variables will be removed. /// environment variables to remove. /// Returns a new command with the corresponding changes. - public static DotNetBuildServerShutdown operator -(DotNetBuildServerShutdown command, IEnumerable<(string name, string value)> vars) => command.RemoveVars(vars); + public static DotNet operator -(DotNet command, IEnumerable<(string name, string value)> vars) => command.RemoveVars(vars); } [ExcludeFromCodeCoverage] -public partial record DotNetClean: ICommandLine +public partial record DotNetExec: ICommandLine { /// /// Appends an argument. @@ -214,7 +214,7 @@ public partial record DotNetClean: ICommandLine /// The command to which an argument will be added. /// Argument to add. /// Returns a new command with the corresponding changes. - public static DotNetClean operator +(DotNetClean command, string arg) => command.AddArgs(arg); + public static DotNetExec operator +(DotNetExec command, string arg) => command.AddArgs(arg); /// /// Removes an argument by its name. @@ -222,7 +222,7 @@ public partial record DotNetClean: ICommandLine /// The command to which an argument will be removed. /// Argument to remove. /// Returns a new command with the corresponding changes. - public static DotNetClean operator -(DotNetClean command, string arg) => command.RemoveArgs(arg); + public static DotNetExec operator -(DotNetExec command, string arg) => command.RemoveArgs(arg); /// /// Appends arguments. @@ -230,7 +230,7 @@ public partial record DotNetClean: ICommandLine /// The command to which arguments will be added. /// Arguments to add. /// Returns a new command with the corresponding changes. - public static DotNetClean operator +(DotNetClean command, IEnumerable args) => command.AddArgs(args); + public static DotNetExec operator +(DotNetExec command, IEnumerable args) => command.AddArgs(args); /// /// Removes arguments by their name. @@ -238,7 +238,7 @@ public partial record DotNetClean: ICommandLine /// The command to which arguments will be removed. /// Arguments to remove. /// Returns a new command with the corresponding changes. - public static DotNetClean operator -(DotNetClean command, IEnumerable args) => command.RemoveArgs(args); + public static DotNetExec operator -(DotNetExec command, IEnumerable args) => command.RemoveArgs(args); /// /// Appends an environment variable. @@ -246,7 +246,7 @@ public partial record DotNetClean: ICommandLine /// The command to which an environment variable will be added. /// Environment variable to add. /// Returns a new command with the corresponding changes. - public static DotNetClean operator +(DotNetClean command, (string name, string value) var) => command.AddVars(var); + public static DotNetExec operator +(DotNetExec command, (string name, string value) var) => command.AddVars(var); /// /// Removes environment variable by its name and value. @@ -254,7 +254,7 @@ public partial record DotNetClean: ICommandLine /// The command to which an environment variable will be removed. /// Environment variable to remove. /// Returns a new command with the corresponding changes. - public static DotNetClean operator -(DotNetClean command, (string name, string value) var) => command.RemoveVars(var); + public static DotNetExec operator -(DotNetExec command, (string name, string value) var) => command.RemoveVars(var); /// /// Appends environment variables. @@ -262,7 +262,7 @@ public partial record DotNetClean: ICommandLine /// The command to which environment variables will be added. /// Environment variables to add. /// Returns a new command with the corresponding changes. - public static DotNetClean operator +(DotNetClean command, IEnumerable<(string name, string value)> vars) => command.AddVars(vars); + public static DotNetExec operator +(DotNetExec command, IEnumerable<(string name, string value)> vars) => command.AddVars(vars); /// /// Removes environment variables by their name and value. @@ -270,11 +270,11 @@ public partial record DotNetClean: ICommandLine /// The command to which environment variables will be removed. /// environment variables to remove. /// Returns a new command with the corresponding changes. - public static DotNetClean operator -(DotNetClean command, IEnumerable<(string name, string value)> vars) => command.RemoveVars(vars); + public static DotNetExec operator -(DotNetExec command, IEnumerable<(string name, string value)> vars) => command.RemoveVars(vars); } [ExcludeFromCodeCoverage] -public partial record DotNetCustom: ICommandLine +public partial record DotNetAddPackage: ICommandLine { /// /// Appends an argument. @@ -282,7 +282,7 @@ public partial record DotNetCustom: ICommandLine /// The command to which an argument will be added. /// Argument to add. /// Returns a new command with the corresponding changes. - public static DotNetCustom operator +(DotNetCustom command, string arg) => command.AddArgs(arg); + public static DotNetAddPackage operator +(DotNetAddPackage command, string arg) => command.AddArgs(arg); /// /// Removes an argument by its name. @@ -290,7 +290,7 @@ public partial record DotNetCustom: ICommandLine /// The command to which an argument will be removed. /// Argument to remove. /// Returns a new command with the corresponding changes. - public static DotNetCustom operator -(DotNetCustom command, string arg) => command.RemoveArgs(arg); + public static DotNetAddPackage operator -(DotNetAddPackage command, string arg) => command.RemoveArgs(arg); /// /// Appends arguments. @@ -298,7 +298,7 @@ public partial record DotNetCustom: ICommandLine /// The command to which arguments will be added. /// Arguments to add. /// Returns a new command with the corresponding changes. - public static DotNetCustom operator +(DotNetCustom command, IEnumerable args) => command.AddArgs(args); + public static DotNetAddPackage operator +(DotNetAddPackage command, IEnumerable args) => command.AddArgs(args); /// /// Removes arguments by their name. @@ -306,7 +306,7 @@ public partial record DotNetCustom: ICommandLine /// The command to which arguments will be removed. /// Arguments to remove. /// Returns a new command with the corresponding changes. - public static DotNetCustom operator -(DotNetCustom command, IEnumerable args) => command.RemoveArgs(args); + public static DotNetAddPackage operator -(DotNetAddPackage command, IEnumerable args) => command.RemoveArgs(args); /// /// Appends an environment variable. @@ -314,7 +314,7 @@ public partial record DotNetCustom: ICommandLine /// The command to which an environment variable will be added. /// Environment variable to add. /// Returns a new command with the corresponding changes. - public static DotNetCustom operator +(DotNetCustom command, (string name, string value) var) => command.AddVars(var); + public static DotNetAddPackage operator +(DotNetAddPackage command, (string name, string value) var) => command.AddVars(var); /// /// Removes environment variable by its name and value. @@ -322,7 +322,7 @@ public partial record DotNetCustom: ICommandLine /// The command to which an environment variable will be removed. /// Environment variable to remove. /// Returns a new command with the corresponding changes. - public static DotNetCustom operator -(DotNetCustom command, (string name, string value) var) => command.RemoveVars(var); + public static DotNetAddPackage operator -(DotNetAddPackage command, (string name, string value) var) => command.RemoveVars(var); /// /// Appends environment variables. @@ -330,7 +330,7 @@ public partial record DotNetCustom: ICommandLine /// The command to which environment variables will be added. /// Environment variables to add. /// Returns a new command with the corresponding changes. - public static DotNetCustom operator +(DotNetCustom command, IEnumerable<(string name, string value)> vars) => command.AddVars(vars); + public static DotNetAddPackage operator +(DotNetAddPackage command, IEnumerable<(string name, string value)> vars) => command.AddVars(vars); /// /// Removes environment variables by their name and value. @@ -338,11 +338,11 @@ public partial record DotNetCustom: ICommandLine /// The command to which environment variables will be removed. /// environment variables to remove. /// Returns a new command with the corresponding changes. - public static DotNetCustom operator -(DotNetCustom command, IEnumerable<(string name, string value)> vars) => command.RemoveVars(vars); + public static DotNetAddPackage operator -(DotNetAddPackage command, IEnumerable<(string name, string value)> vars) => command.RemoveVars(vars); } [ExcludeFromCodeCoverage] -public partial record DotNetNew: ICommandLine +public partial record DotNetListPackage: ICommandLine { /// /// Appends an argument. @@ -350,7 +350,7 @@ public partial record DotNetNew: ICommandLine /// The command to which an argument will be added. /// Argument to add. /// Returns a new command with the corresponding changes. - public static DotNetNew operator +(DotNetNew command, string arg) => command.AddArgs(arg); + public static DotNetListPackage operator +(DotNetListPackage command, string arg) => command.AddArgs(arg); /// /// Removes an argument by its name. @@ -358,7 +358,7 @@ public partial record DotNetNew: ICommandLine /// The command to which an argument will be removed. /// Argument to remove. /// Returns a new command with the corresponding changes. - public static DotNetNew operator -(DotNetNew command, string arg) => command.RemoveArgs(arg); + public static DotNetListPackage operator -(DotNetListPackage command, string arg) => command.RemoveArgs(arg); /// /// Appends arguments. @@ -366,7 +366,7 @@ public partial record DotNetNew: ICommandLine /// The command to which arguments will be added. /// Arguments to add. /// Returns a new command with the corresponding changes. - public static DotNetNew operator +(DotNetNew command, IEnumerable args) => command.AddArgs(args); + public static DotNetListPackage operator +(DotNetListPackage command, IEnumerable args) => command.AddArgs(args); /// /// Removes arguments by their name. @@ -374,7 +374,7 @@ public partial record DotNetNew: ICommandLine /// The command to which arguments will be removed. /// Arguments to remove. /// Returns a new command with the corresponding changes. - public static DotNetNew operator -(DotNetNew command, IEnumerable args) => command.RemoveArgs(args); + public static DotNetListPackage operator -(DotNetListPackage command, IEnumerable args) => command.RemoveArgs(args); /// /// Appends an environment variable. @@ -382,7 +382,7 @@ public partial record DotNetNew: ICommandLine /// The command to which an environment variable will be added. /// Environment variable to add. /// Returns a new command with the corresponding changes. - public static DotNetNew operator +(DotNetNew command, (string name, string value) var) => command.AddVars(var); + public static DotNetListPackage operator +(DotNetListPackage command, (string name, string value) var) => command.AddVars(var); /// /// Removes environment variable by its name and value. @@ -390,7 +390,7 @@ public partial record DotNetNew: ICommandLine /// The command to which an environment variable will be removed. /// Environment variable to remove. /// Returns a new command with the corresponding changes. - public static DotNetNew operator -(DotNetNew command, (string name, string value) var) => command.RemoveVars(var); + public static DotNetListPackage operator -(DotNetListPackage command, (string name, string value) var) => command.RemoveVars(var); /// /// Appends environment variables. @@ -398,7 +398,7 @@ public partial record DotNetNew: ICommandLine /// The command to which environment variables will be added. /// Environment variables to add. /// Returns a new command with the corresponding changes. - public static DotNetNew operator +(DotNetNew command, IEnumerable<(string name, string value)> vars) => command.AddVars(vars); + public static DotNetListPackage operator +(DotNetListPackage command, IEnumerable<(string name, string value)> vars) => command.AddVars(vars); /// /// Removes environment variables by their name and value. @@ -406,11 +406,11 @@ public partial record DotNetNew: ICommandLine /// The command to which environment variables will be removed. /// environment variables to remove. /// Returns a new command with the corresponding changes. - public static DotNetNew operator -(DotNetNew command, IEnumerable<(string name, string value)> vars) => command.RemoveVars(vars); + public static DotNetListPackage operator -(DotNetListPackage command, IEnumerable<(string name, string value)> vars) => command.RemoveVars(vars); } [ExcludeFromCodeCoverage] -public partial record DotNetNuGetPush: ICommandLine +public partial record DotNetRemovePackage: ICommandLine { /// /// Appends an argument. @@ -418,7 +418,7 @@ public partial record DotNetNuGetPush: ICommandLine /// The command to which an argument will be added. /// Argument to add. /// Returns a new command with the corresponding changes. - public static DotNetNuGetPush operator +(DotNetNuGetPush command, string arg) => command.AddArgs(arg); + public static DotNetRemovePackage operator +(DotNetRemovePackage command, string arg) => command.AddArgs(arg); /// /// Removes an argument by its name. @@ -426,7 +426,7 @@ public partial record DotNetNuGetPush: ICommandLine /// The command to which an argument will be removed. /// Argument to remove. /// Returns a new command with the corresponding changes. - public static DotNetNuGetPush operator -(DotNetNuGetPush command, string arg) => command.RemoveArgs(arg); + public static DotNetRemovePackage operator -(DotNetRemovePackage command, string arg) => command.RemoveArgs(arg); /// /// Appends arguments. @@ -434,7 +434,7 @@ public partial record DotNetNuGetPush: ICommandLine /// The command to which arguments will be added. /// Arguments to add. /// Returns a new command with the corresponding changes. - public static DotNetNuGetPush operator +(DotNetNuGetPush command, IEnumerable args) => command.AddArgs(args); + public static DotNetRemovePackage operator +(DotNetRemovePackage command, IEnumerable args) => command.AddArgs(args); /// /// Removes arguments by their name. @@ -442,7 +442,7 @@ public partial record DotNetNuGetPush: ICommandLine /// The command to which arguments will be removed. /// Arguments to remove. /// Returns a new command with the corresponding changes. - public static DotNetNuGetPush operator -(DotNetNuGetPush command, IEnumerable args) => command.RemoveArgs(args); + public static DotNetRemovePackage operator -(DotNetRemovePackage command, IEnumerable args) => command.RemoveArgs(args); /// /// Appends an environment variable. @@ -450,7 +450,7 @@ public partial record DotNetNuGetPush: ICommandLine /// The command to which an environment variable will be added. /// Environment variable to add. /// Returns a new command with the corresponding changes. - public static DotNetNuGetPush operator +(DotNetNuGetPush command, (string name, string value) var) => command.AddVars(var); + public static DotNetRemovePackage operator +(DotNetRemovePackage command, (string name, string value) var) => command.AddVars(var); /// /// Removes environment variable by its name and value. @@ -458,7 +458,7 @@ public partial record DotNetNuGetPush: ICommandLine /// The command to which an environment variable will be removed. /// Environment variable to remove. /// Returns a new command with the corresponding changes. - public static DotNetNuGetPush operator -(DotNetNuGetPush command, (string name, string value) var) => command.RemoveVars(var); + public static DotNetRemovePackage operator -(DotNetRemovePackage command, (string name, string value) var) => command.RemoveVars(var); /// /// Appends environment variables. @@ -466,7 +466,7 @@ public partial record DotNetNuGetPush: ICommandLine /// The command to which environment variables will be added. /// Environment variables to add. /// Returns a new command with the corresponding changes. - public static DotNetNuGetPush operator +(DotNetNuGetPush command, IEnumerable<(string name, string value)> vars) => command.AddVars(vars); + public static DotNetRemovePackage operator +(DotNetRemovePackage command, IEnumerable<(string name, string value)> vars) => command.AddVars(vars); /// /// Removes environment variables by their name and value. @@ -474,11 +474,11 @@ public partial record DotNetNuGetPush: ICommandLine /// The command to which environment variables will be removed. /// environment variables to remove. /// Returns a new command with the corresponding changes. - public static DotNetNuGetPush operator -(DotNetNuGetPush command, IEnumerable<(string name, string value)> vars) => command.RemoveVars(vars); + public static DotNetRemovePackage operator -(DotNetRemovePackage command, IEnumerable<(string name, string value)> vars) => command.RemoveVars(vars); } [ExcludeFromCodeCoverage] -public partial record DotNetPack: ICommandLine +public partial record DotNetAddReference: ICommandLine { /// /// Appends an argument. @@ -486,7 +486,7 @@ public partial record DotNetPack: ICommandLine /// The command to which an argument will be added. /// Argument to add. /// Returns a new command with the corresponding changes. - public static DotNetPack operator +(DotNetPack command, string arg) => command.AddArgs(arg); + public static DotNetAddReference operator +(DotNetAddReference command, string arg) => command.AddArgs(arg); /// /// Removes an argument by its name. @@ -494,7 +494,7 @@ public partial record DotNetPack: ICommandLine /// The command to which an argument will be removed. /// Argument to remove. /// Returns a new command with the corresponding changes. - public static DotNetPack operator -(DotNetPack command, string arg) => command.RemoveArgs(arg); + public static DotNetAddReference operator -(DotNetAddReference command, string arg) => command.RemoveArgs(arg); /// /// Appends arguments. @@ -502,7 +502,7 @@ public partial record DotNetPack: ICommandLine /// The command to which arguments will be added. /// Arguments to add. /// Returns a new command with the corresponding changes. - public static DotNetPack operator +(DotNetPack command, IEnumerable args) => command.AddArgs(args); + public static DotNetAddReference operator +(DotNetAddReference command, IEnumerable args) => command.AddArgs(args); /// /// Removes arguments by their name. @@ -510,7 +510,7 @@ public partial record DotNetPack: ICommandLine /// The command to which arguments will be removed. /// Arguments to remove. /// Returns a new command with the corresponding changes. - public static DotNetPack operator -(DotNetPack command, IEnumerable args) => command.RemoveArgs(args); + public static DotNetAddReference operator -(DotNetAddReference command, IEnumerable args) => command.RemoveArgs(args); /// /// Appends an environment variable. @@ -518,7 +518,7 @@ public partial record DotNetPack: ICommandLine /// The command to which an environment variable will be added. /// Environment variable to add. /// Returns a new command with the corresponding changes. - public static DotNetPack operator +(DotNetPack command, (string name, string value) var) => command.AddVars(var); + public static DotNetAddReference operator +(DotNetAddReference command, (string name, string value) var) => command.AddVars(var); /// /// Removes environment variable by its name and value. @@ -526,7 +526,7 @@ public partial record DotNetPack: ICommandLine /// The command to which an environment variable will be removed. /// Environment variable to remove. /// Returns a new command with the corresponding changes. - public static DotNetPack operator -(DotNetPack command, (string name, string value) var) => command.RemoveVars(var); + public static DotNetAddReference operator -(DotNetAddReference command, (string name, string value) var) => command.RemoveVars(var); /// /// Appends environment variables. @@ -534,7 +534,7 @@ public partial record DotNetPack: ICommandLine /// The command to which environment variables will be added. /// Environment variables to add. /// Returns a new command with the corresponding changes. - public static DotNetPack operator +(DotNetPack command, IEnumerable<(string name, string value)> vars) => command.AddVars(vars); + public static DotNetAddReference operator +(DotNetAddReference command, IEnumerable<(string name, string value)> vars) => command.AddVars(vars); /// /// Removes environment variables by their name and value. @@ -542,11 +542,11 @@ public partial record DotNetPack: ICommandLine /// The command to which environment variables will be removed. /// environment variables to remove. /// Returns a new command with the corresponding changes. - public static DotNetPack operator -(DotNetPack command, IEnumerable<(string name, string value)> vars) => command.RemoveVars(vars); + public static DotNetAddReference operator -(DotNetAddReference command, IEnumerable<(string name, string value)> vars) => command.RemoveVars(vars); } [ExcludeFromCodeCoverage] -public partial record DotNetPublish: ICommandLine +public partial record DotNetListReference: ICommandLine { /// /// Appends an argument. @@ -554,7 +554,7 @@ public partial record DotNetPublish: ICommandLine /// The command to which an argument will be added. /// Argument to add. /// Returns a new command with the corresponding changes. - public static DotNetPublish operator +(DotNetPublish command, string arg) => command.AddArgs(arg); + public static DotNetListReference operator +(DotNetListReference command, string arg) => command.AddArgs(arg); /// /// Removes an argument by its name. @@ -562,7 +562,7 @@ public partial record DotNetPublish: ICommandLine /// The command to which an argument will be removed. /// Argument to remove. /// Returns a new command with the corresponding changes. - public static DotNetPublish operator -(DotNetPublish command, string arg) => command.RemoveArgs(arg); + public static DotNetListReference operator -(DotNetListReference command, string arg) => command.RemoveArgs(arg); /// /// Appends arguments. @@ -570,7 +570,7 @@ public partial record DotNetPublish: ICommandLine /// The command to which arguments will be added. /// Arguments to add. /// Returns a new command with the corresponding changes. - public static DotNetPublish operator +(DotNetPublish command, IEnumerable args) => command.AddArgs(args); + public static DotNetListReference operator +(DotNetListReference command, IEnumerable args) => command.AddArgs(args); /// /// Removes arguments by their name. @@ -578,7 +578,7 @@ public partial record DotNetPublish: ICommandLine /// The command to which arguments will be removed. /// Arguments to remove. /// Returns a new command with the corresponding changes. - public static DotNetPublish operator -(DotNetPublish command, IEnumerable args) => command.RemoveArgs(args); + public static DotNetListReference operator -(DotNetListReference command, IEnumerable args) => command.RemoveArgs(args); /// /// Appends an environment variable. @@ -586,7 +586,7 @@ public partial record DotNetPublish: ICommandLine /// The command to which an environment variable will be added. /// Environment variable to add. /// Returns a new command with the corresponding changes. - public static DotNetPublish operator +(DotNetPublish command, (string name, string value) var) => command.AddVars(var); + public static DotNetListReference operator +(DotNetListReference command, (string name, string value) var) => command.AddVars(var); /// /// Removes environment variable by its name and value. @@ -594,7 +594,7 @@ public partial record DotNetPublish: ICommandLine /// The command to which an environment variable will be removed. /// Environment variable to remove. /// Returns a new command with the corresponding changes. - public static DotNetPublish operator -(DotNetPublish command, (string name, string value) var) => command.RemoveVars(var); + public static DotNetListReference operator -(DotNetListReference command, (string name, string value) var) => command.RemoveVars(var); /// /// Appends environment variables. @@ -602,7 +602,7 @@ public partial record DotNetPublish: ICommandLine /// The command to which environment variables will be added. /// Environment variables to add. /// Returns a new command with the corresponding changes. - public static DotNetPublish operator +(DotNetPublish command, IEnumerable<(string name, string value)> vars) => command.AddVars(vars); + public static DotNetListReference operator +(DotNetListReference command, IEnumerable<(string name, string value)> vars) => command.AddVars(vars); /// /// Removes environment variables by their name and value. @@ -610,11 +610,11 @@ public partial record DotNetPublish: ICommandLine /// The command to which environment variables will be removed. /// environment variables to remove. /// Returns a new command with the corresponding changes. - public static DotNetPublish operator -(DotNetPublish command, IEnumerable<(string name, string value)> vars) => command.RemoveVars(vars); + public static DotNetListReference operator -(DotNetListReference command, IEnumerable<(string name, string value)> vars) => command.RemoveVars(vars); } [ExcludeFromCodeCoverage] -public partial record DotNetRestore: ICommandLine +public partial record DotNetRemoveReference: ICommandLine { /// /// Appends an argument. @@ -622,7 +622,7 @@ public partial record DotNetRestore: ICommandLine /// The command to which an argument will be added. /// Argument to add. /// Returns a new command with the corresponding changes. - public static DotNetRestore operator +(DotNetRestore command, string arg) => command.AddArgs(arg); + public static DotNetRemoveReference operator +(DotNetRemoveReference command, string arg) => command.AddArgs(arg); /// /// Removes an argument by its name. @@ -630,7 +630,7 @@ public partial record DotNetRestore: ICommandLine /// The command to which an argument will be removed. /// Argument to remove. /// Returns a new command with the corresponding changes. - public static DotNetRestore operator -(DotNetRestore command, string arg) => command.RemoveArgs(arg); + public static DotNetRemoveReference operator -(DotNetRemoveReference command, string arg) => command.RemoveArgs(arg); /// /// Appends arguments. @@ -638,7 +638,7 @@ public partial record DotNetRestore: ICommandLine /// The command to which arguments will be added. /// Arguments to add. /// Returns a new command with the corresponding changes. - public static DotNetRestore operator +(DotNetRestore command, IEnumerable args) => command.AddArgs(args); + public static DotNetRemoveReference operator +(DotNetRemoveReference command, IEnumerable args) => command.AddArgs(args); /// /// Removes arguments by their name. @@ -646,7 +646,7 @@ public partial record DotNetRestore: ICommandLine /// The command to which arguments will be removed. /// Arguments to remove. /// Returns a new command with the corresponding changes. - public static DotNetRestore operator -(DotNetRestore command, IEnumerable args) => command.RemoveArgs(args); + public static DotNetRemoveReference operator -(DotNetRemoveReference command, IEnumerable args) => command.RemoveArgs(args); /// /// Appends an environment variable. @@ -654,7 +654,7 @@ public partial record DotNetRestore: ICommandLine /// The command to which an environment variable will be added. /// Environment variable to add. /// Returns a new command with the corresponding changes. - public static DotNetRestore operator +(DotNetRestore command, (string name, string value) var) => command.AddVars(var); + public static DotNetRemoveReference operator +(DotNetRemoveReference command, (string name, string value) var) => command.AddVars(var); /// /// Removes environment variable by its name and value. @@ -662,7 +662,7 @@ public partial record DotNetRestore: ICommandLine /// The command to which an environment variable will be removed. /// Environment variable to remove. /// Returns a new command with the corresponding changes. - public static DotNetRestore operator -(DotNetRestore command, (string name, string value) var) => command.RemoveVars(var); + public static DotNetRemoveReference operator -(DotNetRemoveReference command, (string name, string value) var) => command.RemoveVars(var); /// /// Appends environment variables. @@ -670,7 +670,7 @@ public partial record DotNetRestore: ICommandLine /// The command to which environment variables will be added. /// Environment variables to add. /// Returns a new command with the corresponding changes. - public static DotNetRestore operator +(DotNetRestore command, IEnumerable<(string name, string value)> vars) => command.AddVars(vars); + public static DotNetRemoveReference operator +(DotNetRemoveReference command, IEnumerable<(string name, string value)> vars) => command.AddVars(vars); /// /// Removes environment variables by their name and value. @@ -678,11 +678,11 @@ public partial record DotNetRestore: ICommandLine /// The command to which environment variables will be removed. /// environment variables to remove. /// Returns a new command with the corresponding changes. - public static DotNetRestore operator -(DotNetRestore command, IEnumerable<(string name, string value)> vars) => command.RemoveVars(vars); + public static DotNetRemoveReference operator -(DotNetRemoveReference command, IEnumerable<(string name, string value)> vars) => command.RemoveVars(vars); } [ExcludeFromCodeCoverage] -public partial record DotNetRun: ICommandLine +public partial record DotNetBuild: ICommandLine { /// /// Appends an argument. @@ -690,7 +690,7 @@ public partial record DotNetRun: ICommandLine /// The command to which an argument will be added. /// Argument to add. /// Returns a new command with the corresponding changes. - public static DotNetRun operator +(DotNetRun command, string arg) => command.AddArgs(arg); + public static DotNetBuild operator +(DotNetBuild command, string arg) => command.AddArgs(arg); /// /// Removes an argument by its name. @@ -698,7 +698,7 @@ public partial record DotNetRun: ICommandLine /// The command to which an argument will be removed. /// Argument to remove. /// Returns a new command with the corresponding changes. - public static DotNetRun operator -(DotNetRun command, string arg) => command.RemoveArgs(arg); + public static DotNetBuild operator -(DotNetBuild command, string arg) => command.RemoveArgs(arg); /// /// Appends arguments. @@ -706,7 +706,7 @@ public partial record DotNetRun: ICommandLine /// The command to which arguments will be added. /// Arguments to add. /// Returns a new command with the corresponding changes. - public static DotNetRun operator +(DotNetRun command, IEnumerable args) => command.AddArgs(args); + public static DotNetBuild operator +(DotNetBuild command, IEnumerable args) => command.AddArgs(args); /// /// Removes arguments by their name. @@ -714,7 +714,7 @@ public partial record DotNetRun: ICommandLine /// The command to which arguments will be removed. /// Arguments to remove. /// Returns a new command with the corresponding changes. - public static DotNetRun operator -(DotNetRun command, IEnumerable args) => command.RemoveArgs(args); + public static DotNetBuild operator -(DotNetBuild command, IEnumerable args) => command.RemoveArgs(args); /// /// Appends an environment variable. @@ -722,7 +722,7 @@ public partial record DotNetRun: ICommandLine /// The command to which an environment variable will be added. /// Environment variable to add. /// Returns a new command with the corresponding changes. - public static DotNetRun operator +(DotNetRun command, (string name, string value) var) => command.AddVars(var); + public static DotNetBuild operator +(DotNetBuild command, (string name, string value) var) => command.AddVars(var); /// /// Removes environment variable by its name and value. @@ -730,7 +730,7 @@ public partial record DotNetRun: ICommandLine /// The command to which an environment variable will be removed. /// Environment variable to remove. /// Returns a new command with the corresponding changes. - public static DotNetRun operator -(DotNetRun command, (string name, string value) var) => command.RemoveVars(var); + public static DotNetBuild operator -(DotNetBuild command, (string name, string value) var) => command.RemoveVars(var); /// /// Appends environment variables. @@ -738,7 +738,7 @@ public partial record DotNetRun: ICommandLine /// The command to which environment variables will be added. /// Environment variables to add. /// Returns a new command with the corresponding changes. - public static DotNetRun operator +(DotNetRun command, IEnumerable<(string name, string value)> vars) => command.AddVars(vars); + public static DotNetBuild operator +(DotNetBuild command, IEnumerable<(string name, string value)> vars) => command.AddVars(vars); /// /// Removes environment variables by their name and value. @@ -746,11 +746,11 @@ public partial record DotNetRun: ICommandLine /// The command to which environment variables will be removed. /// environment variables to remove. /// Returns a new command with the corresponding changes. - public static DotNetRun operator -(DotNetRun command, IEnumerable<(string name, string value)> vars) => command.RemoveVars(vars); + public static DotNetBuild operator -(DotNetBuild command, IEnumerable<(string name, string value)> vars) => command.RemoveVars(vars); } [ExcludeFromCodeCoverage] -public partial record DotNetTest: ICommandLine +public partial record DotNetBuildServerShutdown: ICommandLine { /// /// Appends an argument. @@ -758,7 +758,7 @@ public partial record DotNetTest: ICommandLine /// The command to which an argument will be added. /// Argument to add. /// Returns a new command with the corresponding changes. - public static DotNetTest operator +(DotNetTest command, string arg) => command.AddArgs(arg); + public static DotNetBuildServerShutdown operator +(DotNetBuildServerShutdown command, string arg) => command.AddArgs(arg); /// /// Removes an argument by its name. @@ -766,7 +766,7 @@ public partial record DotNetTest: ICommandLine /// The command to which an argument will be removed. /// Argument to remove. /// Returns a new command with the corresponding changes. - public static DotNetTest operator -(DotNetTest command, string arg) => command.RemoveArgs(arg); + public static DotNetBuildServerShutdown operator -(DotNetBuildServerShutdown command, string arg) => command.RemoveArgs(arg); /// /// Appends arguments. @@ -774,7 +774,7 @@ public partial record DotNetTest: ICommandLine /// The command to which arguments will be added. /// Arguments to add. /// Returns a new command with the corresponding changes. - public static DotNetTest operator +(DotNetTest command, IEnumerable args) => command.AddArgs(args); + public static DotNetBuildServerShutdown operator +(DotNetBuildServerShutdown command, IEnumerable args) => command.AddArgs(args); /// /// Removes arguments by their name. @@ -782,7 +782,7 @@ public partial record DotNetTest: ICommandLine /// The command to which arguments will be removed. /// Arguments to remove. /// Returns a new command with the corresponding changes. - public static DotNetTest operator -(DotNetTest command, IEnumerable args) => command.RemoveArgs(args); + public static DotNetBuildServerShutdown operator -(DotNetBuildServerShutdown command, IEnumerable args) => command.RemoveArgs(args); /// /// Appends an environment variable. @@ -790,7 +790,7 @@ public partial record DotNetTest: ICommandLine /// The command to which an environment variable will be added. /// Environment variable to add. /// Returns a new command with the corresponding changes. - public static DotNetTest operator +(DotNetTest command, (string name, string value) var) => command.AddVars(var); + public static DotNetBuildServerShutdown operator +(DotNetBuildServerShutdown command, (string name, string value) var) => command.AddVars(var); /// /// Removes environment variable by its name and value. @@ -798,7 +798,7 @@ public partial record DotNetTest: ICommandLine /// The command to which an environment variable will be removed. /// Environment variable to remove. /// Returns a new command with the corresponding changes. - public static DotNetTest operator -(DotNetTest command, (string name, string value) var) => command.RemoveVars(var); + public static DotNetBuildServerShutdown operator -(DotNetBuildServerShutdown command, (string name, string value) var) => command.RemoveVars(var); /// /// Appends environment variables. @@ -806,7 +806,7 @@ public partial record DotNetTest: ICommandLine /// The command to which environment variables will be added. /// Environment variables to add. /// Returns a new command with the corresponding changes. - public static DotNetTest operator +(DotNetTest command, IEnumerable<(string name, string value)> vars) => command.AddVars(vars); + public static DotNetBuildServerShutdown operator +(DotNetBuildServerShutdown command, IEnumerable<(string name, string value)> vars) => command.AddVars(vars); /// /// Removes environment variables by their name and value. @@ -814,11 +814,11 @@ public partial record DotNetTest: ICommandLine /// The command to which environment variables will be removed. /// environment variables to remove. /// Returns a new command with the corresponding changes. - public static DotNetTest operator -(DotNetTest command, IEnumerable<(string name, string value)> vars) => command.RemoveVars(vars); + public static DotNetBuildServerShutdown operator -(DotNetBuildServerShutdown command, IEnumerable<(string name, string value)> vars) => command.RemoveVars(vars); } [ExcludeFromCodeCoverage] -public partial record DotNetToolRestore: ICommandLine +public partial record DotNetClean: ICommandLine { /// /// Appends an argument. @@ -826,7 +826,7 @@ public partial record DotNetToolRestore: ICommandLine /// The command to which an argument will be added. /// Argument to add. /// Returns a new command with the corresponding changes. - public static DotNetToolRestore operator +(DotNetToolRestore command, string arg) => command.AddArgs(arg); + public static DotNetClean operator +(DotNetClean command, string arg) => command.AddArgs(arg); /// /// Removes an argument by its name. @@ -834,7 +834,7 @@ public partial record DotNetToolRestore: ICommandLine /// The command to which an argument will be removed. /// Argument to remove. /// Returns a new command with the corresponding changes. - public static DotNetToolRestore operator -(DotNetToolRestore command, string arg) => command.RemoveArgs(arg); + public static DotNetClean operator -(DotNetClean command, string arg) => command.RemoveArgs(arg); /// /// Appends arguments. @@ -842,7 +842,7 @@ public partial record DotNetToolRestore: ICommandLine /// The command to which arguments will be added. /// Arguments to add. /// Returns a new command with the corresponding changes. - public static DotNetToolRestore operator +(DotNetToolRestore command, IEnumerable args) => command.AddArgs(args); + public static DotNetClean operator +(DotNetClean command, IEnumerable args) => command.AddArgs(args); /// /// Removes arguments by their name. @@ -850,7 +850,7 @@ public partial record DotNetToolRestore: ICommandLine /// The command to which arguments will be removed. /// Arguments to remove. /// Returns a new command with the corresponding changes. - public static DotNetToolRestore operator -(DotNetToolRestore command, IEnumerable args) => command.RemoveArgs(args); + public static DotNetClean operator -(DotNetClean command, IEnumerable args) => command.RemoveArgs(args); /// /// Appends an environment variable. @@ -858,7 +858,7 @@ public partial record DotNetToolRestore: ICommandLine /// The command to which an environment variable will be added. /// Environment variable to add. /// Returns a new command with the corresponding changes. - public static DotNetToolRestore operator +(DotNetToolRestore command, (string name, string value) var) => command.AddVars(var); + public static DotNetClean operator +(DotNetClean command, (string name, string value) var) => command.AddVars(var); /// /// Removes environment variable by its name and value. @@ -866,7 +866,7 @@ public partial record DotNetToolRestore: ICommandLine /// The command to which an environment variable will be removed. /// Environment variable to remove. /// Returns a new command with the corresponding changes. - public static DotNetToolRestore operator -(DotNetToolRestore command, (string name, string value) var) => command.RemoveVars(var); + public static DotNetClean operator -(DotNetClean command, (string name, string value) var) => command.RemoveVars(var); /// /// Appends environment variables. @@ -874,7 +874,7 @@ public partial record DotNetToolRestore: ICommandLine /// The command to which environment variables will be added. /// Environment variables to add. /// Returns a new command with the corresponding changes. - public static DotNetToolRestore operator +(DotNetToolRestore command, IEnumerable<(string name, string value)> vars) => command.AddVars(vars); + public static DotNetClean operator +(DotNetClean command, IEnumerable<(string name, string value)> vars) => command.AddVars(vars); /// /// Removes environment variables by their name and value. @@ -882,11 +882,11 @@ public partial record DotNetToolRestore: ICommandLine /// The command to which environment variables will be removed. /// environment variables to remove. /// Returns a new command with the corresponding changes. - public static DotNetToolRestore operator -(DotNetToolRestore command, IEnumerable<(string name, string value)> vars) => command.RemoveVars(vars); + public static DotNetClean operator -(DotNetClean command, IEnumerable<(string name, string value)> vars) => command.RemoveVars(vars); } [ExcludeFromCodeCoverage] -public partial record MSBuild: ICommandLine +public partial record DotNetDevCertsHttps: ICommandLine { /// /// Appends an argument. @@ -894,7 +894,7 @@ public partial record MSBuild: ICommandLine /// The command to which an argument will be added. /// Argument to add. /// Returns a new command with the corresponding changes. - public static MSBuild operator +(MSBuild command, string arg) => command.AddArgs(arg); + public static DotNetDevCertsHttps operator +(DotNetDevCertsHttps command, string arg) => command.AddArgs(arg); /// /// Removes an argument by its name. @@ -902,7 +902,7 @@ public partial record MSBuild: ICommandLine /// The command to which an argument will be removed. /// Argument to remove. /// Returns a new command with the corresponding changes. - public static MSBuild operator -(MSBuild command, string arg) => command.RemoveArgs(arg); + public static DotNetDevCertsHttps operator -(DotNetDevCertsHttps command, string arg) => command.RemoveArgs(arg); /// /// Appends arguments. @@ -910,7 +910,7 @@ public partial record MSBuild: ICommandLine /// The command to which arguments will be added. /// Arguments to add. /// Returns a new command with the corresponding changes. - public static MSBuild operator +(MSBuild command, IEnumerable args) => command.AddArgs(args); + public static DotNetDevCertsHttps operator +(DotNetDevCertsHttps command, IEnumerable args) => command.AddArgs(args); /// /// Removes arguments by their name. @@ -918,7 +918,7 @@ public partial record MSBuild: ICommandLine /// The command to which arguments will be removed. /// Arguments to remove. /// Returns a new command with the corresponding changes. - public static MSBuild operator -(MSBuild command, IEnumerable args) => command.RemoveArgs(args); + public static DotNetDevCertsHttps operator -(DotNetDevCertsHttps command, IEnumerable args) => command.RemoveArgs(args); /// /// Appends an environment variable. @@ -926,7 +926,7 @@ public partial record MSBuild: ICommandLine /// The command to which an environment variable will be added. /// Environment variable to add. /// Returns a new command with the corresponding changes. - public static MSBuild operator +(MSBuild command, (string name, string value) var) => command.AddVars(var); + public static DotNetDevCertsHttps operator +(DotNetDevCertsHttps command, (string name, string value) var) => command.AddVars(var); /// /// Removes environment variable by its name and value. @@ -934,7 +934,7 @@ public partial record MSBuild: ICommandLine /// The command to which an environment variable will be removed. /// Environment variable to remove. /// Returns a new command with the corresponding changes. - public static MSBuild operator -(MSBuild command, (string name, string value) var) => command.RemoveVars(var); + public static DotNetDevCertsHttps operator -(DotNetDevCertsHttps command, (string name, string value) var) => command.RemoveVars(var); /// /// Appends environment variables. @@ -942,7 +942,7 @@ public partial record MSBuild: ICommandLine /// The command to which environment variables will be added. /// Environment variables to add. /// Returns a new command with the corresponding changes. - public static MSBuild operator +(MSBuild command, IEnumerable<(string name, string value)> vars) => command.AddVars(vars); + public static DotNetDevCertsHttps operator +(DotNetDevCertsHttps command, IEnumerable<(string name, string value)> vars) => command.AddVars(vars); /// /// Removes environment variables by their name and value. @@ -950,11 +950,11 @@ public partial record MSBuild: ICommandLine /// The command to which environment variables will be removed. /// environment variables to remove. /// Returns a new command with the corresponding changes. - public static MSBuild operator -(MSBuild command, IEnumerable<(string name, string value)> vars) => command.RemoveVars(vars); + public static DotNetDevCertsHttps operator -(DotNetDevCertsHttps command, IEnumerable<(string name, string value)> vars) => command.RemoveVars(vars); } [ExcludeFromCodeCoverage] -public partial record VSTest: ICommandLine +public partial record DotNetFormat: ICommandLine { /// /// Appends an argument. @@ -962,7 +962,7 @@ public partial record VSTest: ICommandLine /// The command to which an argument will be added. /// Argument to add. /// Returns a new command with the corresponding changes. - public static VSTest operator +(VSTest command, string arg) => command.AddArgs(arg); + public static DotNetFormat operator +(DotNetFormat command, string arg) => command.AddArgs(arg); /// /// Removes an argument by its name. @@ -970,7 +970,7 @@ public partial record VSTest: ICommandLine /// The command to which an argument will be removed. /// Argument to remove. /// Returns a new command with the corresponding changes. - public static VSTest operator -(VSTest command, string arg) => command.RemoveArgs(arg); + public static DotNetFormat operator -(DotNetFormat command, string arg) => command.RemoveArgs(arg); /// /// Appends arguments. @@ -978,7 +978,7 @@ public partial record VSTest: ICommandLine /// The command to which arguments will be added. /// Arguments to add. /// Returns a new command with the corresponding changes. - public static VSTest operator +(VSTest command, IEnumerable args) => command.AddArgs(args); + public static DotNetFormat operator +(DotNetFormat command, IEnumerable args) => command.AddArgs(args); /// /// Removes arguments by their name. @@ -986,7 +986,7 @@ public partial record VSTest: ICommandLine /// The command to which arguments will be removed. /// Arguments to remove. /// Returns a new command with the corresponding changes. - public static VSTest operator -(VSTest command, IEnumerable args) => command.RemoveArgs(args); + public static DotNetFormat operator -(DotNetFormat command, IEnumerable args) => command.RemoveArgs(args); /// /// Appends an environment variable. @@ -994,7 +994,7 @@ public partial record VSTest: ICommandLine /// The command to which an environment variable will be added. /// Environment variable to add. /// Returns a new command with the corresponding changes. - public static VSTest operator +(VSTest command, (string name, string value) var) => command.AddVars(var); + public static DotNetFormat operator +(DotNetFormat command, (string name, string value) var) => command.AddVars(var); /// /// Removes environment variable by its name and value. @@ -1002,7 +1002,7 @@ public partial record VSTest: ICommandLine /// The command to which an environment variable will be removed. /// Environment variable to remove. /// Returns a new command with the corresponding changes. - public static VSTest operator -(VSTest command, (string name, string value) var) => command.RemoveVars(var); + public static DotNetFormat operator -(DotNetFormat command, (string name, string value) var) => command.RemoveVars(var); /// /// Appends environment variables. @@ -1010,7 +1010,7 @@ public partial record VSTest: ICommandLine /// The command to which environment variables will be added. /// Environment variables to add. /// Returns a new command with the corresponding changes. - public static VSTest operator +(VSTest command, IEnumerable<(string name, string value)> vars) => command.AddVars(vars); + public static DotNetFormat operator +(DotNetFormat command, IEnumerable<(string name, string value)> vars) => command.AddVars(vars); /// /// Removes environment variables by their name and value. @@ -1018,7 +1018,4291 @@ public partial record VSTest: ICommandLine /// The command to which environment variables will be removed. /// environment variables to remove. /// Returns a new command with the corresponding changes. - public static VSTest operator -(VSTest command, IEnumerable<(string name, string value)> vars) => command.RemoveVars(vars); + public static DotNetFormat operator -(DotNetFormat command, IEnumerable<(string name, string value)> vars) => command.RemoveVars(vars); +} + +[ExcludeFromCodeCoverage] +public partial record DotNetFormatStyle: ICommandLine +{ + /// + /// Appends an argument. + /// + /// The command to which an argument will be added. + /// Argument to add. + /// Returns a new command with the corresponding changes. + public static DotNetFormatStyle operator +(DotNetFormatStyle command, string arg) => command.AddArgs(arg); + + /// + /// Removes an argument by its name. + /// + /// The command to which an argument will be removed. + /// Argument to remove. + /// Returns a new command with the corresponding changes. + public static DotNetFormatStyle operator -(DotNetFormatStyle command, string arg) => command.RemoveArgs(arg); + + /// + /// Appends arguments. + /// + /// The command to which arguments will be added. + /// Arguments to add. + /// Returns a new command with the corresponding changes. + public static DotNetFormatStyle operator +(DotNetFormatStyle command, IEnumerable args) => command.AddArgs(args); + + /// + /// Removes arguments by their name. + /// + /// The command to which arguments will be removed. + /// Arguments to remove. + /// Returns a new command with the corresponding changes. + public static DotNetFormatStyle operator -(DotNetFormatStyle command, IEnumerable args) => command.RemoveArgs(args); + + /// + /// Appends an environment variable. + /// + /// The command to which an environment variable will be added. + /// Environment variable to add. + /// Returns a new command with the corresponding changes. + public static DotNetFormatStyle operator +(DotNetFormatStyle command, (string name, string value) var) => command.AddVars(var); + + /// + /// Removes environment variable by its name and value. + /// + /// The command to which an environment variable will be removed. + /// Environment variable to remove. + /// Returns a new command with the corresponding changes. + public static DotNetFormatStyle operator -(DotNetFormatStyle command, (string name, string value) var) => command.RemoveVars(var); + + /// + /// Appends environment variables. + /// + /// The command to which environment variables will be added. + /// Environment variables to add. + /// Returns a new command with the corresponding changes. + public static DotNetFormatStyle operator +(DotNetFormatStyle command, IEnumerable<(string name, string value)> vars) => command.AddVars(vars); + + /// + /// Removes environment variables by their name and value. + /// + /// The command to which environment variables will be removed. + /// environment variables to remove. + /// Returns a new command with the corresponding changes. + public static DotNetFormatStyle operator -(DotNetFormatStyle command, IEnumerable<(string name, string value)> vars) => command.RemoveVars(vars); +} + +[ExcludeFromCodeCoverage] +public partial record DotNetFormatAnalyzers: ICommandLine +{ + /// + /// Appends an argument. + /// + /// The command to which an argument will be added. + /// Argument to add. + /// Returns a new command with the corresponding changes. + public static DotNetFormatAnalyzers operator +(DotNetFormatAnalyzers command, string arg) => command.AddArgs(arg); + + /// + /// Removes an argument by its name. + /// + /// The command to which an argument will be removed. + /// Argument to remove. + /// Returns a new command with the corresponding changes. + public static DotNetFormatAnalyzers operator -(DotNetFormatAnalyzers command, string arg) => command.RemoveArgs(arg); + + /// + /// Appends arguments. + /// + /// The command to which arguments will be added. + /// Arguments to add. + /// Returns a new command with the corresponding changes. + public static DotNetFormatAnalyzers operator +(DotNetFormatAnalyzers command, IEnumerable args) => command.AddArgs(args); + + /// + /// Removes arguments by their name. + /// + /// The command to which arguments will be removed. + /// Arguments to remove. + /// Returns a new command with the corresponding changes. + public static DotNetFormatAnalyzers operator -(DotNetFormatAnalyzers command, IEnumerable args) => command.RemoveArgs(args); + + /// + /// Appends an environment variable. + /// + /// The command to which an environment variable will be added. + /// Environment variable to add. + /// Returns a new command with the corresponding changes. + public static DotNetFormatAnalyzers operator +(DotNetFormatAnalyzers command, (string name, string value) var) => command.AddVars(var); + + /// + /// Removes environment variable by its name and value. + /// + /// The command to which an environment variable will be removed. + /// Environment variable to remove. + /// Returns a new command with the corresponding changes. + public static DotNetFormatAnalyzers operator -(DotNetFormatAnalyzers command, (string name, string value) var) => command.RemoveVars(var); + + /// + /// Appends environment variables. + /// + /// The command to which environment variables will be added. + /// Environment variables to add. + /// Returns a new command with the corresponding changes. + public static DotNetFormatAnalyzers operator +(DotNetFormatAnalyzers command, IEnumerable<(string name, string value)> vars) => command.AddVars(vars); + + /// + /// Removes environment variables by their name and value. + /// + /// The command to which environment variables will be removed. + /// environment variables to remove. + /// Returns a new command with the corresponding changes. + public static DotNetFormatAnalyzers operator -(DotNetFormatAnalyzers command, IEnumerable<(string name, string value)> vars) => command.RemoveVars(vars); +} + +[ExcludeFromCodeCoverage] +public partial record MSBuild: ICommandLine +{ + /// + /// Appends an argument. + /// + /// The command to which an argument will be added. + /// Argument to add. + /// Returns a new command with the corresponding changes. + public static MSBuild operator +(MSBuild command, string arg) => command.AddArgs(arg); + + /// + /// Removes an argument by its name. + /// + /// The command to which an argument will be removed. + /// Argument to remove. + /// Returns a new command with the corresponding changes. + public static MSBuild operator -(MSBuild command, string arg) => command.RemoveArgs(arg); + + /// + /// Appends arguments. + /// + /// The command to which arguments will be added. + /// Arguments to add. + /// Returns a new command with the corresponding changes. + public static MSBuild operator +(MSBuild command, IEnumerable args) => command.AddArgs(args); + + /// + /// Removes arguments by their name. + /// + /// The command to which arguments will be removed. + /// Arguments to remove. + /// Returns a new command with the corresponding changes. + public static MSBuild operator -(MSBuild command, IEnumerable args) => command.RemoveArgs(args); + + /// + /// Appends an environment variable. + /// + /// The command to which an environment variable will be added. + /// Environment variable to add. + /// Returns a new command with the corresponding changes. + public static MSBuild operator +(MSBuild command, (string name, string value) var) => command.AddVars(var); + + /// + /// Removes environment variable by its name and value. + /// + /// The command to which an environment variable will be removed. + /// Environment variable to remove. + /// Returns a new command with the corresponding changes. + public static MSBuild operator -(MSBuild command, (string name, string value) var) => command.RemoveVars(var); + + /// + /// Appends environment variables. + /// + /// The command to which environment variables will be added. + /// Environment variables to add. + /// Returns a new command with the corresponding changes. + public static MSBuild operator +(MSBuild command, IEnumerable<(string name, string value)> vars) => command.AddVars(vars); + + /// + /// Removes environment variables by their name and value. + /// + /// The command to which environment variables will be removed. + /// environment variables to remove. + /// Returns a new command with the corresponding changes. + public static MSBuild operator -(MSBuild command, IEnumerable<(string name, string value)> vars) => command.RemoveVars(vars); +} + +[ExcludeFromCodeCoverage] +public partial record DotNetNew: ICommandLine +{ + /// + /// Appends an argument. + /// + /// The command to which an argument will be added. + /// Argument to add. + /// Returns a new command with the corresponding changes. + public static DotNetNew operator +(DotNetNew command, string arg) => command.AddArgs(arg); + + /// + /// Removes an argument by its name. + /// + /// The command to which an argument will be removed. + /// Argument to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNew operator -(DotNetNew command, string arg) => command.RemoveArgs(arg); + + /// + /// Appends arguments. + /// + /// The command to which arguments will be added. + /// Arguments to add. + /// Returns a new command with the corresponding changes. + public static DotNetNew operator +(DotNetNew command, IEnumerable args) => command.AddArgs(args); + + /// + /// Removes arguments by their name. + /// + /// The command to which arguments will be removed. + /// Arguments to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNew operator -(DotNetNew command, IEnumerable args) => command.RemoveArgs(args); + + /// + /// Appends an environment variable. + /// + /// The command to which an environment variable will be added. + /// Environment variable to add. + /// Returns a new command with the corresponding changes. + public static DotNetNew operator +(DotNetNew command, (string name, string value) var) => command.AddVars(var); + + /// + /// Removes environment variable by its name and value. + /// + /// The command to which an environment variable will be removed. + /// Environment variable to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNew operator -(DotNetNew command, (string name, string value) var) => command.RemoveVars(var); + + /// + /// Appends environment variables. + /// + /// The command to which environment variables will be added. + /// Environment variables to add. + /// Returns a new command with the corresponding changes. + public static DotNetNew operator +(DotNetNew command, IEnumerable<(string name, string value)> vars) => command.AddVars(vars); + + /// + /// Removes environment variables by their name and value. + /// + /// The command to which environment variables will be removed. + /// environment variables to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNew operator -(DotNetNew command, IEnumerable<(string name, string value)> vars) => command.RemoveVars(vars); +} + +[ExcludeFromCodeCoverage] +public partial record DotNetNewList: ICommandLine +{ + /// + /// Appends an argument. + /// + /// The command to which an argument will be added. + /// Argument to add. + /// Returns a new command with the corresponding changes. + public static DotNetNewList operator +(DotNetNewList command, string arg) => command.AddArgs(arg); + + /// + /// Removes an argument by its name. + /// + /// The command to which an argument will be removed. + /// Argument to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNewList operator -(DotNetNewList command, string arg) => command.RemoveArgs(arg); + + /// + /// Appends arguments. + /// + /// The command to which arguments will be added. + /// Arguments to add. + /// Returns a new command with the corresponding changes. + public static DotNetNewList operator +(DotNetNewList command, IEnumerable args) => command.AddArgs(args); + + /// + /// Removes arguments by their name. + /// + /// The command to which arguments will be removed. + /// Arguments to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNewList operator -(DotNetNewList command, IEnumerable args) => command.RemoveArgs(args); + + /// + /// Appends an environment variable. + /// + /// The command to which an environment variable will be added. + /// Environment variable to add. + /// Returns a new command with the corresponding changes. + public static DotNetNewList operator +(DotNetNewList command, (string name, string value) var) => command.AddVars(var); + + /// + /// Removes environment variable by its name and value. + /// + /// The command to which an environment variable will be removed. + /// Environment variable to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNewList operator -(DotNetNewList command, (string name, string value) var) => command.RemoveVars(var); + + /// + /// Appends environment variables. + /// + /// The command to which environment variables will be added. + /// Environment variables to add. + /// Returns a new command with the corresponding changes. + public static DotNetNewList operator +(DotNetNewList command, IEnumerable<(string name, string value)> vars) => command.AddVars(vars); + + /// + /// Removes environment variables by their name and value. + /// + /// The command to which environment variables will be removed. + /// environment variables to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNewList operator -(DotNetNewList command, IEnumerable<(string name, string value)> vars) => command.RemoveVars(vars); +} + +[ExcludeFromCodeCoverage] +public partial record DotNetNewSearch: ICommandLine +{ + /// + /// Appends an argument. + /// + /// The command to which an argument will be added. + /// Argument to add. + /// Returns a new command with the corresponding changes. + public static DotNetNewSearch operator +(DotNetNewSearch command, string arg) => command.AddArgs(arg); + + /// + /// Removes an argument by its name. + /// + /// The command to which an argument will be removed. + /// Argument to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNewSearch operator -(DotNetNewSearch command, string arg) => command.RemoveArgs(arg); + + /// + /// Appends arguments. + /// + /// The command to which arguments will be added. + /// Arguments to add. + /// Returns a new command with the corresponding changes. + public static DotNetNewSearch operator +(DotNetNewSearch command, IEnumerable args) => command.AddArgs(args); + + /// + /// Removes arguments by their name. + /// + /// The command to which arguments will be removed. + /// Arguments to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNewSearch operator -(DotNetNewSearch command, IEnumerable args) => command.RemoveArgs(args); + + /// + /// Appends an environment variable. + /// + /// The command to which an environment variable will be added. + /// Environment variable to add. + /// Returns a new command with the corresponding changes. + public static DotNetNewSearch operator +(DotNetNewSearch command, (string name, string value) var) => command.AddVars(var); + + /// + /// Removes environment variable by its name and value. + /// + /// The command to which an environment variable will be removed. + /// Environment variable to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNewSearch operator -(DotNetNewSearch command, (string name, string value) var) => command.RemoveVars(var); + + /// + /// Appends environment variables. + /// + /// The command to which environment variables will be added. + /// Environment variables to add. + /// Returns a new command with the corresponding changes. + public static DotNetNewSearch operator +(DotNetNewSearch command, IEnumerable<(string name, string value)> vars) => command.AddVars(vars); + + /// + /// Removes environment variables by their name and value. + /// + /// The command to which environment variables will be removed. + /// environment variables to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNewSearch operator -(DotNetNewSearch command, IEnumerable<(string name, string value)> vars) => command.RemoveVars(vars); +} + +[ExcludeFromCodeCoverage] +public partial record DotNetNewDetails: ICommandLine +{ + /// + /// Appends an argument. + /// + /// The command to which an argument will be added. + /// Argument to add. + /// Returns a new command with the corresponding changes. + public static DotNetNewDetails operator +(DotNetNewDetails command, string arg) => command.AddArgs(arg); + + /// + /// Removes an argument by its name. + /// + /// The command to which an argument will be removed. + /// Argument to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNewDetails operator -(DotNetNewDetails command, string arg) => command.RemoveArgs(arg); + + /// + /// Appends arguments. + /// + /// The command to which arguments will be added. + /// Arguments to add. + /// Returns a new command with the corresponding changes. + public static DotNetNewDetails operator +(DotNetNewDetails command, IEnumerable args) => command.AddArgs(args); + + /// + /// Removes arguments by their name. + /// + /// The command to which arguments will be removed. + /// Arguments to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNewDetails operator -(DotNetNewDetails command, IEnumerable args) => command.RemoveArgs(args); + + /// + /// Appends an environment variable. + /// + /// The command to which an environment variable will be added. + /// Environment variable to add. + /// Returns a new command with the corresponding changes. + public static DotNetNewDetails operator +(DotNetNewDetails command, (string name, string value) var) => command.AddVars(var); + + /// + /// Removes environment variable by its name and value. + /// + /// The command to which an environment variable will be removed. + /// Environment variable to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNewDetails operator -(DotNetNewDetails command, (string name, string value) var) => command.RemoveVars(var); + + /// + /// Appends environment variables. + /// + /// The command to which environment variables will be added. + /// Environment variables to add. + /// Returns a new command with the corresponding changes. + public static DotNetNewDetails operator +(DotNetNewDetails command, IEnumerable<(string name, string value)> vars) => command.AddVars(vars); + + /// + /// Removes environment variables by their name and value. + /// + /// The command to which environment variables will be removed. + /// environment variables to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNewDetails operator -(DotNetNewDetails command, IEnumerable<(string name, string value)> vars) => command.RemoveVars(vars); +} + +[ExcludeFromCodeCoverage] +public partial record DotNetNewInstall: ICommandLine +{ + /// + /// Appends an argument. + /// + /// The command to which an argument will be added. + /// Argument to add. + /// Returns a new command with the corresponding changes. + public static DotNetNewInstall operator +(DotNetNewInstall command, string arg) => command.AddArgs(arg); + + /// + /// Removes an argument by its name. + /// + /// The command to which an argument will be removed. + /// Argument to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNewInstall operator -(DotNetNewInstall command, string arg) => command.RemoveArgs(arg); + + /// + /// Appends arguments. + /// + /// The command to which arguments will be added. + /// Arguments to add. + /// Returns a new command with the corresponding changes. + public static DotNetNewInstall operator +(DotNetNewInstall command, IEnumerable args) => command.AddArgs(args); + + /// + /// Removes arguments by their name. + /// + /// The command to which arguments will be removed. + /// Arguments to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNewInstall operator -(DotNetNewInstall command, IEnumerable args) => command.RemoveArgs(args); + + /// + /// Appends an environment variable. + /// + /// The command to which an environment variable will be added. + /// Environment variable to add. + /// Returns a new command with the corresponding changes. + public static DotNetNewInstall operator +(DotNetNewInstall command, (string name, string value) var) => command.AddVars(var); + + /// + /// Removes environment variable by its name and value. + /// + /// The command to which an environment variable will be removed. + /// Environment variable to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNewInstall operator -(DotNetNewInstall command, (string name, string value) var) => command.RemoveVars(var); + + /// + /// Appends environment variables. + /// + /// The command to which environment variables will be added. + /// Environment variables to add. + /// Returns a new command with the corresponding changes. + public static DotNetNewInstall operator +(DotNetNewInstall command, IEnumerable<(string name, string value)> vars) => command.AddVars(vars); + + /// + /// Removes environment variables by their name and value. + /// + /// The command to which environment variables will be removed. + /// environment variables to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNewInstall operator -(DotNetNewInstall command, IEnumerable<(string name, string value)> vars) => command.RemoveVars(vars); +} + +[ExcludeFromCodeCoverage] +public partial record DotNetNewUninstall: ICommandLine +{ + /// + /// Appends an argument. + /// + /// The command to which an argument will be added. + /// Argument to add. + /// Returns a new command with the corresponding changes. + public static DotNetNewUninstall operator +(DotNetNewUninstall command, string arg) => command.AddArgs(arg); + + /// + /// Removes an argument by its name. + /// + /// The command to which an argument will be removed. + /// Argument to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNewUninstall operator -(DotNetNewUninstall command, string arg) => command.RemoveArgs(arg); + + /// + /// Appends arguments. + /// + /// The command to which arguments will be added. + /// Arguments to add. + /// Returns a new command with the corresponding changes. + public static DotNetNewUninstall operator +(DotNetNewUninstall command, IEnumerable args) => command.AddArgs(args); + + /// + /// Removes arguments by their name. + /// + /// The command to which arguments will be removed. + /// Arguments to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNewUninstall operator -(DotNetNewUninstall command, IEnumerable args) => command.RemoveArgs(args); + + /// + /// Appends an environment variable. + /// + /// The command to which an environment variable will be added. + /// Environment variable to add. + /// Returns a new command with the corresponding changes. + public static DotNetNewUninstall operator +(DotNetNewUninstall command, (string name, string value) var) => command.AddVars(var); + + /// + /// Removes environment variable by its name and value. + /// + /// The command to which an environment variable will be removed. + /// Environment variable to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNewUninstall operator -(DotNetNewUninstall command, (string name, string value) var) => command.RemoveVars(var); + + /// + /// Appends environment variables. + /// + /// The command to which environment variables will be added. + /// Environment variables to add. + /// Returns a new command with the corresponding changes. + public static DotNetNewUninstall operator +(DotNetNewUninstall command, IEnumerable<(string name, string value)> vars) => command.AddVars(vars); + + /// + /// Removes environment variables by their name and value. + /// + /// The command to which environment variables will be removed. + /// environment variables to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNewUninstall operator -(DotNetNewUninstall command, IEnumerable<(string name, string value)> vars) => command.RemoveVars(vars); +} + +[ExcludeFromCodeCoverage] +public partial record DotNetNewUpdate: ICommandLine +{ + /// + /// Appends an argument. + /// + /// The command to which an argument will be added. + /// Argument to add. + /// Returns a new command with the corresponding changes. + public static DotNetNewUpdate operator +(DotNetNewUpdate command, string arg) => command.AddArgs(arg); + + /// + /// Removes an argument by its name. + /// + /// The command to which an argument will be removed. + /// Argument to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNewUpdate operator -(DotNetNewUpdate command, string arg) => command.RemoveArgs(arg); + + /// + /// Appends arguments. + /// + /// The command to which arguments will be added. + /// Arguments to add. + /// Returns a new command with the corresponding changes. + public static DotNetNewUpdate operator +(DotNetNewUpdate command, IEnumerable args) => command.AddArgs(args); + + /// + /// Removes arguments by their name. + /// + /// The command to which arguments will be removed. + /// Arguments to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNewUpdate operator -(DotNetNewUpdate command, IEnumerable args) => command.RemoveArgs(args); + + /// + /// Appends an environment variable. + /// + /// The command to which an environment variable will be added. + /// Environment variable to add. + /// Returns a new command with the corresponding changes. + public static DotNetNewUpdate operator +(DotNetNewUpdate command, (string name, string value) var) => command.AddVars(var); + + /// + /// Removes environment variable by its name and value. + /// + /// The command to which an environment variable will be removed. + /// Environment variable to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNewUpdate operator -(DotNetNewUpdate command, (string name, string value) var) => command.RemoveVars(var); + + /// + /// Appends environment variables. + /// + /// The command to which environment variables will be added. + /// Environment variables to add. + /// Returns a new command with the corresponding changes. + public static DotNetNewUpdate operator +(DotNetNewUpdate command, IEnumerable<(string name, string value)> vars) => command.AddVars(vars); + + /// + /// Removes environment variables by their name and value. + /// + /// The command to which environment variables will be removed. + /// environment variables to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNewUpdate operator -(DotNetNewUpdate command, IEnumerable<(string name, string value)> vars) => command.RemoveVars(vars); +} + +[ExcludeFromCodeCoverage] +public partial record DotNetNuGetDelete: ICommandLine +{ + /// + /// Appends an argument. + /// + /// The command to which an argument will be added. + /// Argument to add. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetDelete operator +(DotNetNuGetDelete command, string arg) => command.AddArgs(arg); + + /// + /// Removes an argument by its name. + /// + /// The command to which an argument will be removed. + /// Argument to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetDelete operator -(DotNetNuGetDelete command, string arg) => command.RemoveArgs(arg); + + /// + /// Appends arguments. + /// + /// The command to which arguments will be added. + /// Arguments to add. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetDelete operator +(DotNetNuGetDelete command, IEnumerable args) => command.AddArgs(args); + + /// + /// Removes arguments by their name. + /// + /// The command to which arguments will be removed. + /// Arguments to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetDelete operator -(DotNetNuGetDelete command, IEnumerable args) => command.RemoveArgs(args); + + /// + /// Appends an environment variable. + /// + /// The command to which an environment variable will be added. + /// Environment variable to add. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetDelete operator +(DotNetNuGetDelete command, (string name, string value) var) => command.AddVars(var); + + /// + /// Removes environment variable by its name and value. + /// + /// The command to which an environment variable will be removed. + /// Environment variable to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetDelete operator -(DotNetNuGetDelete command, (string name, string value) var) => command.RemoveVars(var); + + /// + /// Appends environment variables. + /// + /// The command to which environment variables will be added. + /// Environment variables to add. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetDelete operator +(DotNetNuGetDelete command, IEnumerable<(string name, string value)> vars) => command.AddVars(vars); + + /// + /// Removes environment variables by their name and value. + /// + /// The command to which environment variables will be removed. + /// environment variables to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetDelete operator -(DotNetNuGetDelete command, IEnumerable<(string name, string value)> vars) => command.RemoveVars(vars); +} + +[ExcludeFromCodeCoverage] +public partial record DotNetNuGetLocalsClear: ICommandLine +{ + /// + /// Appends an argument. + /// + /// The command to which an argument will be added. + /// Argument to add. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetLocalsClear operator +(DotNetNuGetLocalsClear command, string arg) => command.AddArgs(arg); + + /// + /// Removes an argument by its name. + /// + /// The command to which an argument will be removed. + /// Argument to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetLocalsClear operator -(DotNetNuGetLocalsClear command, string arg) => command.RemoveArgs(arg); + + /// + /// Appends arguments. + /// + /// The command to which arguments will be added. + /// Arguments to add. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetLocalsClear operator +(DotNetNuGetLocalsClear command, IEnumerable args) => command.AddArgs(args); + + /// + /// Removes arguments by their name. + /// + /// The command to which arguments will be removed. + /// Arguments to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetLocalsClear operator -(DotNetNuGetLocalsClear command, IEnumerable args) => command.RemoveArgs(args); + + /// + /// Appends an environment variable. + /// + /// The command to which an environment variable will be added. + /// Environment variable to add. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetLocalsClear operator +(DotNetNuGetLocalsClear command, (string name, string value) var) => command.AddVars(var); + + /// + /// Removes environment variable by its name and value. + /// + /// The command to which an environment variable will be removed. + /// Environment variable to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetLocalsClear operator -(DotNetNuGetLocalsClear command, (string name, string value) var) => command.RemoveVars(var); + + /// + /// Appends environment variables. + /// + /// The command to which environment variables will be added. + /// Environment variables to add. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetLocalsClear operator +(DotNetNuGetLocalsClear command, IEnumerable<(string name, string value)> vars) => command.AddVars(vars); + + /// + /// Removes environment variables by their name and value. + /// + /// The command to which environment variables will be removed. + /// environment variables to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetLocalsClear operator -(DotNetNuGetLocalsClear command, IEnumerable<(string name, string value)> vars) => command.RemoveVars(vars); +} + +[ExcludeFromCodeCoverage] +public partial record DotNetNuGetLocalsList: ICommandLine +{ + /// + /// Appends an argument. + /// + /// The command to which an argument will be added. + /// Argument to add. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetLocalsList operator +(DotNetNuGetLocalsList command, string arg) => command.AddArgs(arg); + + /// + /// Removes an argument by its name. + /// + /// The command to which an argument will be removed. + /// Argument to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetLocalsList operator -(DotNetNuGetLocalsList command, string arg) => command.RemoveArgs(arg); + + /// + /// Appends arguments. + /// + /// The command to which arguments will be added. + /// Arguments to add. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetLocalsList operator +(DotNetNuGetLocalsList command, IEnumerable args) => command.AddArgs(args); + + /// + /// Removes arguments by their name. + /// + /// The command to which arguments will be removed. + /// Arguments to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetLocalsList operator -(DotNetNuGetLocalsList command, IEnumerable args) => command.RemoveArgs(args); + + /// + /// Appends an environment variable. + /// + /// The command to which an environment variable will be added. + /// Environment variable to add. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetLocalsList operator +(DotNetNuGetLocalsList command, (string name, string value) var) => command.AddVars(var); + + /// + /// Removes environment variable by its name and value. + /// + /// The command to which an environment variable will be removed. + /// Environment variable to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetLocalsList operator -(DotNetNuGetLocalsList command, (string name, string value) var) => command.RemoveVars(var); + + /// + /// Appends environment variables. + /// + /// The command to which environment variables will be added. + /// Environment variables to add. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetLocalsList operator +(DotNetNuGetLocalsList command, IEnumerable<(string name, string value)> vars) => command.AddVars(vars); + + /// + /// Removes environment variables by their name and value. + /// + /// The command to which environment variables will be removed. + /// environment variables to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetLocalsList operator -(DotNetNuGetLocalsList command, IEnumerable<(string name, string value)> vars) => command.RemoveVars(vars); +} + +[ExcludeFromCodeCoverage] +public partial record DotNetNuGetPush: ICommandLine +{ + /// + /// Appends an argument. + /// + /// The command to which an argument will be added. + /// Argument to add. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetPush operator +(DotNetNuGetPush command, string arg) => command.AddArgs(arg); + + /// + /// Removes an argument by its name. + /// + /// The command to which an argument will be removed. + /// Argument to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetPush operator -(DotNetNuGetPush command, string arg) => command.RemoveArgs(arg); + + /// + /// Appends arguments. + /// + /// The command to which arguments will be added. + /// Arguments to add. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetPush operator +(DotNetNuGetPush command, IEnumerable args) => command.AddArgs(args); + + /// + /// Removes arguments by their name. + /// + /// The command to which arguments will be removed. + /// Arguments to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetPush operator -(DotNetNuGetPush command, IEnumerable args) => command.RemoveArgs(args); + + /// + /// Appends an environment variable. + /// + /// The command to which an environment variable will be added. + /// Environment variable to add. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetPush operator +(DotNetNuGetPush command, (string name, string value) var) => command.AddVars(var); + + /// + /// Removes environment variable by its name and value. + /// + /// The command to which an environment variable will be removed. + /// Environment variable to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetPush operator -(DotNetNuGetPush command, (string name, string value) var) => command.RemoveVars(var); + + /// + /// Appends environment variables. + /// + /// The command to which environment variables will be added. + /// Environment variables to add. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetPush operator +(DotNetNuGetPush command, IEnumerable<(string name, string value)> vars) => command.AddVars(vars); + + /// + /// Removes environment variables by their name and value. + /// + /// The command to which environment variables will be removed. + /// environment variables to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetPush operator -(DotNetNuGetPush command, IEnumerable<(string name, string value)> vars) => command.RemoveVars(vars); +} + +[ExcludeFromCodeCoverage] +public partial record DotNetNuGetAddSource: ICommandLine +{ + /// + /// Appends an argument. + /// + /// The command to which an argument will be added. + /// Argument to add. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetAddSource operator +(DotNetNuGetAddSource command, string arg) => command.AddArgs(arg); + + /// + /// Removes an argument by its name. + /// + /// The command to which an argument will be removed. + /// Argument to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetAddSource operator -(DotNetNuGetAddSource command, string arg) => command.RemoveArgs(arg); + + /// + /// Appends arguments. + /// + /// The command to which arguments will be added. + /// Arguments to add. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetAddSource operator +(DotNetNuGetAddSource command, IEnumerable args) => command.AddArgs(args); + + /// + /// Removes arguments by their name. + /// + /// The command to which arguments will be removed. + /// Arguments to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetAddSource operator -(DotNetNuGetAddSource command, IEnumerable args) => command.RemoveArgs(args); + + /// + /// Appends an environment variable. + /// + /// The command to which an environment variable will be added. + /// Environment variable to add. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetAddSource operator +(DotNetNuGetAddSource command, (string name, string value) var) => command.AddVars(var); + + /// + /// Removes environment variable by its name and value. + /// + /// The command to which an environment variable will be removed. + /// Environment variable to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetAddSource operator -(DotNetNuGetAddSource command, (string name, string value) var) => command.RemoveVars(var); + + /// + /// Appends environment variables. + /// + /// The command to which environment variables will be added. + /// Environment variables to add. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetAddSource operator +(DotNetNuGetAddSource command, IEnumerable<(string name, string value)> vars) => command.AddVars(vars); + + /// + /// Removes environment variables by their name and value. + /// + /// The command to which environment variables will be removed. + /// environment variables to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetAddSource operator -(DotNetNuGetAddSource command, IEnumerable<(string name, string value)> vars) => command.RemoveVars(vars); +} + +[ExcludeFromCodeCoverage] +public partial record DotNetNuGetDisableSource: ICommandLine +{ + /// + /// Appends an argument. + /// + /// The command to which an argument will be added. + /// Argument to add. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetDisableSource operator +(DotNetNuGetDisableSource command, string arg) => command.AddArgs(arg); + + /// + /// Removes an argument by its name. + /// + /// The command to which an argument will be removed. + /// Argument to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetDisableSource operator -(DotNetNuGetDisableSource command, string arg) => command.RemoveArgs(arg); + + /// + /// Appends arguments. + /// + /// The command to which arguments will be added. + /// Arguments to add. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetDisableSource operator +(DotNetNuGetDisableSource command, IEnumerable args) => command.AddArgs(args); + + /// + /// Removes arguments by their name. + /// + /// The command to which arguments will be removed. + /// Arguments to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetDisableSource operator -(DotNetNuGetDisableSource command, IEnumerable args) => command.RemoveArgs(args); + + /// + /// Appends an environment variable. + /// + /// The command to which an environment variable will be added. + /// Environment variable to add. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetDisableSource operator +(DotNetNuGetDisableSource command, (string name, string value) var) => command.AddVars(var); + + /// + /// Removes environment variable by its name and value. + /// + /// The command to which an environment variable will be removed. + /// Environment variable to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetDisableSource operator -(DotNetNuGetDisableSource command, (string name, string value) var) => command.RemoveVars(var); + + /// + /// Appends environment variables. + /// + /// The command to which environment variables will be added. + /// Environment variables to add. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetDisableSource operator +(DotNetNuGetDisableSource command, IEnumerable<(string name, string value)> vars) => command.AddVars(vars); + + /// + /// Removes environment variables by their name and value. + /// + /// The command to which environment variables will be removed. + /// environment variables to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetDisableSource operator -(DotNetNuGetDisableSource command, IEnumerable<(string name, string value)> vars) => command.RemoveVars(vars); +} + +[ExcludeFromCodeCoverage] +public partial record DotNetNuGetEnableSource: ICommandLine +{ + /// + /// Appends an argument. + /// + /// The command to which an argument will be added. + /// Argument to add. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetEnableSource operator +(DotNetNuGetEnableSource command, string arg) => command.AddArgs(arg); + + /// + /// Removes an argument by its name. + /// + /// The command to which an argument will be removed. + /// Argument to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetEnableSource operator -(DotNetNuGetEnableSource command, string arg) => command.RemoveArgs(arg); + + /// + /// Appends arguments. + /// + /// The command to which arguments will be added. + /// Arguments to add. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetEnableSource operator +(DotNetNuGetEnableSource command, IEnumerable args) => command.AddArgs(args); + + /// + /// Removes arguments by their name. + /// + /// The command to which arguments will be removed. + /// Arguments to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetEnableSource operator -(DotNetNuGetEnableSource command, IEnumerable args) => command.RemoveArgs(args); + + /// + /// Appends an environment variable. + /// + /// The command to which an environment variable will be added. + /// Environment variable to add. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetEnableSource operator +(DotNetNuGetEnableSource command, (string name, string value) var) => command.AddVars(var); + + /// + /// Removes environment variable by its name and value. + /// + /// The command to which an environment variable will be removed. + /// Environment variable to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetEnableSource operator -(DotNetNuGetEnableSource command, (string name, string value) var) => command.RemoveVars(var); + + /// + /// Appends environment variables. + /// + /// The command to which environment variables will be added. + /// Environment variables to add. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetEnableSource operator +(DotNetNuGetEnableSource command, IEnumerable<(string name, string value)> vars) => command.AddVars(vars); + + /// + /// Removes environment variables by their name and value. + /// + /// The command to which environment variables will be removed. + /// environment variables to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetEnableSource operator -(DotNetNuGetEnableSource command, IEnumerable<(string name, string value)> vars) => command.RemoveVars(vars); +} + +[ExcludeFromCodeCoverage] +public partial record DotNetNuGetListSource: ICommandLine +{ + /// + /// Appends an argument. + /// + /// The command to which an argument will be added. + /// Argument to add. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetListSource operator +(DotNetNuGetListSource command, string arg) => command.AddArgs(arg); + + /// + /// Removes an argument by its name. + /// + /// The command to which an argument will be removed. + /// Argument to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetListSource operator -(DotNetNuGetListSource command, string arg) => command.RemoveArgs(arg); + + /// + /// Appends arguments. + /// + /// The command to which arguments will be added. + /// Arguments to add. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetListSource operator +(DotNetNuGetListSource command, IEnumerable args) => command.AddArgs(args); + + /// + /// Removes arguments by their name. + /// + /// The command to which arguments will be removed. + /// Arguments to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetListSource operator -(DotNetNuGetListSource command, IEnumerable args) => command.RemoveArgs(args); + + /// + /// Appends an environment variable. + /// + /// The command to which an environment variable will be added. + /// Environment variable to add. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetListSource operator +(DotNetNuGetListSource command, (string name, string value) var) => command.AddVars(var); + + /// + /// Removes environment variable by its name and value. + /// + /// The command to which an environment variable will be removed. + /// Environment variable to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetListSource operator -(DotNetNuGetListSource command, (string name, string value) var) => command.RemoveVars(var); + + /// + /// Appends environment variables. + /// + /// The command to which environment variables will be added. + /// Environment variables to add. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetListSource operator +(DotNetNuGetListSource command, IEnumerable<(string name, string value)> vars) => command.AddVars(vars); + + /// + /// Removes environment variables by their name and value. + /// + /// The command to which environment variables will be removed. + /// environment variables to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetListSource operator -(DotNetNuGetListSource command, IEnumerable<(string name, string value)> vars) => command.RemoveVars(vars); +} + +[ExcludeFromCodeCoverage] +public partial record DotNetNuGetRemoveSource: ICommandLine +{ + /// + /// Appends an argument. + /// + /// The command to which an argument will be added. + /// Argument to add. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetRemoveSource operator +(DotNetNuGetRemoveSource command, string arg) => command.AddArgs(arg); + + /// + /// Removes an argument by its name. + /// + /// The command to which an argument will be removed. + /// Argument to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetRemoveSource operator -(DotNetNuGetRemoveSource command, string arg) => command.RemoveArgs(arg); + + /// + /// Appends arguments. + /// + /// The command to which arguments will be added. + /// Arguments to add. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetRemoveSource operator +(DotNetNuGetRemoveSource command, IEnumerable args) => command.AddArgs(args); + + /// + /// Removes arguments by their name. + /// + /// The command to which arguments will be removed. + /// Arguments to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetRemoveSource operator -(DotNetNuGetRemoveSource command, IEnumerable args) => command.RemoveArgs(args); + + /// + /// Appends an environment variable. + /// + /// The command to which an environment variable will be added. + /// Environment variable to add. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetRemoveSource operator +(DotNetNuGetRemoveSource command, (string name, string value) var) => command.AddVars(var); + + /// + /// Removes environment variable by its name and value. + /// + /// The command to which an environment variable will be removed. + /// Environment variable to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetRemoveSource operator -(DotNetNuGetRemoveSource command, (string name, string value) var) => command.RemoveVars(var); + + /// + /// Appends environment variables. + /// + /// The command to which environment variables will be added. + /// Environment variables to add. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetRemoveSource operator +(DotNetNuGetRemoveSource command, IEnumerable<(string name, string value)> vars) => command.AddVars(vars); + + /// + /// Removes environment variables by their name and value. + /// + /// The command to which environment variables will be removed. + /// environment variables to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetRemoveSource operator -(DotNetNuGetRemoveSource command, IEnumerable<(string name, string value)> vars) => command.RemoveVars(vars); +} + +[ExcludeFromCodeCoverage] +public partial record DotNetNuGetUpdateSource: ICommandLine +{ + /// + /// Appends an argument. + /// + /// The command to which an argument will be added. + /// Argument to add. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetUpdateSource operator +(DotNetNuGetUpdateSource command, string arg) => command.AddArgs(arg); + + /// + /// Removes an argument by its name. + /// + /// The command to which an argument will be removed. + /// Argument to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetUpdateSource operator -(DotNetNuGetUpdateSource command, string arg) => command.RemoveArgs(arg); + + /// + /// Appends arguments. + /// + /// The command to which arguments will be added. + /// Arguments to add. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetUpdateSource operator +(DotNetNuGetUpdateSource command, IEnumerable args) => command.AddArgs(args); + + /// + /// Removes arguments by their name. + /// + /// The command to which arguments will be removed. + /// Arguments to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetUpdateSource operator -(DotNetNuGetUpdateSource command, IEnumerable args) => command.RemoveArgs(args); + + /// + /// Appends an environment variable. + /// + /// The command to which an environment variable will be added. + /// Environment variable to add. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetUpdateSource operator +(DotNetNuGetUpdateSource command, (string name, string value) var) => command.AddVars(var); + + /// + /// Removes environment variable by its name and value. + /// + /// The command to which an environment variable will be removed. + /// Environment variable to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetUpdateSource operator -(DotNetNuGetUpdateSource command, (string name, string value) var) => command.RemoveVars(var); + + /// + /// Appends environment variables. + /// + /// The command to which environment variables will be added. + /// Environment variables to add. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetUpdateSource operator +(DotNetNuGetUpdateSource command, IEnumerable<(string name, string value)> vars) => command.AddVars(vars); + + /// + /// Removes environment variables by their name and value. + /// + /// The command to which environment variables will be removed. + /// environment variables to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetUpdateSource operator -(DotNetNuGetUpdateSource command, IEnumerable<(string name, string value)> vars) => command.RemoveVars(vars); +} + +[ExcludeFromCodeCoverage] +public partial record DotNetNuGetVerify: ICommandLine +{ + /// + /// Appends an argument. + /// + /// The command to which an argument will be added. + /// Argument to add. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetVerify operator +(DotNetNuGetVerify command, string arg) => command.AddArgs(arg); + + /// + /// Removes an argument by its name. + /// + /// The command to which an argument will be removed. + /// Argument to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetVerify operator -(DotNetNuGetVerify command, string arg) => command.RemoveArgs(arg); + + /// + /// Appends arguments. + /// + /// The command to which arguments will be added. + /// Arguments to add. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetVerify operator +(DotNetNuGetVerify command, IEnumerable args) => command.AddArgs(args); + + /// + /// Removes arguments by their name. + /// + /// The command to which arguments will be removed. + /// Arguments to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetVerify operator -(DotNetNuGetVerify command, IEnumerable args) => command.RemoveArgs(args); + + /// + /// Appends an environment variable. + /// + /// The command to which an environment variable will be added. + /// Environment variable to add. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetVerify operator +(DotNetNuGetVerify command, (string name, string value) var) => command.AddVars(var); + + /// + /// Removes environment variable by its name and value. + /// + /// The command to which an environment variable will be removed. + /// Environment variable to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetVerify operator -(DotNetNuGetVerify command, (string name, string value) var) => command.RemoveVars(var); + + /// + /// Appends environment variables. + /// + /// The command to which environment variables will be added. + /// Environment variables to add. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetVerify operator +(DotNetNuGetVerify command, IEnumerable<(string name, string value)> vars) => command.AddVars(vars); + + /// + /// Removes environment variables by their name and value. + /// + /// The command to which environment variables will be removed. + /// environment variables to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetVerify operator -(DotNetNuGetVerify command, IEnumerable<(string name, string value)> vars) => command.RemoveVars(vars); +} + +[ExcludeFromCodeCoverage] +public partial record DotNetNuGetTrustList: ICommandLine +{ + /// + /// Appends an argument. + /// + /// The command to which an argument will be added. + /// Argument to add. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetTrustList operator +(DotNetNuGetTrustList command, string arg) => command.AddArgs(arg); + + /// + /// Removes an argument by its name. + /// + /// The command to which an argument will be removed. + /// Argument to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetTrustList operator -(DotNetNuGetTrustList command, string arg) => command.RemoveArgs(arg); + + /// + /// Appends arguments. + /// + /// The command to which arguments will be added. + /// Arguments to add. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetTrustList operator +(DotNetNuGetTrustList command, IEnumerable args) => command.AddArgs(args); + + /// + /// Removes arguments by their name. + /// + /// The command to which arguments will be removed. + /// Arguments to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetTrustList operator -(DotNetNuGetTrustList command, IEnumerable args) => command.RemoveArgs(args); + + /// + /// Appends an environment variable. + /// + /// The command to which an environment variable will be added. + /// Environment variable to add. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetTrustList operator +(DotNetNuGetTrustList command, (string name, string value) var) => command.AddVars(var); + + /// + /// Removes environment variable by its name and value. + /// + /// The command to which an environment variable will be removed. + /// Environment variable to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetTrustList operator -(DotNetNuGetTrustList command, (string name, string value) var) => command.RemoveVars(var); + + /// + /// Appends environment variables. + /// + /// The command to which environment variables will be added. + /// Environment variables to add. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetTrustList operator +(DotNetNuGetTrustList command, IEnumerable<(string name, string value)> vars) => command.AddVars(vars); + + /// + /// Removes environment variables by their name and value. + /// + /// The command to which environment variables will be removed. + /// environment variables to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetTrustList operator -(DotNetNuGetTrustList command, IEnumerable<(string name, string value)> vars) => command.RemoveVars(vars); +} + +[ExcludeFromCodeCoverage] +public partial record DotNetNuGetTrustSync: ICommandLine +{ + /// + /// Appends an argument. + /// + /// The command to which an argument will be added. + /// Argument to add. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetTrustSync operator +(DotNetNuGetTrustSync command, string arg) => command.AddArgs(arg); + + /// + /// Removes an argument by its name. + /// + /// The command to which an argument will be removed. + /// Argument to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetTrustSync operator -(DotNetNuGetTrustSync command, string arg) => command.RemoveArgs(arg); + + /// + /// Appends arguments. + /// + /// The command to which arguments will be added. + /// Arguments to add. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetTrustSync operator +(DotNetNuGetTrustSync command, IEnumerable args) => command.AddArgs(args); + + /// + /// Removes arguments by their name. + /// + /// The command to which arguments will be removed. + /// Arguments to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetTrustSync operator -(DotNetNuGetTrustSync command, IEnumerable args) => command.RemoveArgs(args); + + /// + /// Appends an environment variable. + /// + /// The command to which an environment variable will be added. + /// Environment variable to add. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetTrustSync operator +(DotNetNuGetTrustSync command, (string name, string value) var) => command.AddVars(var); + + /// + /// Removes environment variable by its name and value. + /// + /// The command to which an environment variable will be removed. + /// Environment variable to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetTrustSync operator -(DotNetNuGetTrustSync command, (string name, string value) var) => command.RemoveVars(var); + + /// + /// Appends environment variables. + /// + /// The command to which environment variables will be added. + /// Environment variables to add. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetTrustSync operator +(DotNetNuGetTrustSync command, IEnumerable<(string name, string value)> vars) => command.AddVars(vars); + + /// + /// Removes environment variables by their name and value. + /// + /// The command to which environment variables will be removed. + /// environment variables to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetTrustSync operator -(DotNetNuGetTrustSync command, IEnumerable<(string name, string value)> vars) => command.RemoveVars(vars); +} + +[ExcludeFromCodeCoverage] +public partial record DotNetNuGetTrustRemove: ICommandLine +{ + /// + /// Appends an argument. + /// + /// The command to which an argument will be added. + /// Argument to add. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetTrustRemove operator +(DotNetNuGetTrustRemove command, string arg) => command.AddArgs(arg); + + /// + /// Removes an argument by its name. + /// + /// The command to which an argument will be removed. + /// Argument to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetTrustRemove operator -(DotNetNuGetTrustRemove command, string arg) => command.RemoveArgs(arg); + + /// + /// Appends arguments. + /// + /// The command to which arguments will be added. + /// Arguments to add. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetTrustRemove operator +(DotNetNuGetTrustRemove command, IEnumerable args) => command.AddArgs(args); + + /// + /// Removes arguments by their name. + /// + /// The command to which arguments will be removed. + /// Arguments to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetTrustRemove operator -(DotNetNuGetTrustRemove command, IEnumerable args) => command.RemoveArgs(args); + + /// + /// Appends an environment variable. + /// + /// The command to which an environment variable will be added. + /// Environment variable to add. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetTrustRemove operator +(DotNetNuGetTrustRemove command, (string name, string value) var) => command.AddVars(var); + + /// + /// Removes environment variable by its name and value. + /// + /// The command to which an environment variable will be removed. + /// Environment variable to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetTrustRemove operator -(DotNetNuGetTrustRemove command, (string name, string value) var) => command.RemoveVars(var); + + /// + /// Appends environment variables. + /// + /// The command to which environment variables will be added. + /// Environment variables to add. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetTrustRemove operator +(DotNetNuGetTrustRemove command, IEnumerable<(string name, string value)> vars) => command.AddVars(vars); + + /// + /// Removes environment variables by their name and value. + /// + /// The command to which environment variables will be removed. + /// environment variables to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetTrustRemove operator -(DotNetNuGetTrustRemove command, IEnumerable<(string name, string value)> vars) => command.RemoveVars(vars); +} + +[ExcludeFromCodeCoverage] +public partial record DotNetNuGetTrustAuthor: ICommandLine +{ + /// + /// Appends an argument. + /// + /// The command to which an argument will be added. + /// Argument to add. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetTrustAuthor operator +(DotNetNuGetTrustAuthor command, string arg) => command.AddArgs(arg); + + /// + /// Removes an argument by its name. + /// + /// The command to which an argument will be removed. + /// Argument to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetTrustAuthor operator -(DotNetNuGetTrustAuthor command, string arg) => command.RemoveArgs(arg); + + /// + /// Appends arguments. + /// + /// The command to which arguments will be added. + /// Arguments to add. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetTrustAuthor operator +(DotNetNuGetTrustAuthor command, IEnumerable args) => command.AddArgs(args); + + /// + /// Removes arguments by their name. + /// + /// The command to which arguments will be removed. + /// Arguments to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetTrustAuthor operator -(DotNetNuGetTrustAuthor command, IEnumerable args) => command.RemoveArgs(args); + + /// + /// Appends an environment variable. + /// + /// The command to which an environment variable will be added. + /// Environment variable to add. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetTrustAuthor operator +(DotNetNuGetTrustAuthor command, (string name, string value) var) => command.AddVars(var); + + /// + /// Removes environment variable by its name and value. + /// + /// The command to which an environment variable will be removed. + /// Environment variable to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetTrustAuthor operator -(DotNetNuGetTrustAuthor command, (string name, string value) var) => command.RemoveVars(var); + + /// + /// Appends environment variables. + /// + /// The command to which environment variables will be added. + /// Environment variables to add. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetTrustAuthor operator +(DotNetNuGetTrustAuthor command, IEnumerable<(string name, string value)> vars) => command.AddVars(vars); + + /// + /// Removes environment variables by their name and value. + /// + /// The command to which environment variables will be removed. + /// environment variables to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetTrustAuthor operator -(DotNetNuGetTrustAuthor command, IEnumerable<(string name, string value)> vars) => command.RemoveVars(vars); +} + +[ExcludeFromCodeCoverage] +public partial record DotNetNuGetTrustRepository: ICommandLine +{ + /// + /// Appends an argument. + /// + /// The command to which an argument will be added. + /// Argument to add. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetTrustRepository operator +(DotNetNuGetTrustRepository command, string arg) => command.AddArgs(arg); + + /// + /// Removes an argument by its name. + /// + /// The command to which an argument will be removed. + /// Argument to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetTrustRepository operator -(DotNetNuGetTrustRepository command, string arg) => command.RemoveArgs(arg); + + /// + /// Appends arguments. + /// + /// The command to which arguments will be added. + /// Arguments to add. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetTrustRepository operator +(DotNetNuGetTrustRepository command, IEnumerable args) => command.AddArgs(args); + + /// + /// Removes arguments by their name. + /// + /// The command to which arguments will be removed. + /// Arguments to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetTrustRepository operator -(DotNetNuGetTrustRepository command, IEnumerable args) => command.RemoveArgs(args); + + /// + /// Appends an environment variable. + /// + /// The command to which an environment variable will be added. + /// Environment variable to add. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetTrustRepository operator +(DotNetNuGetTrustRepository command, (string name, string value) var) => command.AddVars(var); + + /// + /// Removes environment variable by its name and value. + /// + /// The command to which an environment variable will be removed. + /// Environment variable to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetTrustRepository operator -(DotNetNuGetTrustRepository command, (string name, string value) var) => command.RemoveVars(var); + + /// + /// Appends environment variables. + /// + /// The command to which environment variables will be added. + /// Environment variables to add. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetTrustRepository operator +(DotNetNuGetTrustRepository command, IEnumerable<(string name, string value)> vars) => command.AddVars(vars); + + /// + /// Removes environment variables by their name and value. + /// + /// The command to which environment variables will be removed. + /// environment variables to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetTrustRepository operator -(DotNetNuGetTrustRepository command, IEnumerable<(string name, string value)> vars) => command.RemoveVars(vars); +} + +[ExcludeFromCodeCoverage] +public partial record DotNetNuGetTrustCertificate: ICommandLine +{ + /// + /// Appends an argument. + /// + /// The command to which an argument will be added. + /// Argument to add. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetTrustCertificate operator +(DotNetNuGetTrustCertificate command, string arg) => command.AddArgs(arg); + + /// + /// Removes an argument by its name. + /// + /// The command to which an argument will be removed. + /// Argument to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetTrustCertificate operator -(DotNetNuGetTrustCertificate command, string arg) => command.RemoveArgs(arg); + + /// + /// Appends arguments. + /// + /// The command to which arguments will be added. + /// Arguments to add. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetTrustCertificate operator +(DotNetNuGetTrustCertificate command, IEnumerable args) => command.AddArgs(args); + + /// + /// Removes arguments by their name. + /// + /// The command to which arguments will be removed. + /// Arguments to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetTrustCertificate operator -(DotNetNuGetTrustCertificate command, IEnumerable args) => command.RemoveArgs(args); + + /// + /// Appends an environment variable. + /// + /// The command to which an environment variable will be added. + /// Environment variable to add. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetTrustCertificate operator +(DotNetNuGetTrustCertificate command, (string name, string value) var) => command.AddVars(var); + + /// + /// Removes environment variable by its name and value. + /// + /// The command to which an environment variable will be removed. + /// Environment variable to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetTrustCertificate operator -(DotNetNuGetTrustCertificate command, (string name, string value) var) => command.RemoveVars(var); + + /// + /// Appends environment variables. + /// + /// The command to which environment variables will be added. + /// Environment variables to add. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetTrustCertificate operator +(DotNetNuGetTrustCertificate command, IEnumerable<(string name, string value)> vars) => command.AddVars(vars); + + /// + /// Removes environment variables by their name and value. + /// + /// The command to which environment variables will be removed. + /// environment variables to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetTrustCertificate operator -(DotNetNuGetTrustCertificate command, IEnumerable<(string name, string value)> vars) => command.RemoveVars(vars); +} + +[ExcludeFromCodeCoverage] +public partial record DotNetNuGetTrustSource: ICommandLine +{ + /// + /// Appends an argument. + /// + /// The command to which an argument will be added. + /// Argument to add. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetTrustSource operator +(DotNetNuGetTrustSource command, string arg) => command.AddArgs(arg); + + /// + /// Removes an argument by its name. + /// + /// The command to which an argument will be removed. + /// Argument to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetTrustSource operator -(DotNetNuGetTrustSource command, string arg) => command.RemoveArgs(arg); + + /// + /// Appends arguments. + /// + /// The command to which arguments will be added. + /// Arguments to add. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetTrustSource operator +(DotNetNuGetTrustSource command, IEnumerable args) => command.AddArgs(args); + + /// + /// Removes arguments by their name. + /// + /// The command to which arguments will be removed. + /// Arguments to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetTrustSource operator -(DotNetNuGetTrustSource command, IEnumerable args) => command.RemoveArgs(args); + + /// + /// Appends an environment variable. + /// + /// The command to which an environment variable will be added. + /// Environment variable to add. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetTrustSource operator +(DotNetNuGetTrustSource command, (string name, string value) var) => command.AddVars(var); + + /// + /// Removes environment variable by its name and value. + /// + /// The command to which an environment variable will be removed. + /// Environment variable to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetTrustSource operator -(DotNetNuGetTrustSource command, (string name, string value) var) => command.RemoveVars(var); + + /// + /// Appends environment variables. + /// + /// The command to which environment variables will be added. + /// Environment variables to add. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetTrustSource operator +(DotNetNuGetTrustSource command, IEnumerable<(string name, string value)> vars) => command.AddVars(vars); + + /// + /// Removes environment variables by their name and value. + /// + /// The command to which environment variables will be removed. + /// environment variables to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetTrustSource operator -(DotNetNuGetTrustSource command, IEnumerable<(string name, string value)> vars) => command.RemoveVars(vars); +} + +[ExcludeFromCodeCoverage] +public partial record DotNetNuGetSign: ICommandLine +{ + /// + /// Appends an argument. + /// + /// The command to which an argument will be added. + /// Argument to add. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetSign operator +(DotNetNuGetSign command, string arg) => command.AddArgs(arg); + + /// + /// Removes an argument by its name. + /// + /// The command to which an argument will be removed. + /// Argument to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetSign operator -(DotNetNuGetSign command, string arg) => command.RemoveArgs(arg); + + /// + /// Appends arguments. + /// + /// The command to which arguments will be added. + /// Arguments to add. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetSign operator +(DotNetNuGetSign command, IEnumerable args) => command.AddArgs(args); + + /// + /// Removes arguments by their name. + /// + /// The command to which arguments will be removed. + /// Arguments to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetSign operator -(DotNetNuGetSign command, IEnumerable args) => command.RemoveArgs(args); + + /// + /// Appends an environment variable. + /// + /// The command to which an environment variable will be added. + /// Environment variable to add. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetSign operator +(DotNetNuGetSign command, (string name, string value) var) => command.AddVars(var); + + /// + /// Removes environment variable by its name and value. + /// + /// The command to which an environment variable will be removed. + /// Environment variable to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetSign operator -(DotNetNuGetSign command, (string name, string value) var) => command.RemoveVars(var); + + /// + /// Appends environment variables. + /// + /// The command to which environment variables will be added. + /// Environment variables to add. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetSign operator +(DotNetNuGetSign command, IEnumerable<(string name, string value)> vars) => command.AddVars(vars); + + /// + /// Removes environment variables by their name and value. + /// + /// The command to which environment variables will be removed. + /// environment variables to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetSign operator -(DotNetNuGetSign command, IEnumerable<(string name, string value)> vars) => command.RemoveVars(vars); +} + +[ExcludeFromCodeCoverage] +public partial record DotNetNuGetWhy: ICommandLine +{ + /// + /// Appends an argument. + /// + /// The command to which an argument will be added. + /// Argument to add. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetWhy operator +(DotNetNuGetWhy command, string arg) => command.AddArgs(arg); + + /// + /// Removes an argument by its name. + /// + /// The command to which an argument will be removed. + /// Argument to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetWhy operator -(DotNetNuGetWhy command, string arg) => command.RemoveArgs(arg); + + /// + /// Appends arguments. + /// + /// The command to which arguments will be added. + /// Arguments to add. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetWhy operator +(DotNetNuGetWhy command, IEnumerable args) => command.AddArgs(args); + + /// + /// Removes arguments by their name. + /// + /// The command to which arguments will be removed. + /// Arguments to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetWhy operator -(DotNetNuGetWhy command, IEnumerable args) => command.RemoveArgs(args); + + /// + /// Appends an environment variable. + /// + /// The command to which an environment variable will be added. + /// Environment variable to add. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetWhy operator +(DotNetNuGetWhy command, (string name, string value) var) => command.AddVars(var); + + /// + /// Removes environment variable by its name and value. + /// + /// The command to which an environment variable will be removed. + /// Environment variable to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetWhy operator -(DotNetNuGetWhy command, (string name, string value) var) => command.RemoveVars(var); + + /// + /// Appends environment variables. + /// + /// The command to which environment variables will be added. + /// Environment variables to add. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetWhy operator +(DotNetNuGetWhy command, IEnumerable<(string name, string value)> vars) => command.AddVars(vars); + + /// + /// Removes environment variables by their name and value. + /// + /// The command to which environment variables will be removed. + /// environment variables to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetWhy operator -(DotNetNuGetWhy command, IEnumerable<(string name, string value)> vars) => command.RemoveVars(vars); +} + +[ExcludeFromCodeCoverage] +public partial record DotNetNuGetConfigGet: ICommandLine +{ + /// + /// Appends an argument. + /// + /// The command to which an argument will be added. + /// Argument to add. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetConfigGet operator +(DotNetNuGetConfigGet command, string arg) => command.AddArgs(arg); + + /// + /// Removes an argument by its name. + /// + /// The command to which an argument will be removed. + /// Argument to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetConfigGet operator -(DotNetNuGetConfigGet command, string arg) => command.RemoveArgs(arg); + + /// + /// Appends arguments. + /// + /// The command to which arguments will be added. + /// Arguments to add. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetConfigGet operator +(DotNetNuGetConfigGet command, IEnumerable args) => command.AddArgs(args); + + /// + /// Removes arguments by their name. + /// + /// The command to which arguments will be removed. + /// Arguments to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetConfigGet operator -(DotNetNuGetConfigGet command, IEnumerable args) => command.RemoveArgs(args); + + /// + /// Appends an environment variable. + /// + /// The command to which an environment variable will be added. + /// Environment variable to add. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetConfigGet operator +(DotNetNuGetConfigGet command, (string name, string value) var) => command.AddVars(var); + + /// + /// Removes environment variable by its name and value. + /// + /// The command to which an environment variable will be removed. + /// Environment variable to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetConfigGet operator -(DotNetNuGetConfigGet command, (string name, string value) var) => command.RemoveVars(var); + + /// + /// Appends environment variables. + /// + /// The command to which environment variables will be added. + /// Environment variables to add. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetConfigGet operator +(DotNetNuGetConfigGet command, IEnumerable<(string name, string value)> vars) => command.AddVars(vars); + + /// + /// Removes environment variables by their name and value. + /// + /// The command to which environment variables will be removed. + /// environment variables to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetConfigGet operator -(DotNetNuGetConfigGet command, IEnumerable<(string name, string value)> vars) => command.RemoveVars(vars); +} + +[ExcludeFromCodeCoverage] +public partial record DotNetNuGetConfigSet: ICommandLine +{ + /// + /// Appends an argument. + /// + /// The command to which an argument will be added. + /// Argument to add. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetConfigSet operator +(DotNetNuGetConfigSet command, string arg) => command.AddArgs(arg); + + /// + /// Removes an argument by its name. + /// + /// The command to which an argument will be removed. + /// Argument to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetConfigSet operator -(DotNetNuGetConfigSet command, string arg) => command.RemoveArgs(arg); + + /// + /// Appends arguments. + /// + /// The command to which arguments will be added. + /// Arguments to add. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetConfigSet operator +(DotNetNuGetConfigSet command, IEnumerable args) => command.AddArgs(args); + + /// + /// Removes arguments by their name. + /// + /// The command to which arguments will be removed. + /// Arguments to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetConfigSet operator -(DotNetNuGetConfigSet command, IEnumerable args) => command.RemoveArgs(args); + + /// + /// Appends an environment variable. + /// + /// The command to which an environment variable will be added. + /// Environment variable to add. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetConfigSet operator +(DotNetNuGetConfigSet command, (string name, string value) var) => command.AddVars(var); + + /// + /// Removes environment variable by its name and value. + /// + /// The command to which an environment variable will be removed. + /// Environment variable to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetConfigSet operator -(DotNetNuGetConfigSet command, (string name, string value) var) => command.RemoveVars(var); + + /// + /// Appends environment variables. + /// + /// The command to which environment variables will be added. + /// Environment variables to add. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetConfigSet operator +(DotNetNuGetConfigSet command, IEnumerable<(string name, string value)> vars) => command.AddVars(vars); + + /// + /// Removes environment variables by their name and value. + /// + /// The command to which environment variables will be removed. + /// environment variables to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetConfigSet operator -(DotNetNuGetConfigSet command, IEnumerable<(string name, string value)> vars) => command.RemoveVars(vars); +} + +[ExcludeFromCodeCoverage] +public partial record DotNetNuGetConfigUnset: ICommandLine +{ + /// + /// Appends an argument. + /// + /// The command to which an argument will be added. + /// Argument to add. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetConfigUnset operator +(DotNetNuGetConfigUnset command, string arg) => command.AddArgs(arg); + + /// + /// Removes an argument by its name. + /// + /// The command to which an argument will be removed. + /// Argument to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetConfigUnset operator -(DotNetNuGetConfigUnset command, string arg) => command.RemoveArgs(arg); + + /// + /// Appends arguments. + /// + /// The command to which arguments will be added. + /// Arguments to add. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetConfigUnset operator +(DotNetNuGetConfigUnset command, IEnumerable args) => command.AddArgs(args); + + /// + /// Removes arguments by their name. + /// + /// The command to which arguments will be removed. + /// Arguments to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetConfigUnset operator -(DotNetNuGetConfigUnset command, IEnumerable args) => command.RemoveArgs(args); + + /// + /// Appends an environment variable. + /// + /// The command to which an environment variable will be added. + /// Environment variable to add. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetConfigUnset operator +(DotNetNuGetConfigUnset command, (string name, string value) var) => command.AddVars(var); + + /// + /// Removes environment variable by its name and value. + /// + /// The command to which an environment variable will be removed. + /// Environment variable to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetConfigUnset operator -(DotNetNuGetConfigUnset command, (string name, string value) var) => command.RemoveVars(var); + + /// + /// Appends environment variables. + /// + /// The command to which environment variables will be added. + /// Environment variables to add. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetConfigUnset operator +(DotNetNuGetConfigUnset command, IEnumerable<(string name, string value)> vars) => command.AddVars(vars); + + /// + /// Removes environment variables by their name and value. + /// + /// The command to which environment variables will be removed. + /// environment variables to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetConfigUnset operator -(DotNetNuGetConfigUnset command, IEnumerable<(string name, string value)> vars) => command.RemoveVars(vars); +} + +[ExcludeFromCodeCoverage] +public partial record DotNetNuGetConfigPaths: ICommandLine +{ + /// + /// Appends an argument. + /// + /// The command to which an argument will be added. + /// Argument to add. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetConfigPaths operator +(DotNetNuGetConfigPaths command, string arg) => command.AddArgs(arg); + + /// + /// Removes an argument by its name. + /// + /// The command to which an argument will be removed. + /// Argument to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetConfigPaths operator -(DotNetNuGetConfigPaths command, string arg) => command.RemoveArgs(arg); + + /// + /// Appends arguments. + /// + /// The command to which arguments will be added. + /// Arguments to add. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetConfigPaths operator +(DotNetNuGetConfigPaths command, IEnumerable args) => command.AddArgs(args); + + /// + /// Removes arguments by their name. + /// + /// The command to which arguments will be removed. + /// Arguments to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetConfigPaths operator -(DotNetNuGetConfigPaths command, IEnumerable args) => command.RemoveArgs(args); + + /// + /// Appends an environment variable. + /// + /// The command to which an environment variable will be added. + /// Environment variable to add. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetConfigPaths operator +(DotNetNuGetConfigPaths command, (string name, string value) var) => command.AddVars(var); + + /// + /// Removes environment variable by its name and value. + /// + /// The command to which an environment variable will be removed. + /// Environment variable to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetConfigPaths operator -(DotNetNuGetConfigPaths command, (string name, string value) var) => command.RemoveVars(var); + + /// + /// Appends environment variables. + /// + /// The command to which environment variables will be added. + /// Environment variables to add. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetConfigPaths operator +(DotNetNuGetConfigPaths command, IEnumerable<(string name, string value)> vars) => command.AddVars(vars); + + /// + /// Removes environment variables by their name and value. + /// + /// The command to which environment variables will be removed. + /// environment variables to remove. + /// Returns a new command with the corresponding changes. + public static DotNetNuGetConfigPaths operator -(DotNetNuGetConfigPaths command, IEnumerable<(string name, string value)> vars) => command.RemoveVars(vars); +} + +[ExcludeFromCodeCoverage] +public partial record DotNetPackageSearch: ICommandLine +{ + /// + /// Appends an argument. + /// + /// The command to which an argument will be added. + /// Argument to add. + /// Returns a new command with the corresponding changes. + public static DotNetPackageSearch operator +(DotNetPackageSearch command, string arg) => command.AddArgs(arg); + + /// + /// Removes an argument by its name. + /// + /// The command to which an argument will be removed. + /// Argument to remove. + /// Returns a new command with the corresponding changes. + public static DotNetPackageSearch operator -(DotNetPackageSearch command, string arg) => command.RemoveArgs(arg); + + /// + /// Appends arguments. + /// + /// The command to which arguments will be added. + /// Arguments to add. + /// Returns a new command with the corresponding changes. + public static DotNetPackageSearch operator +(DotNetPackageSearch command, IEnumerable args) => command.AddArgs(args); + + /// + /// Removes arguments by their name. + /// + /// The command to which arguments will be removed. + /// Arguments to remove. + /// Returns a new command with the corresponding changes. + public static DotNetPackageSearch operator -(DotNetPackageSearch command, IEnumerable args) => command.RemoveArgs(args); + + /// + /// Appends an environment variable. + /// + /// The command to which an environment variable will be added. + /// Environment variable to add. + /// Returns a new command with the corresponding changes. + public static DotNetPackageSearch operator +(DotNetPackageSearch command, (string name, string value) var) => command.AddVars(var); + + /// + /// Removes environment variable by its name and value. + /// + /// The command to which an environment variable will be removed. + /// Environment variable to remove. + /// Returns a new command with the corresponding changes. + public static DotNetPackageSearch operator -(DotNetPackageSearch command, (string name, string value) var) => command.RemoveVars(var); + + /// + /// Appends environment variables. + /// + /// The command to which environment variables will be added. + /// Environment variables to add. + /// Returns a new command with the corresponding changes. + public static DotNetPackageSearch operator +(DotNetPackageSearch command, IEnumerable<(string name, string value)> vars) => command.AddVars(vars); + + /// + /// Removes environment variables by their name and value. + /// + /// The command to which environment variables will be removed. + /// environment variables to remove. + /// Returns a new command with the corresponding changes. + public static DotNetPackageSearch operator -(DotNetPackageSearch command, IEnumerable<(string name, string value)> vars) => command.RemoveVars(vars); +} + +[ExcludeFromCodeCoverage] +public partial record DotNetPack: ICommandLine +{ + /// + /// Appends an argument. + /// + /// The command to which an argument will be added. + /// Argument to add. + /// Returns a new command with the corresponding changes. + public static DotNetPack operator +(DotNetPack command, string arg) => command.AddArgs(arg); + + /// + /// Removes an argument by its name. + /// + /// The command to which an argument will be removed. + /// Argument to remove. + /// Returns a new command with the corresponding changes. + public static DotNetPack operator -(DotNetPack command, string arg) => command.RemoveArgs(arg); + + /// + /// Appends arguments. + /// + /// The command to which arguments will be added. + /// Arguments to add. + /// Returns a new command with the corresponding changes. + public static DotNetPack operator +(DotNetPack command, IEnumerable args) => command.AddArgs(args); + + /// + /// Removes arguments by their name. + /// + /// The command to which arguments will be removed. + /// Arguments to remove. + /// Returns a new command with the corresponding changes. + public static DotNetPack operator -(DotNetPack command, IEnumerable args) => command.RemoveArgs(args); + + /// + /// Appends an environment variable. + /// + /// The command to which an environment variable will be added. + /// Environment variable to add. + /// Returns a new command with the corresponding changes. + public static DotNetPack operator +(DotNetPack command, (string name, string value) var) => command.AddVars(var); + + /// + /// Removes environment variable by its name and value. + /// + /// The command to which an environment variable will be removed. + /// Environment variable to remove. + /// Returns a new command with the corresponding changes. + public static DotNetPack operator -(DotNetPack command, (string name, string value) var) => command.RemoveVars(var); + + /// + /// Appends environment variables. + /// + /// The command to which environment variables will be added. + /// Environment variables to add. + /// Returns a new command with the corresponding changes. + public static DotNetPack operator +(DotNetPack command, IEnumerable<(string name, string value)> vars) => command.AddVars(vars); + + /// + /// Removes environment variables by their name and value. + /// + /// The command to which environment variables will be removed. + /// environment variables to remove. + /// Returns a new command with the corresponding changes. + public static DotNetPack operator -(DotNetPack command, IEnumerable<(string name, string value)> vars) => command.RemoveVars(vars); +} + +[ExcludeFromCodeCoverage] +public partial record DotNetPublish: ICommandLine +{ + /// + /// Appends an argument. + /// + /// The command to which an argument will be added. + /// Argument to add. + /// Returns a new command with the corresponding changes. + public static DotNetPublish operator +(DotNetPublish command, string arg) => command.AddArgs(arg); + + /// + /// Removes an argument by its name. + /// + /// The command to which an argument will be removed. + /// Argument to remove. + /// Returns a new command with the corresponding changes. + public static DotNetPublish operator -(DotNetPublish command, string arg) => command.RemoveArgs(arg); + + /// + /// Appends arguments. + /// + /// The command to which arguments will be added. + /// Arguments to add. + /// Returns a new command with the corresponding changes. + public static DotNetPublish operator +(DotNetPublish command, IEnumerable args) => command.AddArgs(args); + + /// + /// Removes arguments by their name. + /// + /// The command to which arguments will be removed. + /// Arguments to remove. + /// Returns a new command with the corresponding changes. + public static DotNetPublish operator -(DotNetPublish command, IEnumerable args) => command.RemoveArgs(args); + + /// + /// Appends an environment variable. + /// + /// The command to which an environment variable will be added. + /// Environment variable to add. + /// Returns a new command with the corresponding changes. + public static DotNetPublish operator +(DotNetPublish command, (string name, string value) var) => command.AddVars(var); + + /// + /// Removes environment variable by its name and value. + /// + /// The command to which an environment variable will be removed. + /// Environment variable to remove. + /// Returns a new command with the corresponding changes. + public static DotNetPublish operator -(DotNetPublish command, (string name, string value) var) => command.RemoveVars(var); + + /// + /// Appends environment variables. + /// + /// The command to which environment variables will be added. + /// Environment variables to add. + /// Returns a new command with the corresponding changes. + public static DotNetPublish operator +(DotNetPublish command, IEnumerable<(string name, string value)> vars) => command.AddVars(vars); + + /// + /// Removes environment variables by their name and value. + /// + /// The command to which environment variables will be removed. + /// environment variables to remove. + /// Returns a new command with the corresponding changes. + public static DotNetPublish operator -(DotNetPublish command, IEnumerable<(string name, string value)> vars) => command.RemoveVars(vars); +} + +[ExcludeFromCodeCoverage] +public partial record DotNetRestore: ICommandLine +{ + /// + /// Appends an argument. + /// + /// The command to which an argument will be added. + /// Argument to add. + /// Returns a new command with the corresponding changes. + public static DotNetRestore operator +(DotNetRestore command, string arg) => command.AddArgs(arg); + + /// + /// Removes an argument by its name. + /// + /// The command to which an argument will be removed. + /// Argument to remove. + /// Returns a new command with the corresponding changes. + public static DotNetRestore operator -(DotNetRestore command, string arg) => command.RemoveArgs(arg); + + /// + /// Appends arguments. + /// + /// The command to which arguments will be added. + /// Arguments to add. + /// Returns a new command with the corresponding changes. + public static DotNetRestore operator +(DotNetRestore command, IEnumerable args) => command.AddArgs(args); + + /// + /// Removes arguments by their name. + /// + /// The command to which arguments will be removed. + /// Arguments to remove. + /// Returns a new command with the corresponding changes. + public static DotNetRestore operator -(DotNetRestore command, IEnumerable args) => command.RemoveArgs(args); + + /// + /// Appends an environment variable. + /// + /// The command to which an environment variable will be added. + /// Environment variable to add. + /// Returns a new command with the corresponding changes. + public static DotNetRestore operator +(DotNetRestore command, (string name, string value) var) => command.AddVars(var); + + /// + /// Removes environment variable by its name and value. + /// + /// The command to which an environment variable will be removed. + /// Environment variable to remove. + /// Returns a new command with the corresponding changes. + public static DotNetRestore operator -(DotNetRestore command, (string name, string value) var) => command.RemoveVars(var); + + /// + /// Appends environment variables. + /// + /// The command to which environment variables will be added. + /// Environment variables to add. + /// Returns a new command with the corresponding changes. + public static DotNetRestore operator +(DotNetRestore command, IEnumerable<(string name, string value)> vars) => command.AddVars(vars); + + /// + /// Removes environment variables by their name and value. + /// + /// The command to which environment variables will be removed. + /// environment variables to remove. + /// Returns a new command with the corresponding changes. + public static DotNetRestore operator -(DotNetRestore command, IEnumerable<(string name, string value)> vars) => command.RemoveVars(vars); +} + +[ExcludeFromCodeCoverage] +public partial record DotNetRun: ICommandLine +{ + /// + /// Appends an argument. + /// + /// The command to which an argument will be added. + /// Argument to add. + /// Returns a new command with the corresponding changes. + public static DotNetRun operator +(DotNetRun command, string arg) => command.AddArgs(arg); + + /// + /// Removes an argument by its name. + /// + /// The command to which an argument will be removed. + /// Argument to remove. + /// Returns a new command with the corresponding changes. + public static DotNetRun operator -(DotNetRun command, string arg) => command.RemoveArgs(arg); + + /// + /// Appends arguments. + /// + /// The command to which arguments will be added. + /// Arguments to add. + /// Returns a new command with the corresponding changes. + public static DotNetRun operator +(DotNetRun command, IEnumerable args) => command.AddArgs(args); + + /// + /// Removes arguments by their name. + /// + /// The command to which arguments will be removed. + /// Arguments to remove. + /// Returns a new command with the corresponding changes. + public static DotNetRun operator -(DotNetRun command, IEnumerable args) => command.RemoveArgs(args); + + /// + /// Appends an environment variable. + /// + /// The command to which an environment variable will be added. + /// Environment variable to add. + /// Returns a new command with the corresponding changes. + public static DotNetRun operator +(DotNetRun command, (string name, string value) var) => command.AddVars(var); + + /// + /// Removes environment variable by its name and value. + /// + /// The command to which an environment variable will be removed. + /// Environment variable to remove. + /// Returns a new command with the corresponding changes. + public static DotNetRun operator -(DotNetRun command, (string name, string value) var) => command.RemoveVars(var); + + /// + /// Appends environment variables. + /// + /// The command to which environment variables will be added. + /// Environment variables to add. + /// Returns a new command with the corresponding changes. + public static DotNetRun operator +(DotNetRun command, IEnumerable<(string name, string value)> vars) => command.AddVars(vars); + + /// + /// Removes environment variables by their name and value. + /// + /// The command to which environment variables will be removed. + /// environment variables to remove. + /// Returns a new command with the corresponding changes. + public static DotNetRun operator -(DotNetRun command, IEnumerable<(string name, string value)> vars) => command.RemoveVars(vars); +} + +[ExcludeFromCodeCoverage] +public partial record DotNetSdkCheck: ICommandLine +{ + /// + /// Appends an argument. + /// + /// The command to which an argument will be added. + /// Argument to add. + /// Returns a new command with the corresponding changes. + public static DotNetSdkCheck operator +(DotNetSdkCheck command, string arg) => command.AddArgs(arg); + + /// + /// Removes an argument by its name. + /// + /// The command to which an argument will be removed. + /// Argument to remove. + /// Returns a new command with the corresponding changes. + public static DotNetSdkCheck operator -(DotNetSdkCheck command, string arg) => command.RemoveArgs(arg); + + /// + /// Appends arguments. + /// + /// The command to which arguments will be added. + /// Arguments to add. + /// Returns a new command with the corresponding changes. + public static DotNetSdkCheck operator +(DotNetSdkCheck command, IEnumerable args) => command.AddArgs(args); + + /// + /// Removes arguments by their name. + /// + /// The command to which arguments will be removed. + /// Arguments to remove. + /// Returns a new command with the corresponding changes. + public static DotNetSdkCheck operator -(DotNetSdkCheck command, IEnumerable args) => command.RemoveArgs(args); + + /// + /// Appends an environment variable. + /// + /// The command to which an environment variable will be added. + /// Environment variable to add. + /// Returns a new command with the corresponding changes. + public static DotNetSdkCheck operator +(DotNetSdkCheck command, (string name, string value) var) => command.AddVars(var); + + /// + /// Removes environment variable by its name and value. + /// + /// The command to which an environment variable will be removed. + /// Environment variable to remove. + /// Returns a new command with the corresponding changes. + public static DotNetSdkCheck operator -(DotNetSdkCheck command, (string name, string value) var) => command.RemoveVars(var); + + /// + /// Appends environment variables. + /// + /// The command to which environment variables will be added. + /// Environment variables to add. + /// Returns a new command with the corresponding changes. + public static DotNetSdkCheck operator +(DotNetSdkCheck command, IEnumerable<(string name, string value)> vars) => command.AddVars(vars); + + /// + /// Removes environment variables by their name and value. + /// + /// The command to which environment variables will be removed. + /// environment variables to remove. + /// Returns a new command with the corresponding changes. + public static DotNetSdkCheck operator -(DotNetSdkCheck command, IEnumerable<(string name, string value)> vars) => command.RemoveVars(vars); +} + +[ExcludeFromCodeCoverage] +public partial record DotNetSlnList: ICommandLine +{ + /// + /// Appends an argument. + /// + /// The command to which an argument will be added. + /// Argument to add. + /// Returns a new command with the corresponding changes. + public static DotNetSlnList operator +(DotNetSlnList command, string arg) => command.AddArgs(arg); + + /// + /// Removes an argument by its name. + /// + /// The command to which an argument will be removed. + /// Argument to remove. + /// Returns a new command with the corresponding changes. + public static DotNetSlnList operator -(DotNetSlnList command, string arg) => command.RemoveArgs(arg); + + /// + /// Appends arguments. + /// + /// The command to which arguments will be added. + /// Arguments to add. + /// Returns a new command with the corresponding changes. + public static DotNetSlnList operator +(DotNetSlnList command, IEnumerable args) => command.AddArgs(args); + + /// + /// Removes arguments by their name. + /// + /// The command to which arguments will be removed. + /// Arguments to remove. + /// Returns a new command with the corresponding changes. + public static DotNetSlnList operator -(DotNetSlnList command, IEnumerable args) => command.RemoveArgs(args); + + /// + /// Appends an environment variable. + /// + /// The command to which an environment variable will be added. + /// Environment variable to add. + /// Returns a new command with the corresponding changes. + public static DotNetSlnList operator +(DotNetSlnList command, (string name, string value) var) => command.AddVars(var); + + /// + /// Removes environment variable by its name and value. + /// + /// The command to which an environment variable will be removed. + /// Environment variable to remove. + /// Returns a new command with the corresponding changes. + public static DotNetSlnList operator -(DotNetSlnList command, (string name, string value) var) => command.RemoveVars(var); + + /// + /// Appends environment variables. + /// + /// The command to which environment variables will be added. + /// Environment variables to add. + /// Returns a new command with the corresponding changes. + public static DotNetSlnList operator +(DotNetSlnList command, IEnumerable<(string name, string value)> vars) => command.AddVars(vars); + + /// + /// Removes environment variables by their name and value. + /// + /// The command to which environment variables will be removed. + /// environment variables to remove. + /// Returns a new command with the corresponding changes. + public static DotNetSlnList operator -(DotNetSlnList command, IEnumerable<(string name, string value)> vars) => command.RemoveVars(vars); +} + +[ExcludeFromCodeCoverage] +public partial record DotNetSlnAdd: ICommandLine +{ + /// + /// Appends an argument. + /// + /// The command to which an argument will be added. + /// Argument to add. + /// Returns a new command with the corresponding changes. + public static DotNetSlnAdd operator +(DotNetSlnAdd command, string arg) => command.AddArgs(arg); + + /// + /// Removes an argument by its name. + /// + /// The command to which an argument will be removed. + /// Argument to remove. + /// Returns a new command with the corresponding changes. + public static DotNetSlnAdd operator -(DotNetSlnAdd command, string arg) => command.RemoveArgs(arg); + + /// + /// Appends arguments. + /// + /// The command to which arguments will be added. + /// Arguments to add. + /// Returns a new command with the corresponding changes. + public static DotNetSlnAdd operator +(DotNetSlnAdd command, IEnumerable args) => command.AddArgs(args); + + /// + /// Removes arguments by their name. + /// + /// The command to which arguments will be removed. + /// Arguments to remove. + /// Returns a new command with the corresponding changes. + public static DotNetSlnAdd operator -(DotNetSlnAdd command, IEnumerable args) => command.RemoveArgs(args); + + /// + /// Appends an environment variable. + /// + /// The command to which an environment variable will be added. + /// Environment variable to add. + /// Returns a new command with the corresponding changes. + public static DotNetSlnAdd operator +(DotNetSlnAdd command, (string name, string value) var) => command.AddVars(var); + + /// + /// Removes environment variable by its name and value. + /// + /// The command to which an environment variable will be removed. + /// Environment variable to remove. + /// Returns a new command with the corresponding changes. + public static DotNetSlnAdd operator -(DotNetSlnAdd command, (string name, string value) var) => command.RemoveVars(var); + + /// + /// Appends environment variables. + /// + /// The command to which environment variables will be added. + /// Environment variables to add. + /// Returns a new command with the corresponding changes. + public static DotNetSlnAdd operator +(DotNetSlnAdd command, IEnumerable<(string name, string value)> vars) => command.AddVars(vars); + + /// + /// Removes environment variables by their name and value. + /// + /// The command to which environment variables will be removed. + /// environment variables to remove. + /// Returns a new command with the corresponding changes. + public static DotNetSlnAdd operator -(DotNetSlnAdd command, IEnumerable<(string name, string value)> vars) => command.RemoveVars(vars); +} + +[ExcludeFromCodeCoverage] +public partial record DotNetSlnRemove: ICommandLine +{ + /// + /// Appends an argument. + /// + /// The command to which an argument will be added. + /// Argument to add. + /// Returns a new command with the corresponding changes. + public static DotNetSlnRemove operator +(DotNetSlnRemove command, string arg) => command.AddArgs(arg); + + /// + /// Removes an argument by its name. + /// + /// The command to which an argument will be removed. + /// Argument to remove. + /// Returns a new command with the corresponding changes. + public static DotNetSlnRemove operator -(DotNetSlnRemove command, string arg) => command.RemoveArgs(arg); + + /// + /// Appends arguments. + /// + /// The command to which arguments will be added. + /// Arguments to add. + /// Returns a new command with the corresponding changes. + public static DotNetSlnRemove operator +(DotNetSlnRemove command, IEnumerable args) => command.AddArgs(args); + + /// + /// Removes arguments by their name. + /// + /// The command to which arguments will be removed. + /// Arguments to remove. + /// Returns a new command with the corresponding changes. + public static DotNetSlnRemove operator -(DotNetSlnRemove command, IEnumerable args) => command.RemoveArgs(args); + + /// + /// Appends an environment variable. + /// + /// The command to which an environment variable will be added. + /// Environment variable to add. + /// Returns a new command with the corresponding changes. + public static DotNetSlnRemove operator +(DotNetSlnRemove command, (string name, string value) var) => command.AddVars(var); + + /// + /// Removes environment variable by its name and value. + /// + /// The command to which an environment variable will be removed. + /// Environment variable to remove. + /// Returns a new command with the corresponding changes. + public static DotNetSlnRemove operator -(DotNetSlnRemove command, (string name, string value) var) => command.RemoveVars(var); + + /// + /// Appends environment variables. + /// + /// The command to which environment variables will be added. + /// Environment variables to add. + /// Returns a new command with the corresponding changes. + public static DotNetSlnRemove operator +(DotNetSlnRemove command, IEnumerable<(string name, string value)> vars) => command.AddVars(vars); + + /// + /// Removes environment variables by their name and value. + /// + /// The command to which environment variables will be removed. + /// environment variables to remove. + /// Returns a new command with the corresponding changes. + public static DotNetSlnRemove operator -(DotNetSlnRemove command, IEnumerable<(string name, string value)> vars) => command.RemoveVars(vars); +} + +[ExcludeFromCodeCoverage] +public partial record DotNetStore: ICommandLine +{ + /// + /// Appends an argument. + /// + /// The command to which an argument will be added. + /// Argument to add. + /// Returns a new command with the corresponding changes. + public static DotNetStore operator +(DotNetStore command, string arg) => command.AddArgs(arg); + + /// + /// Removes an argument by its name. + /// + /// The command to which an argument will be removed. + /// Argument to remove. + /// Returns a new command with the corresponding changes. + public static DotNetStore operator -(DotNetStore command, string arg) => command.RemoveArgs(arg); + + /// + /// Appends arguments. + /// + /// The command to which arguments will be added. + /// Arguments to add. + /// Returns a new command with the corresponding changes. + public static DotNetStore operator +(DotNetStore command, IEnumerable args) => command.AddArgs(args); + + /// + /// Removes arguments by their name. + /// + /// The command to which arguments will be removed. + /// Arguments to remove. + /// Returns a new command with the corresponding changes. + public static DotNetStore operator -(DotNetStore command, IEnumerable args) => command.RemoveArgs(args); + + /// + /// Appends an environment variable. + /// + /// The command to which an environment variable will be added. + /// Environment variable to add. + /// Returns a new command with the corresponding changes. + public static DotNetStore operator +(DotNetStore command, (string name, string value) var) => command.AddVars(var); + + /// + /// Removes environment variable by its name and value. + /// + /// The command to which an environment variable will be removed. + /// Environment variable to remove. + /// Returns a new command with the corresponding changes. + public static DotNetStore operator -(DotNetStore command, (string name, string value) var) => command.RemoveVars(var); + + /// + /// Appends environment variables. + /// + /// The command to which environment variables will be added. + /// Environment variables to add. + /// Returns a new command with the corresponding changes. + public static DotNetStore operator +(DotNetStore command, IEnumerable<(string name, string value)> vars) => command.AddVars(vars); + + /// + /// Removes environment variables by their name and value. + /// + /// The command to which environment variables will be removed. + /// environment variables to remove. + /// Returns a new command with the corresponding changes. + public static DotNetStore operator -(DotNetStore command, IEnumerable<(string name, string value)> vars) => command.RemoveVars(vars); +} + +[ExcludeFromCodeCoverage] +public partial record DotNetTest: ICommandLine +{ + /// + /// Appends an argument. + /// + /// The command to which an argument will be added. + /// Argument to add. + /// Returns a new command with the corresponding changes. + public static DotNetTest operator +(DotNetTest command, string arg) => command.AddArgs(arg); + + /// + /// Removes an argument by its name. + /// + /// The command to which an argument will be removed. + /// Argument to remove. + /// Returns a new command with the corresponding changes. + public static DotNetTest operator -(DotNetTest command, string arg) => command.RemoveArgs(arg); + + /// + /// Appends arguments. + /// + /// The command to which arguments will be added. + /// Arguments to add. + /// Returns a new command with the corresponding changes. + public static DotNetTest operator +(DotNetTest command, IEnumerable args) => command.AddArgs(args); + + /// + /// Removes arguments by their name. + /// + /// The command to which arguments will be removed. + /// Arguments to remove. + /// Returns a new command with the corresponding changes. + public static DotNetTest operator -(DotNetTest command, IEnumerable args) => command.RemoveArgs(args); + + /// + /// Appends an environment variable. + /// + /// The command to which an environment variable will be added. + /// Environment variable to add. + /// Returns a new command with the corresponding changes. + public static DotNetTest operator +(DotNetTest command, (string name, string value) var) => command.AddVars(var); + + /// + /// Removes environment variable by its name and value. + /// + /// The command to which an environment variable will be removed. + /// Environment variable to remove. + /// Returns a new command with the corresponding changes. + public static DotNetTest operator -(DotNetTest command, (string name, string value) var) => command.RemoveVars(var); + + /// + /// Appends environment variables. + /// + /// The command to which environment variables will be added. + /// Environment variables to add. + /// Returns a new command with the corresponding changes. + public static DotNetTest operator +(DotNetTest command, IEnumerable<(string name, string value)> vars) => command.AddVars(vars); + + /// + /// Removes environment variables by their name and value. + /// + /// The command to which environment variables will be removed. + /// environment variables to remove. + /// Returns a new command with the corresponding changes. + public static DotNetTest operator -(DotNetTest command, IEnumerable<(string name, string value)> vars) => command.RemoveVars(vars); +} + +[ExcludeFromCodeCoverage] +public partial record DotNetToolInstall: ICommandLine +{ + /// + /// Appends an argument. + /// + /// The command to which an argument will be added. + /// Argument to add. + /// Returns a new command with the corresponding changes. + public static DotNetToolInstall operator +(DotNetToolInstall command, string arg) => command.AddArgs(arg); + + /// + /// Removes an argument by its name. + /// + /// The command to which an argument will be removed. + /// Argument to remove. + /// Returns a new command with the corresponding changes. + public static DotNetToolInstall operator -(DotNetToolInstall command, string arg) => command.RemoveArgs(arg); + + /// + /// Appends arguments. + /// + /// The command to which arguments will be added. + /// Arguments to add. + /// Returns a new command with the corresponding changes. + public static DotNetToolInstall operator +(DotNetToolInstall command, IEnumerable args) => command.AddArgs(args); + + /// + /// Removes arguments by their name. + /// + /// The command to which arguments will be removed. + /// Arguments to remove. + /// Returns a new command with the corresponding changes. + public static DotNetToolInstall operator -(DotNetToolInstall command, IEnumerable args) => command.RemoveArgs(args); + + /// + /// Appends an environment variable. + /// + /// The command to which an environment variable will be added. + /// Environment variable to add. + /// Returns a new command with the corresponding changes. + public static DotNetToolInstall operator +(DotNetToolInstall command, (string name, string value) var) => command.AddVars(var); + + /// + /// Removes environment variable by its name and value. + /// + /// The command to which an environment variable will be removed. + /// Environment variable to remove. + /// Returns a new command with the corresponding changes. + public static DotNetToolInstall operator -(DotNetToolInstall command, (string name, string value) var) => command.RemoveVars(var); + + /// + /// Appends environment variables. + /// + /// The command to which environment variables will be added. + /// Environment variables to add. + /// Returns a new command with the corresponding changes. + public static DotNetToolInstall operator +(DotNetToolInstall command, IEnumerable<(string name, string value)> vars) => command.AddVars(vars); + + /// + /// Removes environment variables by their name and value. + /// + /// The command to which environment variables will be removed. + /// environment variables to remove. + /// Returns a new command with the corresponding changes. + public static DotNetToolInstall operator -(DotNetToolInstall command, IEnumerable<(string name, string value)> vars) => command.RemoveVars(vars); +} + +[ExcludeFromCodeCoverage] +public partial record DotNetToolList: ICommandLine +{ + /// + /// Appends an argument. + /// + /// The command to which an argument will be added. + /// Argument to add. + /// Returns a new command with the corresponding changes. + public static DotNetToolList operator +(DotNetToolList command, string arg) => command.AddArgs(arg); + + /// + /// Removes an argument by its name. + /// + /// The command to which an argument will be removed. + /// Argument to remove. + /// Returns a new command with the corresponding changes. + public static DotNetToolList operator -(DotNetToolList command, string arg) => command.RemoveArgs(arg); + + /// + /// Appends arguments. + /// + /// The command to which arguments will be added. + /// Arguments to add. + /// Returns a new command with the corresponding changes. + public static DotNetToolList operator +(DotNetToolList command, IEnumerable args) => command.AddArgs(args); + + /// + /// Removes arguments by their name. + /// + /// The command to which arguments will be removed. + /// Arguments to remove. + /// Returns a new command with the corresponding changes. + public static DotNetToolList operator -(DotNetToolList command, IEnumerable args) => command.RemoveArgs(args); + + /// + /// Appends an environment variable. + /// + /// The command to which an environment variable will be added. + /// Environment variable to add. + /// Returns a new command with the corresponding changes. + public static DotNetToolList operator +(DotNetToolList command, (string name, string value) var) => command.AddVars(var); + + /// + /// Removes environment variable by its name and value. + /// + /// The command to which an environment variable will be removed. + /// Environment variable to remove. + /// Returns a new command with the corresponding changes. + public static DotNetToolList operator -(DotNetToolList command, (string name, string value) var) => command.RemoveVars(var); + + /// + /// Appends environment variables. + /// + /// The command to which environment variables will be added. + /// Environment variables to add. + /// Returns a new command with the corresponding changes. + public static DotNetToolList operator +(DotNetToolList command, IEnumerable<(string name, string value)> vars) => command.AddVars(vars); + + /// + /// Removes environment variables by their name and value. + /// + /// The command to which environment variables will be removed. + /// environment variables to remove. + /// Returns a new command with the corresponding changes. + public static DotNetToolList operator -(DotNetToolList command, IEnumerable<(string name, string value)> vars) => command.RemoveVars(vars); +} + +[ExcludeFromCodeCoverage] +public partial record DotNetToolRestore: ICommandLine +{ + /// + /// Appends an argument. + /// + /// The command to which an argument will be added. + /// Argument to add. + /// Returns a new command with the corresponding changes. + public static DotNetToolRestore operator +(DotNetToolRestore command, string arg) => command.AddArgs(arg); + + /// + /// Removes an argument by its name. + /// + /// The command to which an argument will be removed. + /// Argument to remove. + /// Returns a new command with the corresponding changes. + public static DotNetToolRestore operator -(DotNetToolRestore command, string arg) => command.RemoveArgs(arg); + + /// + /// Appends arguments. + /// + /// The command to which arguments will be added. + /// Arguments to add. + /// Returns a new command with the corresponding changes. + public static DotNetToolRestore operator +(DotNetToolRestore command, IEnumerable args) => command.AddArgs(args); + + /// + /// Removes arguments by their name. + /// + /// The command to which arguments will be removed. + /// Arguments to remove. + /// Returns a new command with the corresponding changes. + public static DotNetToolRestore operator -(DotNetToolRestore command, IEnumerable args) => command.RemoveArgs(args); + + /// + /// Appends an environment variable. + /// + /// The command to which an environment variable will be added. + /// Environment variable to add. + /// Returns a new command with the corresponding changes. + public static DotNetToolRestore operator +(DotNetToolRestore command, (string name, string value) var) => command.AddVars(var); + + /// + /// Removes environment variable by its name and value. + /// + /// The command to which an environment variable will be removed. + /// Environment variable to remove. + /// Returns a new command with the corresponding changes. + public static DotNetToolRestore operator -(DotNetToolRestore command, (string name, string value) var) => command.RemoveVars(var); + + /// + /// Appends environment variables. + /// + /// The command to which environment variables will be added. + /// Environment variables to add. + /// Returns a new command with the corresponding changes. + public static DotNetToolRestore operator +(DotNetToolRestore command, IEnumerable<(string name, string value)> vars) => command.AddVars(vars); + + /// + /// Removes environment variables by their name and value. + /// + /// The command to which environment variables will be removed. + /// environment variables to remove. + /// Returns a new command with the corresponding changes. + public static DotNetToolRestore operator -(DotNetToolRestore command, IEnumerable<(string name, string value)> vars) => command.RemoveVars(vars); +} + +[ExcludeFromCodeCoverage] +public partial record DotNetToolRun: ICommandLine +{ + /// + /// Appends an argument. + /// + /// The command to which an argument will be added. + /// Argument to add. + /// Returns a new command with the corresponding changes. + public static DotNetToolRun operator +(DotNetToolRun command, string arg) => command.AddArgs(arg); + + /// + /// Removes an argument by its name. + /// + /// The command to which an argument will be removed. + /// Argument to remove. + /// Returns a new command with the corresponding changes. + public static DotNetToolRun operator -(DotNetToolRun command, string arg) => command.RemoveArgs(arg); + + /// + /// Appends arguments. + /// + /// The command to which arguments will be added. + /// Arguments to add. + /// Returns a new command with the corresponding changes. + public static DotNetToolRun operator +(DotNetToolRun command, IEnumerable args) => command.AddArgs(args); + + /// + /// Removes arguments by their name. + /// + /// The command to which arguments will be removed. + /// Arguments to remove. + /// Returns a new command with the corresponding changes. + public static DotNetToolRun operator -(DotNetToolRun command, IEnumerable args) => command.RemoveArgs(args); + + /// + /// Appends an environment variable. + /// + /// The command to which an environment variable will be added. + /// Environment variable to add. + /// Returns a new command with the corresponding changes. + public static DotNetToolRun operator +(DotNetToolRun command, (string name, string value) var) => command.AddVars(var); + + /// + /// Removes environment variable by its name and value. + /// + /// The command to which an environment variable will be removed. + /// Environment variable to remove. + /// Returns a new command with the corresponding changes. + public static DotNetToolRun operator -(DotNetToolRun command, (string name, string value) var) => command.RemoveVars(var); + + /// + /// Appends environment variables. + /// + /// The command to which environment variables will be added. + /// Environment variables to add. + /// Returns a new command with the corresponding changes. + public static DotNetToolRun operator +(DotNetToolRun command, IEnumerable<(string name, string value)> vars) => command.AddVars(vars); + + /// + /// Removes environment variables by their name and value. + /// + /// The command to which environment variables will be removed. + /// environment variables to remove. + /// Returns a new command with the corresponding changes. + public static DotNetToolRun operator -(DotNetToolRun command, IEnumerable<(string name, string value)> vars) => command.RemoveVars(vars); +} + +[ExcludeFromCodeCoverage] +public partial record DotNetToolSearch: ICommandLine +{ + /// + /// Appends an argument. + /// + /// The command to which an argument will be added. + /// Argument to add. + /// Returns a new command with the corresponding changes. + public static DotNetToolSearch operator +(DotNetToolSearch command, string arg) => command.AddArgs(arg); + + /// + /// Removes an argument by its name. + /// + /// The command to which an argument will be removed. + /// Argument to remove. + /// Returns a new command with the corresponding changes. + public static DotNetToolSearch operator -(DotNetToolSearch command, string arg) => command.RemoveArgs(arg); + + /// + /// Appends arguments. + /// + /// The command to which arguments will be added. + /// Arguments to add. + /// Returns a new command with the corresponding changes. + public static DotNetToolSearch operator +(DotNetToolSearch command, IEnumerable args) => command.AddArgs(args); + + /// + /// Removes arguments by their name. + /// + /// The command to which arguments will be removed. + /// Arguments to remove. + /// Returns a new command with the corresponding changes. + public static DotNetToolSearch operator -(DotNetToolSearch command, IEnumerable args) => command.RemoveArgs(args); + + /// + /// Appends an environment variable. + /// + /// The command to which an environment variable will be added. + /// Environment variable to add. + /// Returns a new command with the corresponding changes. + public static DotNetToolSearch operator +(DotNetToolSearch command, (string name, string value) var) => command.AddVars(var); + + /// + /// Removes environment variable by its name and value. + /// + /// The command to which an environment variable will be removed. + /// Environment variable to remove. + /// Returns a new command with the corresponding changes. + public static DotNetToolSearch operator -(DotNetToolSearch command, (string name, string value) var) => command.RemoveVars(var); + + /// + /// Appends environment variables. + /// + /// The command to which environment variables will be added. + /// Environment variables to add. + /// Returns a new command with the corresponding changes. + public static DotNetToolSearch operator +(DotNetToolSearch command, IEnumerable<(string name, string value)> vars) => command.AddVars(vars); + + /// + /// Removes environment variables by their name and value. + /// + /// The command to which environment variables will be removed. + /// environment variables to remove. + /// Returns a new command with the corresponding changes. + public static DotNetToolSearch operator -(DotNetToolSearch command, IEnumerable<(string name, string value)> vars) => command.RemoveVars(vars); +} + +[ExcludeFromCodeCoverage] +public partial record DotNetToolUninstall: ICommandLine +{ + /// + /// Appends an argument. + /// + /// The command to which an argument will be added. + /// Argument to add. + /// Returns a new command with the corresponding changes. + public static DotNetToolUninstall operator +(DotNetToolUninstall command, string arg) => command.AddArgs(arg); + + /// + /// Removes an argument by its name. + /// + /// The command to which an argument will be removed. + /// Argument to remove. + /// Returns a new command with the corresponding changes. + public static DotNetToolUninstall operator -(DotNetToolUninstall command, string arg) => command.RemoveArgs(arg); + + /// + /// Appends arguments. + /// + /// The command to which arguments will be added. + /// Arguments to add. + /// Returns a new command with the corresponding changes. + public static DotNetToolUninstall operator +(DotNetToolUninstall command, IEnumerable args) => command.AddArgs(args); + + /// + /// Removes arguments by their name. + /// + /// The command to which arguments will be removed. + /// Arguments to remove. + /// Returns a new command with the corresponding changes. + public static DotNetToolUninstall operator -(DotNetToolUninstall command, IEnumerable args) => command.RemoveArgs(args); + + /// + /// Appends an environment variable. + /// + /// The command to which an environment variable will be added. + /// Environment variable to add. + /// Returns a new command with the corresponding changes. + public static DotNetToolUninstall operator +(DotNetToolUninstall command, (string name, string value) var) => command.AddVars(var); + + /// + /// Removes environment variable by its name and value. + /// + /// The command to which an environment variable will be removed. + /// Environment variable to remove. + /// Returns a new command with the corresponding changes. + public static DotNetToolUninstall operator -(DotNetToolUninstall command, (string name, string value) var) => command.RemoveVars(var); + + /// + /// Appends environment variables. + /// + /// The command to which environment variables will be added. + /// Environment variables to add. + /// Returns a new command with the corresponding changes. + public static DotNetToolUninstall operator +(DotNetToolUninstall command, IEnumerable<(string name, string value)> vars) => command.AddVars(vars); + + /// + /// Removes environment variables by their name and value. + /// + /// The command to which environment variables will be removed. + /// environment variables to remove. + /// Returns a new command with the corresponding changes. + public static DotNetToolUninstall operator -(DotNetToolUninstall command, IEnumerable<(string name, string value)> vars) => command.RemoveVars(vars); +} + +[ExcludeFromCodeCoverage] +public partial record DotNetToolUpdate: ICommandLine +{ + /// + /// Appends an argument. + /// + /// The command to which an argument will be added. + /// Argument to add. + /// Returns a new command with the corresponding changes. + public static DotNetToolUpdate operator +(DotNetToolUpdate command, string arg) => command.AddArgs(arg); + + /// + /// Removes an argument by its name. + /// + /// The command to which an argument will be removed. + /// Argument to remove. + /// Returns a new command with the corresponding changes. + public static DotNetToolUpdate operator -(DotNetToolUpdate command, string arg) => command.RemoveArgs(arg); + + /// + /// Appends arguments. + /// + /// The command to which arguments will be added. + /// Arguments to add. + /// Returns a new command with the corresponding changes. + public static DotNetToolUpdate operator +(DotNetToolUpdate command, IEnumerable args) => command.AddArgs(args); + + /// + /// Removes arguments by their name. + /// + /// The command to which arguments will be removed. + /// Arguments to remove. + /// Returns a new command with the corresponding changes. + public static DotNetToolUpdate operator -(DotNetToolUpdate command, IEnumerable args) => command.RemoveArgs(args); + + /// + /// Appends an environment variable. + /// + /// The command to which an environment variable will be added. + /// Environment variable to add. + /// Returns a new command with the corresponding changes. + public static DotNetToolUpdate operator +(DotNetToolUpdate command, (string name, string value) var) => command.AddVars(var); + + /// + /// Removes environment variable by its name and value. + /// + /// The command to which an environment variable will be removed. + /// Environment variable to remove. + /// Returns a new command with the corresponding changes. + public static DotNetToolUpdate operator -(DotNetToolUpdate command, (string name, string value) var) => command.RemoveVars(var); + + /// + /// Appends environment variables. + /// + /// The command to which environment variables will be added. + /// Environment variables to add. + /// Returns a new command with the corresponding changes. + public static DotNetToolUpdate operator +(DotNetToolUpdate command, IEnumerable<(string name, string value)> vars) => command.AddVars(vars); + + /// + /// Removes environment variables by their name and value. + /// + /// The command to which environment variables will be removed. + /// environment variables to remove. + /// Returns a new command with the corresponding changes. + public static DotNetToolUpdate operator -(DotNetToolUpdate command, IEnumerable<(string name, string value)> vars) => command.RemoveVars(vars); +} + +[ExcludeFromCodeCoverage] +public partial record VSTest: ICommandLine +{ + /// + /// Appends an argument. + /// + /// The command to which an argument will be added. + /// Argument to add. + /// Returns a new command with the corresponding changes. + public static VSTest operator +(VSTest command, string arg) => command.AddArgs(arg); + + /// + /// Removes an argument by its name. + /// + /// The command to which an argument will be removed. + /// Argument to remove. + /// Returns a new command with the corresponding changes. + public static VSTest operator -(VSTest command, string arg) => command.RemoveArgs(arg); + + /// + /// Appends arguments. + /// + /// The command to which arguments will be added. + /// Arguments to add. + /// Returns a new command with the corresponding changes. + public static VSTest operator +(VSTest command, IEnumerable args) => command.AddArgs(args); + + /// + /// Removes arguments by their name. + /// + /// The command to which arguments will be removed. + /// Arguments to remove. + /// Returns a new command with the corresponding changes. + public static VSTest operator -(VSTest command, IEnumerable args) => command.RemoveArgs(args); + + /// + /// Appends an environment variable. + /// + /// The command to which an environment variable will be added. + /// Environment variable to add. + /// Returns a new command with the corresponding changes. + public static VSTest operator +(VSTest command, (string name, string value) var) => command.AddVars(var); + + /// + /// Removes environment variable by its name and value. + /// + /// The command to which an environment variable will be removed. + /// Environment variable to remove. + /// Returns a new command with the corresponding changes. + public static VSTest operator -(VSTest command, (string name, string value) var) => command.RemoveVars(var); + + /// + /// Appends environment variables. + /// + /// The command to which environment variables will be added. + /// Environment variables to add. + /// Returns a new command with the corresponding changes. + public static VSTest operator +(VSTest command, IEnumerable<(string name, string value)> vars) => command.AddVars(vars); + + /// + /// Removes environment variables by their name and value. + /// + /// The command to which environment variables will be removed. + /// environment variables to remove. + /// Returns a new command with the corresponding changes. + public static VSTest operator -(VSTest command, IEnumerable<(string name, string value)> vars) => command.RemoveVars(vars); +} + +[ExcludeFromCodeCoverage] +public partial record DotNetWorkload: ICommandLine +{ + /// + /// Appends an argument. + /// + /// The command to which an argument will be added. + /// Argument to add. + /// Returns a new command with the corresponding changes. + public static DotNetWorkload operator +(DotNetWorkload command, string arg) => command.AddArgs(arg); + + /// + /// Removes an argument by its name. + /// + /// The command to which an argument will be removed. + /// Argument to remove. + /// Returns a new command with the corresponding changes. + public static DotNetWorkload operator -(DotNetWorkload command, string arg) => command.RemoveArgs(arg); + + /// + /// Appends arguments. + /// + /// The command to which arguments will be added. + /// Arguments to add. + /// Returns a new command with the corresponding changes. + public static DotNetWorkload operator +(DotNetWorkload command, IEnumerable args) => command.AddArgs(args); + + /// + /// Removes arguments by their name. + /// + /// The command to which arguments will be removed. + /// Arguments to remove. + /// Returns a new command with the corresponding changes. + public static DotNetWorkload operator -(DotNetWorkload command, IEnumerable args) => command.RemoveArgs(args); + + /// + /// Appends an environment variable. + /// + /// The command to which an environment variable will be added. + /// Environment variable to add. + /// Returns a new command with the corresponding changes. + public static DotNetWorkload operator +(DotNetWorkload command, (string name, string value) var) => command.AddVars(var); + + /// + /// Removes environment variable by its name and value. + /// + /// The command to which an environment variable will be removed. + /// Environment variable to remove. + /// Returns a new command with the corresponding changes. + public static DotNetWorkload operator -(DotNetWorkload command, (string name, string value) var) => command.RemoveVars(var); + + /// + /// Appends environment variables. + /// + /// The command to which environment variables will be added. + /// Environment variables to add. + /// Returns a new command with the corresponding changes. + public static DotNetWorkload operator +(DotNetWorkload command, IEnumerable<(string name, string value)> vars) => command.AddVars(vars); + + /// + /// Removes environment variables by their name and value. + /// + /// The command to which environment variables will be removed. + /// environment variables to remove. + /// Returns a new command with the corresponding changes. + public static DotNetWorkload operator -(DotNetWorkload command, IEnumerable<(string name, string value)> vars) => command.RemoveVars(vars); +} + +[ExcludeFromCodeCoverage] +public partial record DotNetWorkloadConfig: ICommandLine +{ + /// + /// Appends an argument. + /// + /// The command to which an argument will be added. + /// Argument to add. + /// Returns a new command with the corresponding changes. + public static DotNetWorkloadConfig operator +(DotNetWorkloadConfig command, string arg) => command.AddArgs(arg); + + /// + /// Removes an argument by its name. + /// + /// The command to which an argument will be removed. + /// Argument to remove. + /// Returns a new command with the corresponding changes. + public static DotNetWorkloadConfig operator -(DotNetWorkloadConfig command, string arg) => command.RemoveArgs(arg); + + /// + /// Appends arguments. + /// + /// The command to which arguments will be added. + /// Arguments to add. + /// Returns a new command with the corresponding changes. + public static DotNetWorkloadConfig operator +(DotNetWorkloadConfig command, IEnumerable args) => command.AddArgs(args); + + /// + /// Removes arguments by their name. + /// + /// The command to which arguments will be removed. + /// Arguments to remove. + /// Returns a new command with the corresponding changes. + public static DotNetWorkloadConfig operator -(DotNetWorkloadConfig command, IEnumerable args) => command.RemoveArgs(args); + + /// + /// Appends an environment variable. + /// + /// The command to which an environment variable will be added. + /// Environment variable to add. + /// Returns a new command with the corresponding changes. + public static DotNetWorkloadConfig operator +(DotNetWorkloadConfig command, (string name, string value) var) => command.AddVars(var); + + /// + /// Removes environment variable by its name and value. + /// + /// The command to which an environment variable will be removed. + /// Environment variable to remove. + /// Returns a new command with the corresponding changes. + public static DotNetWorkloadConfig operator -(DotNetWorkloadConfig command, (string name, string value) var) => command.RemoveVars(var); + + /// + /// Appends environment variables. + /// + /// The command to which environment variables will be added. + /// Environment variables to add. + /// Returns a new command with the corresponding changes. + public static DotNetWorkloadConfig operator +(DotNetWorkloadConfig command, IEnumerable<(string name, string value)> vars) => command.AddVars(vars); + + /// + /// Removes environment variables by their name and value. + /// + /// The command to which environment variables will be removed. + /// environment variables to remove. + /// Returns a new command with the corresponding changes. + public static DotNetWorkloadConfig operator -(DotNetWorkloadConfig command, IEnumerable<(string name, string value)> vars) => command.RemoveVars(vars); +} + +[ExcludeFromCodeCoverage] +public partial record DotNetWorkloadInstall: ICommandLine +{ + /// + /// Appends an argument. + /// + /// The command to which an argument will be added. + /// Argument to add. + /// Returns a new command with the corresponding changes. + public static DotNetWorkloadInstall operator +(DotNetWorkloadInstall command, string arg) => command.AddArgs(arg); + + /// + /// Removes an argument by its name. + /// + /// The command to which an argument will be removed. + /// Argument to remove. + /// Returns a new command with the corresponding changes. + public static DotNetWorkloadInstall operator -(DotNetWorkloadInstall command, string arg) => command.RemoveArgs(arg); + + /// + /// Appends arguments. + /// + /// The command to which arguments will be added. + /// Arguments to add. + /// Returns a new command with the corresponding changes. + public static DotNetWorkloadInstall operator +(DotNetWorkloadInstall command, IEnumerable args) => command.AddArgs(args); + + /// + /// Removes arguments by their name. + /// + /// The command to which arguments will be removed. + /// Arguments to remove. + /// Returns a new command with the corresponding changes. + public static DotNetWorkloadInstall operator -(DotNetWorkloadInstall command, IEnumerable args) => command.RemoveArgs(args); + + /// + /// Appends an environment variable. + /// + /// The command to which an environment variable will be added. + /// Environment variable to add. + /// Returns a new command with the corresponding changes. + public static DotNetWorkloadInstall operator +(DotNetWorkloadInstall command, (string name, string value) var) => command.AddVars(var); + + /// + /// Removes environment variable by its name and value. + /// + /// The command to which an environment variable will be removed. + /// Environment variable to remove. + /// Returns a new command with the corresponding changes. + public static DotNetWorkloadInstall operator -(DotNetWorkloadInstall command, (string name, string value) var) => command.RemoveVars(var); + + /// + /// Appends environment variables. + /// + /// The command to which environment variables will be added. + /// Environment variables to add. + /// Returns a new command with the corresponding changes. + public static DotNetWorkloadInstall operator +(DotNetWorkloadInstall command, IEnumerable<(string name, string value)> vars) => command.AddVars(vars); + + /// + /// Removes environment variables by their name and value. + /// + /// The command to which environment variables will be removed. + /// environment variables to remove. + /// Returns a new command with the corresponding changes. + public static DotNetWorkloadInstall operator -(DotNetWorkloadInstall command, IEnumerable<(string name, string value)> vars) => command.RemoveVars(vars); +} + +[ExcludeFromCodeCoverage] +public partial record DotNetWorkloadList: ICommandLine +{ + /// + /// Appends an argument. + /// + /// The command to which an argument will be added. + /// Argument to add. + /// Returns a new command with the corresponding changes. + public static DotNetWorkloadList operator +(DotNetWorkloadList command, string arg) => command.AddArgs(arg); + + /// + /// Removes an argument by its name. + /// + /// The command to which an argument will be removed. + /// Argument to remove. + /// Returns a new command with the corresponding changes. + public static DotNetWorkloadList operator -(DotNetWorkloadList command, string arg) => command.RemoveArgs(arg); + + /// + /// Appends arguments. + /// + /// The command to which arguments will be added. + /// Arguments to add. + /// Returns a new command with the corresponding changes. + public static DotNetWorkloadList operator +(DotNetWorkloadList command, IEnumerable args) => command.AddArgs(args); + + /// + /// Removes arguments by their name. + /// + /// The command to which arguments will be removed. + /// Arguments to remove. + /// Returns a new command with the corresponding changes. + public static DotNetWorkloadList operator -(DotNetWorkloadList command, IEnumerable args) => command.RemoveArgs(args); + + /// + /// Appends an environment variable. + /// + /// The command to which an environment variable will be added. + /// Environment variable to add. + /// Returns a new command with the corresponding changes. + public static DotNetWorkloadList operator +(DotNetWorkloadList command, (string name, string value) var) => command.AddVars(var); + + /// + /// Removes environment variable by its name and value. + /// + /// The command to which an environment variable will be removed. + /// Environment variable to remove. + /// Returns a new command with the corresponding changes. + public static DotNetWorkloadList operator -(DotNetWorkloadList command, (string name, string value) var) => command.RemoveVars(var); + + /// + /// Appends environment variables. + /// + /// The command to which environment variables will be added. + /// Environment variables to add. + /// Returns a new command with the corresponding changes. + public static DotNetWorkloadList operator +(DotNetWorkloadList command, IEnumerable<(string name, string value)> vars) => command.AddVars(vars); + + /// + /// Removes environment variables by their name and value. + /// + /// The command to which environment variables will be removed. + /// environment variables to remove. + /// Returns a new command with the corresponding changes. + public static DotNetWorkloadList operator -(DotNetWorkloadList command, IEnumerable<(string name, string value)> vars) => command.RemoveVars(vars); +} + +[ExcludeFromCodeCoverage] +public partial record DotNetWorkloadRepair: ICommandLine +{ + /// + /// Appends an argument. + /// + /// The command to which an argument will be added. + /// Argument to add. + /// Returns a new command with the corresponding changes. + public static DotNetWorkloadRepair operator +(DotNetWorkloadRepair command, string arg) => command.AddArgs(arg); + + /// + /// Removes an argument by its name. + /// + /// The command to which an argument will be removed. + /// Argument to remove. + /// Returns a new command with the corresponding changes. + public static DotNetWorkloadRepair operator -(DotNetWorkloadRepair command, string arg) => command.RemoveArgs(arg); + + /// + /// Appends arguments. + /// + /// The command to which arguments will be added. + /// Arguments to add. + /// Returns a new command with the corresponding changes. + public static DotNetWorkloadRepair operator +(DotNetWorkloadRepair command, IEnumerable args) => command.AddArgs(args); + + /// + /// Removes arguments by their name. + /// + /// The command to which arguments will be removed. + /// Arguments to remove. + /// Returns a new command with the corresponding changes. + public static DotNetWorkloadRepair operator -(DotNetWorkloadRepair command, IEnumerable args) => command.RemoveArgs(args); + + /// + /// Appends an environment variable. + /// + /// The command to which an environment variable will be added. + /// Environment variable to add. + /// Returns a new command with the corresponding changes. + public static DotNetWorkloadRepair operator +(DotNetWorkloadRepair command, (string name, string value) var) => command.AddVars(var); + + /// + /// Removes environment variable by its name and value. + /// + /// The command to which an environment variable will be removed. + /// Environment variable to remove. + /// Returns a new command with the corresponding changes. + public static DotNetWorkloadRepair operator -(DotNetWorkloadRepair command, (string name, string value) var) => command.RemoveVars(var); + + /// + /// Appends environment variables. + /// + /// The command to which environment variables will be added. + /// Environment variables to add. + /// Returns a new command with the corresponding changes. + public static DotNetWorkloadRepair operator +(DotNetWorkloadRepair command, IEnumerable<(string name, string value)> vars) => command.AddVars(vars); + + /// + /// Removes environment variables by their name and value. + /// + /// The command to which environment variables will be removed. + /// environment variables to remove. + /// Returns a new command with the corresponding changes. + public static DotNetWorkloadRepair operator -(DotNetWorkloadRepair command, IEnumerable<(string name, string value)> vars) => command.RemoveVars(vars); +} + +[ExcludeFromCodeCoverage] +public partial record DotNetWorkloadRestore: ICommandLine +{ + /// + /// Appends an argument. + /// + /// The command to which an argument will be added. + /// Argument to add. + /// Returns a new command with the corresponding changes. + public static DotNetWorkloadRestore operator +(DotNetWorkloadRestore command, string arg) => command.AddArgs(arg); + + /// + /// Removes an argument by its name. + /// + /// The command to which an argument will be removed. + /// Argument to remove. + /// Returns a new command with the corresponding changes. + public static DotNetWorkloadRestore operator -(DotNetWorkloadRestore command, string arg) => command.RemoveArgs(arg); + + /// + /// Appends arguments. + /// + /// The command to which arguments will be added. + /// Arguments to add. + /// Returns a new command with the corresponding changes. + public static DotNetWorkloadRestore operator +(DotNetWorkloadRestore command, IEnumerable args) => command.AddArgs(args); + + /// + /// Removes arguments by their name. + /// + /// The command to which arguments will be removed. + /// Arguments to remove. + /// Returns a new command with the corresponding changes. + public static DotNetWorkloadRestore operator -(DotNetWorkloadRestore command, IEnumerable args) => command.RemoveArgs(args); + + /// + /// Appends an environment variable. + /// + /// The command to which an environment variable will be added. + /// Environment variable to add. + /// Returns a new command with the corresponding changes. + public static DotNetWorkloadRestore operator +(DotNetWorkloadRestore command, (string name, string value) var) => command.AddVars(var); + + /// + /// Removes environment variable by its name and value. + /// + /// The command to which an environment variable will be removed. + /// Environment variable to remove. + /// Returns a new command with the corresponding changes. + public static DotNetWorkloadRestore operator -(DotNetWorkloadRestore command, (string name, string value) var) => command.RemoveVars(var); + + /// + /// Appends environment variables. + /// + /// The command to which environment variables will be added. + /// Environment variables to add. + /// Returns a new command with the corresponding changes. + public static DotNetWorkloadRestore operator +(DotNetWorkloadRestore command, IEnumerable<(string name, string value)> vars) => command.AddVars(vars); + + /// + /// Removes environment variables by their name and value. + /// + /// The command to which environment variables will be removed. + /// environment variables to remove. + /// Returns a new command with the corresponding changes. + public static DotNetWorkloadRestore operator -(DotNetWorkloadRestore command, IEnumerable<(string name, string value)> vars) => command.RemoveVars(vars); +} + +[ExcludeFromCodeCoverage] +public partial record DotNetWorkloadSearch: ICommandLine +{ + /// + /// Appends an argument. + /// + /// The command to which an argument will be added. + /// Argument to add. + /// Returns a new command with the corresponding changes. + public static DotNetWorkloadSearch operator +(DotNetWorkloadSearch command, string arg) => command.AddArgs(arg); + + /// + /// Removes an argument by its name. + /// + /// The command to which an argument will be removed. + /// Argument to remove. + /// Returns a new command with the corresponding changes. + public static DotNetWorkloadSearch operator -(DotNetWorkloadSearch command, string arg) => command.RemoveArgs(arg); + + /// + /// Appends arguments. + /// + /// The command to which arguments will be added. + /// Arguments to add. + /// Returns a new command with the corresponding changes. + public static DotNetWorkloadSearch operator +(DotNetWorkloadSearch command, IEnumerable args) => command.AddArgs(args); + + /// + /// Removes arguments by their name. + /// + /// The command to which arguments will be removed. + /// Arguments to remove. + /// Returns a new command with the corresponding changes. + public static DotNetWorkloadSearch operator -(DotNetWorkloadSearch command, IEnumerable args) => command.RemoveArgs(args); + + /// + /// Appends an environment variable. + /// + /// The command to which an environment variable will be added. + /// Environment variable to add. + /// Returns a new command with the corresponding changes. + public static DotNetWorkloadSearch operator +(DotNetWorkloadSearch command, (string name, string value) var) => command.AddVars(var); + + /// + /// Removes environment variable by its name and value. + /// + /// The command to which an environment variable will be removed. + /// Environment variable to remove. + /// Returns a new command with the corresponding changes. + public static DotNetWorkloadSearch operator -(DotNetWorkloadSearch command, (string name, string value) var) => command.RemoveVars(var); + + /// + /// Appends environment variables. + /// + /// The command to which environment variables will be added. + /// Environment variables to add. + /// Returns a new command with the corresponding changes. + public static DotNetWorkloadSearch operator +(DotNetWorkloadSearch command, IEnumerable<(string name, string value)> vars) => command.AddVars(vars); + + /// + /// Removes environment variables by their name and value. + /// + /// The command to which environment variables will be removed. + /// environment variables to remove. + /// Returns a new command with the corresponding changes. + public static DotNetWorkloadSearch operator -(DotNetWorkloadSearch command, IEnumerable<(string name, string value)> vars) => command.RemoveVars(vars); +} + +[ExcludeFromCodeCoverage] +public partial record DotNetWorkloadUninstall: ICommandLine +{ + /// + /// Appends an argument. + /// + /// The command to which an argument will be added. + /// Argument to add. + /// Returns a new command with the corresponding changes. + public static DotNetWorkloadUninstall operator +(DotNetWorkloadUninstall command, string arg) => command.AddArgs(arg); + + /// + /// Removes an argument by its name. + /// + /// The command to which an argument will be removed. + /// Argument to remove. + /// Returns a new command with the corresponding changes. + public static DotNetWorkloadUninstall operator -(DotNetWorkloadUninstall command, string arg) => command.RemoveArgs(arg); + + /// + /// Appends arguments. + /// + /// The command to which arguments will be added. + /// Arguments to add. + /// Returns a new command with the corresponding changes. + public static DotNetWorkloadUninstall operator +(DotNetWorkloadUninstall command, IEnumerable args) => command.AddArgs(args); + + /// + /// Removes arguments by their name. + /// + /// The command to which arguments will be removed. + /// Arguments to remove. + /// Returns a new command with the corresponding changes. + public static DotNetWorkloadUninstall operator -(DotNetWorkloadUninstall command, IEnumerable args) => command.RemoveArgs(args); + + /// + /// Appends an environment variable. + /// + /// The command to which an environment variable will be added. + /// Environment variable to add. + /// Returns a new command with the corresponding changes. + public static DotNetWorkloadUninstall operator +(DotNetWorkloadUninstall command, (string name, string value) var) => command.AddVars(var); + + /// + /// Removes environment variable by its name and value. + /// + /// The command to which an environment variable will be removed. + /// Environment variable to remove. + /// Returns a new command with the corresponding changes. + public static DotNetWorkloadUninstall operator -(DotNetWorkloadUninstall command, (string name, string value) var) => command.RemoveVars(var); + + /// + /// Appends environment variables. + /// + /// The command to which environment variables will be added. + /// Environment variables to add. + /// Returns a new command with the corresponding changes. + public static DotNetWorkloadUninstall operator +(DotNetWorkloadUninstall command, IEnumerable<(string name, string value)> vars) => command.AddVars(vars); + + /// + /// Removes environment variables by their name and value. + /// + /// The command to which environment variables will be removed. + /// environment variables to remove. + /// Returns a new command with the corresponding changes. + public static DotNetWorkloadUninstall operator -(DotNetWorkloadUninstall command, IEnumerable<(string name, string value)> vars) => command.RemoveVars(vars); +} + +[ExcludeFromCodeCoverage] +public partial record DotNetWorkloadUpdate: ICommandLine +{ + /// + /// Appends an argument. + /// + /// The command to which an argument will be added. + /// Argument to add. + /// Returns a new command with the corresponding changes. + public static DotNetWorkloadUpdate operator +(DotNetWorkloadUpdate command, string arg) => command.AddArgs(arg); + + /// + /// Removes an argument by its name. + /// + /// The command to which an argument will be removed. + /// Argument to remove. + /// Returns a new command with the corresponding changes. + public static DotNetWorkloadUpdate operator -(DotNetWorkloadUpdate command, string arg) => command.RemoveArgs(arg); + + /// + /// Appends arguments. + /// + /// The command to which arguments will be added. + /// Arguments to add. + /// Returns a new command with the corresponding changes. + public static DotNetWorkloadUpdate operator +(DotNetWorkloadUpdate command, IEnumerable args) => command.AddArgs(args); + + /// + /// Removes arguments by their name. + /// + /// The command to which arguments will be removed. + /// Arguments to remove. + /// Returns a new command with the corresponding changes. + public static DotNetWorkloadUpdate operator -(DotNetWorkloadUpdate command, IEnumerable args) => command.RemoveArgs(args); + + /// + /// Appends an environment variable. + /// + /// The command to which an environment variable will be added. + /// Environment variable to add. + /// Returns a new command with the corresponding changes. + public static DotNetWorkloadUpdate operator +(DotNetWorkloadUpdate command, (string name, string value) var) => command.AddVars(var); + + /// + /// Removes environment variable by its name and value. + /// + /// The command to which an environment variable will be removed. + /// Environment variable to remove. + /// Returns a new command with the corresponding changes. + public static DotNetWorkloadUpdate operator -(DotNetWorkloadUpdate command, (string name, string value) var) => command.RemoveVars(var); + + /// + /// Appends environment variables. + /// + /// The command to which environment variables will be added. + /// Environment variables to add. + /// Returns a new command with the corresponding changes. + public static DotNetWorkloadUpdate operator +(DotNetWorkloadUpdate command, IEnumerable<(string name, string value)> vars) => command.AddVars(vars); + + /// + /// Removes environment variables by their name and value. + /// + /// The command to which environment variables will be removed. + /// environment variables to remove. + /// Returns a new command with the corresponding changes. + public static DotNetWorkloadUpdate operator -(DotNetWorkloadUpdate command, IEnumerable<(string name, string value)> vars) => command.RemoveVars(vars); +} + +[ExcludeFromCodeCoverage] +public partial record DotNetCsi: ICommandLine +{ + /// + /// Appends an argument. + /// + /// The command to which an argument will be added. + /// Argument to add. + /// Returns a new command with the corresponding changes. + public static DotNetCsi operator +(DotNetCsi command, string arg) => command.AddArgs(arg); + + /// + /// Removes an argument by its name. + /// + /// The command to which an argument will be removed. + /// Argument to remove. + /// Returns a new command with the corresponding changes. + public static DotNetCsi operator -(DotNetCsi command, string arg) => command.RemoveArgs(arg); + + /// + /// Appends arguments. + /// + /// The command to which arguments will be added. + /// Arguments to add. + /// Returns a new command with the corresponding changes. + public static DotNetCsi operator +(DotNetCsi command, IEnumerable args) => command.AddArgs(args); + + /// + /// Removes arguments by their name. + /// + /// The command to which arguments will be removed. + /// Arguments to remove. + /// Returns a new command with the corresponding changes. + public static DotNetCsi operator -(DotNetCsi command, IEnumerable args) => command.RemoveArgs(args); + + /// + /// Appends an environment variable. + /// + /// The command to which an environment variable will be added. + /// Environment variable to add. + /// Returns a new command with the corresponding changes. + public static DotNetCsi operator +(DotNetCsi command, (string name, string value) var) => command.AddVars(var); + + /// + /// Removes environment variable by its name and value. + /// + /// The command to which an environment variable will be removed. + /// Environment variable to remove. + /// Returns a new command with the corresponding changes. + public static DotNetCsi operator -(DotNetCsi command, (string name, string value) var) => command.RemoveVars(var); + + /// + /// Appends environment variables. + /// + /// The command to which environment variables will be added. + /// Environment variables to add. + /// Returns a new command with the corresponding changes. + public static DotNetCsi operator +(DotNetCsi command, IEnumerable<(string name, string value)> vars) => command.AddVars(vars); + + /// + /// Removes environment variables by their name and value. + /// + /// The command to which environment variables will be removed. + /// environment variables to remove. + /// Returns a new command with the corresponding changes. + public static DotNetCsi operator -(DotNetCsi command, IEnumerable<(string name, string value)> vars) => command.RemoveVars(vars); } [ExcludeFromCodeCoverage] diff --git a/CSharpInteractive.HostApi/CommandLines.tt b/CSharpInteractive.HostApi/CommandLines.tt index 7e25ef98..bbbf2cbc 100644 --- a/CSharpInteractive.HostApi/CommandLines.tt +++ b/CSharpInteractive.HostApi/CommandLines.tt @@ -1,26 +1,89 @@ // ReSharper disable InconsistentNaming namespace HostApi; - + <# var commandLineTypes = new[] { "CommandLine", // Dotnet + "DotNetCustom", + "DotNet", + "DotNetExec", + "DotNetAddPackage", + "DotNetListPackage", + "DotNetRemovePackage", + "DotNetAddReference", + "DotNetListReference", + "DotNetRemoveReference", "DotNetBuild", "DotNetBuildServerShutdown", "DotNetClean", - "DotNetCustom", + "DotNetDevCertsHttps", + "DotNetFormat", + "DotNetFormatStyle", + "DotNetFormatAnalyzers", + "MSBuild", "DotNetNew", + "DotNetNewList", + "DotNetNewSearch", + "DotNetNewDetails", + "DotNetNewInstall", + "DotNetNewUninstall", + "DotNetNewUpdate", + "DotNetNuGetDelete", + "DotNetNuGetLocalsClear", + "DotNetNuGetLocalsList", "DotNetNuGetPush", + "DotNetNuGetAddSource", + "DotNetNuGetDisableSource", + "DotNetNuGetEnableSource", + "DotNetNuGetListSource", + "DotNetNuGetRemoveSource", + "DotNetNuGetUpdateSource", + "DotNetNuGetVerify", + "DotNetNuGetTrustList", + "DotNetNuGetTrustSync", + "DotNetNuGetTrustRemove", + "DotNetNuGetTrustAuthor", + "DotNetNuGetTrustRepository", + "DotNetNuGetTrustCertificate", + "DotNetNuGetTrustSource", + "DotNetNuGetSign", + "DotNetNuGetWhy", + "DotNetNuGetConfigGet", + "DotNetNuGetConfigSet", + "DotNetNuGetConfigUnset", + "DotNetNuGetConfigPaths", + "DotNetPackageSearch", "DotNetPack", "DotNetPublish", "DotNetRestore", "DotNetRun", + "DotNetSdkCheck", + "DotNetSlnList", + "DotNetSlnAdd", + "DotNetSlnRemove", + "DotNetStore", "DotNetTest", + "DotNetToolInstall", + "DotNetToolList", "DotNetToolRestore", - "MSBuild", + "DotNetToolRun", + "DotNetToolSearch", + "DotNetToolUninstall", + "DotNetToolUpdate", "VSTest", + "DotNetWorkload", + "DotNetWorkloadConfig", + "DotNetWorkloadInstall", + "DotNetWorkloadList", + "DotNetWorkloadRepair", + "DotNetWorkloadRestore", + "DotNetWorkloadSearch", + "DotNetWorkloadUninstall", + "DotNetWorkloadUpdate", + "DotNetCsi", // Docker "DockerCustom", diff --git a/CSharpInteractive.HostApi/DotNetBlameDumpType.cs b/CSharpInteractive.HostApi/DotNetBlameDumpType.cs new file mode 100644 index 00000000..d766b005 --- /dev/null +++ b/CSharpInteractive.HostApi/DotNetBlameDumpType.cs @@ -0,0 +1,22 @@ +namespace HostApi; + +/// +/// The type of dump. +/// +public enum DotNetBlameDumpType +{ + /// + /// None + /// + None, + + /// + /// Full + /// + Full, + + /// + /// Mini + /// + Mini +} \ No newline at end of file diff --git a/CSharpInteractive.HostApi/DotNetBuild.cs b/CSharpInteractive.HostApi/DotNetBuild.cs deleted file mode 100644 index 32d8be79..00000000 --- a/CSharpInteractive.HostApi/DotNetBuild.cs +++ /dev/null @@ -1,115 +0,0 @@ -// ReSharper disable UnusedType.Global -// ReSharper disable UnusedMember.Global -// ReSharper disable InconsistentNaming - -namespace HostApi; - -using Internal.DotNet; - -/// -/// The dotnet build command builds the project and its dependencies into a set of binaries. The binaries include the project's code in Intermediate Language (IL) files with a .dll extension. Depending on the project type and settings, other files may be included. -/// -/// -/// var configuration = Props.Get("configuration", "Release"); -/// -/// -/// new DotNetBuild().WithConfiguration(configuration) -/// .Build().EnsureSuccess(); -/// -/// -/// -/// MSBuild options for setting properties. -/// 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. -/// The URI of the NuGet package source to use during the restore operation. -/// Overrides the tool executable path. -/// Specifies the working directory for the tool to be started. -/// The project or solution file to build. If a project or solution file isn't specified, MSBuild searches the current working directory for a file that has a file extension that ends in either proj or sln and uses that file. -/// 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. -/// Compiles for a specific framework. The framework must be defined in the project file. -/// Defines the build configuration. The default for most projects is Debug, but you can override the build configuration settings in your project. -/// Specifies the target runtime. For a list of Runtime Identifiers (RIDs), see the RID catalog. If you use this option with .NET 6 SDK, use --self-contained or --no-self-contained also. -/// 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. -/// 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. -/// Ignores project-to-project (P2P) references and only builds the specified root project. -/// Doesn't display the startup banner or the copyright message. Available since .NET Core 3.0 SDK. -/// Doesn't execute an implicit restore during build. -/// 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. -/// 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 SDK. -/// 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. -/// 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&apos;t use the -r|--runtime option. Available since .NET 6 Preview 7. -/// 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. -/// Sets the verbosity level of the command. Allowed values are Quiet, Minimal, Normal, Detailed, and Diagnostic. The default is Minimal. For more information, see LoggerVerbosity. -/// Specifies a short name for this operation. -[Target] -public partial record DotNetBuild( - IEnumerable<(string name, string value)> Props, - IEnumerable Args, - IEnumerable<(string name, string value)> Vars, - IEnumerable Sources, - string ExecutablePath = "", - string WorkingDirectory = "", - string Project = "", - string Output = "", - string Framework = "", - string Configuration = "", - string Runtime = "", - string VersionSuffix = "", - bool? NoIncremental = default, - bool? NoDependencies = default, - bool? NoLogo = default, - bool? NoRestore = default, - bool? Force = default, - bool? SelfContained = default, - bool? NoSelfContained = default, - string Arch = "", - string OS = "", - DotNetVerbosity? Verbosity = default, - string ShortName = "") -{ - /// - /// Create a new instance of the command. - /// - /// Specifies the set of command line arguments to use when starting the tool. - public DotNetBuild(params string[] args) - : this([], args, [], []) - { } - - /// - public IStartInfo GetStartInfo(IHost host) - { - if (host == null) throw new ArgumentNullException(nameof(host)); - return host.CreateCommandLine(ExecutablePath) - .WithShortName(ToString()) - .WithArgs("build") - .AddNotEmptyArgs(Project) - .WithWorkingDirectory(WorkingDirectory) - .WithVars(Vars.ToArray()) - .AddMSBuildLoggers(host, Verbosity) - .AddArgs(Sources.Select(i => ("--source", (string?)i)).ToArray()) - .AddArgs( - ("--output", Output), - ("--framework", Framework), - ("--configuration", Configuration), - ("--runtime", Runtime), - ("--version-suffix", VersionSuffix), - ("--verbosity", Verbosity?.ToString().ToLowerInvariant()), - ("--arch", Arch), - ("--os", OS) - ) - .AddBooleanArgs( - ("--no-incremental", NoIncremental), - ("--no-dependencies", NoDependencies), - ("--nologo", NoLogo), - ("--no-restore", NoRestore), - ("--self-contained", SelfContained), - ("--no-self-contained", NoSelfContained), - ("--force", Force) - ) - .AddProps("-p", Props.ToArray()) - .AddArgs(Args.ToArray()); - } - - /// - public override string ToString() => "dotnet build".GetShortName(ShortName, Project); -} \ No newline at end of file diff --git a/CSharpInteractive.HostApi/DotNetBuildServer.cs b/CSharpInteractive.HostApi/DotNetBuildServer.cs index ad376d12..7e9baacb 100644 --- a/CSharpInteractive.HostApi/DotNetBuildServer.cs +++ b/CSharpInteractive.HostApi/DotNetBuildServer.cs @@ -23,4 +23,17 @@ public enum DotNetBuildServer /// Razor build server /// Razor +} + +internal static class DotNetBuildServerExtensions +{ + [SuppressMessage("ReSharper", "UnusedParameter.Global")] + public static string[] ToArgs(this IEnumerable servers, string name, string collectionSeparator) => + servers.Select(server => server switch + { + DotNetBuildServer.MSBuild => "--msbuild", + DotNetBuildServer.VbCsCompiler => "--vbcscompiler", + DotNetBuildServer.Razor => "--razor", + _ => throw new ArgumentOutOfRangeException() + }).ToArray(); } \ No newline at end of file diff --git a/CSharpInteractive.HostApi/DotNetBuildServerShutdown.cs b/CSharpInteractive.HostApi/DotNetBuildServerShutdown.cs deleted file mode 100644 index 7f9d5711..00000000 --- a/CSharpInteractive.HostApi/DotNetBuildServerShutdown.cs +++ /dev/null @@ -1,66 +0,0 @@ -// ReSharper disable UnusedMember.Global -// ReSharper disable MemberCanBePrivate.Global -// ReSharper disable UnusedType.Global -// ReSharper disable StringLiteralTypo - -namespace HostApi; - -using Internal.DotNet; - -/// -/// The dotnet build server command is used to shut down build servers that are started from dotnet. -/// -/// -/// new DotNetBuildServerShutdown() -/// .Run().EnsureSuccess(); -/// -/// -/// -/// 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. -/// Build servers to shut down. By default, all servers are shut down. -/// Overrides the tool executable path. -/// Specifies the working directory for the tool to be started. -/// Specifies a short name for this operation. -[Target] -public partial record DotNetBuildServerShutdown( - IEnumerable Args, - IEnumerable<(string name, string value)> Vars, - IEnumerable Servers, - string ExecutablePath = "", - string WorkingDirectory = "", - string ShortName = "") -{ - /// - /// Create a new instance of the command. - /// - /// Specifies the set of command line arguments to use when starting the tool. - public DotNetBuildServerShutdown(params string[] args) - : this(args, [], []) - { } - - /// - public IStartInfo GetStartInfo(IHost host) - { - if (host == null) throw new ArgumentNullException(nameof(host)); - return host.CreateCommandLine(ExecutablePath) - .WithShortName(ToString()) - .WithWorkingDirectory(WorkingDirectory) - .WithVars(Vars.ToArray()) - .WithArgs("build-server", "shutdown") - .AddArgs(GetServerArg().ToArray()) - .AddArgs(Args.ToArray()); - } - - /// - public override string ToString() => "dotnet build-server shutdown".GetShortName(ShortName); - - private IEnumerable GetServerArg() => - Servers.Select(server => server switch - { - DotNetBuildServer.MSBuild => "--msbuild", - DotNetBuildServer.VbCsCompiler => "--vbcscompiler", - DotNetBuildServer.Razor => "--razor", - _ => throw new ArgumentOutOfRangeException() - }); -} \ No newline at end of file diff --git a/CSharpInteractive.HostApi/DotNetCertificateFormat.cs b/CSharpInteractive.HostApi/DotNetCertificateFormat.cs new file mode 100644 index 00000000..3890c311 --- /dev/null +++ b/CSharpInteractive.HostApi/DotNetCertificateFormat.cs @@ -0,0 +1,17 @@ +namespace HostApi; + +/// +/// Format of the certificate file. +/// +public enum DotNetCertificateFormat +{ + /// + /// PFX (Personal Exchange Format) file is a digital certificate file format used in Microsoft Windows and other systems to store a private key and a corresponding public key certificate, along with any intermediate certificates that may be necessary to establish the trust chain. PFX files are often used for importing and exporting certificates between different systems or applications. + /// + Pfx, + + /// + /// PEM (Privacy Enhanced Mail) is a file format used for storing and transmitting digital certificates, private keys, and other cryptographic information. PEM files use Base64 encoding and consist of a header, a footer, and the Base64-encoded data in between. + /// + Pem +} \ No newline at end of file diff --git a/CSharpInteractive.HostApi/DotNetClean.cs b/CSharpInteractive.HostApi/DotNetClean.cs deleted file mode 100644 index d18157b8..00000000 --- a/CSharpInteractive.HostApi/DotNetClean.cs +++ /dev/null @@ -1,82 +0,0 @@ -// ReSharper disable UnusedType.Global -// ReSharper disable UnusedMember.Global - -namespace HostApi; - -using Internal.DotNet; - -/// -/// The dotnet clean 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. -/// -/// -/// new DotNetClean() -/// .WithVerbosity(DotNetVerbosity.Quiet) -/// .Build().EnsureSuccess(); -/// -/// -/// -/// MSBuild options for setting properties. -/// 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. -/// Overrides the tool executable path. -/// Specifies the working directory for the tool to be started. -/// The MSBuild project or solution to clean. If a project or solution file is not specified, MSBuild searches the current working directory for a file that has a file extension that ends in proj or sln, and uses that file. -/// The framework that was specified at build time. The framework must be defined in the project file. If you specified the framework at build time, you must specify the framework when cleaning. -/// Cleans the output folder of the specified runtime. This is used when a self-contained deployment was created. -/// Defines the build configuration. The default for most projects is Debug, but you can override the build configuration settings in your project. This option is only required when cleaning if you specified it during build time. -/// The directory that contains the build artifacts to clean. Specify the -f|--framework <FRAMEWORK> switch with the output directory switch if you specified the framework when the project was built. -/// Doesn't display the startup banner or the copyright message. Available since .NET Core 3.0 SDK. -/// Sets the verbosity level of the command. Allowed values are Quiet, Minimal, Normal, Detailed, and Diagnostic. The default is Minimal. For more information, see LoggerVerbosity. -/// Specifies a short name for this operation. -[Target] -public partial record DotNetClean( - IEnumerable<(string name, string value)> Props, - IEnumerable Args, - IEnumerable<(string name, string value)> Vars, - string ExecutablePath = "", - string WorkingDirectory = "", - string Project = "", - string Framework = "", - string Runtime = "", - string Configuration = "", - string Output = "", - bool? NoLogo = default, - DotNetVerbosity? Verbosity = default, - string ShortName = "") -{ - /// - /// Create a new instance of the command. - /// - /// Specifies the set of command line arguments to use when starting the tool. - public DotNetClean(params string[] args) - : this([], args, []) - { } - - /// - public IStartInfo GetStartInfo(IHost host) - { - if (host == null) throw new ArgumentNullException(nameof(host)); - return host.CreateCommandLine(ExecutablePath) - .WithShortName(ToString()) - .WithArgs("clean") - .AddNotEmptyArgs(Project) - .WithWorkingDirectory(WorkingDirectory) - .WithVars(Vars.ToArray()) - .AddMSBuildLoggers(host, Verbosity) - .AddArgs( - ("--output", Output), - ("--framework", Framework), - ("--runtime", Runtime), - ("--configuration", Configuration), - ("--verbosity", Verbosity?.ToString().ToLowerInvariant()) - ) - .AddBooleanArgs( - ("--nologo", NoLogo) - ) - .AddProps("-p", Props.ToArray()) - .AddArgs(Args.ToArray()); - } - - /// - public override string ToString() => "dotnet clean".GetShortName(ShortName, Project); -} \ No newline at end of file diff --git a/CSharpInteractive.HostApi/DotNetCommands.cs b/CSharpInteractive.HostApi/DotNetCommands.cs new file mode 100644 index 00000000..0750cbdb --- /dev/null +++ b/CSharpInteractive.HostApi/DotNetCommands.cs @@ -0,0 +1,6647 @@ +// ReSharper disable UnusedMember.Global +// ReSharper disable InconsistentNaming +namespace HostApi; +using Internal.DotNet; +using Internal; + +/// +/// Runs a dotnet application. +///

+/// 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. +///

+///
.NET CLI command
+/// +/// +/// // Adds the namespace "HostApi" to use .NET build API +/// using HostApi; +/// +/// new DotNet() +/// .WithPathToApplication(Path.Combine(path, "MyApp.dll")) +/// .Run().EnsureSuccess(); +/// +/// +///
+/// 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. +/// Paths containing probing policy and assemblies to probe. +/// Overrides the tool executable path. +/// Specifies the working directory for the tool to be started. +/// 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. +/// 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. +/// Version of the .NET runtime to use to run the application. +/// Controls how roll forward is applied to the app. The SETTING can be one of the following values. If not specified, is the default. +/// Enables diagnostic output. +/// Prints out detailed information about a .NET installation and the machine environment, such as the current operating system, and commit SHA of the .NET version. +/// Prints out the version of the .NET SDK used by dotnet commands, which may be affected by a global.json file. +/// Prints out a list of the installed .NET runtimes. An x86 version of the SDK lists only x86 runtimes, and an x64 version of the SDK lists only x64 runtimes. +/// Prints out a list of the installed .NET SDKs. +/// Specifies a short name for this operation. +[Target] +public partial record DotNet( + IEnumerable Args, + IEnumerable<(string name, string value)> Vars, + IEnumerable AdditionalProbingPaths, + string PathToApplication = "", + string AdditionalDeps = "", + string FxVersion = "", + DotNetRollForward? RollForward = default, + bool? Diagnostics = default, + bool? Info = default, + bool? Version = default, + bool? ListRuntimes = default, + bool? ListSdks = default, + string ExecutablePath = "", + string WorkingDirectory = "", + string ShortName = "") +{ + /// + /// Create a new instance of the command. + /// + /// Specifies the set of command line arguments to use when starting the tool. + public DotNet(params string[] args) + : this(args, [], []) + { + } + + /// + /// Create a new instance of the command. + /// + public DotNet() + : this([], [], []) + { + } + + /// + public IStartInfo GetStartInfo(IHost host) + { + if (host == null) throw new ArgumentNullException(nameof(host)); + return host.CreateCommandLine(ExecutablePath) + .WithShortName(ToString()) + .WithWorkingDirectory(WorkingDirectory) + .WithVars(Vars.ToArray()) + .AddNotEmptyArgs(PathToApplication.ToArg()) + .AddArgs(AdditionalProbingPaths.ToArgs("--additionalprobingpath", "")) + .AddArgs(AdditionalDeps.ToArgs("--additional-deps", "")) + .AddArgs(FxVersion.ToArgs("--fx-version", "")) + .AddArgs(RollForward.ToArgs("--roll-forward", "")) + .AddBooleanArgs( + ("--diagnostics", Diagnostics), + ("--info", Info), + ("--version", Version), + ("--list-runtimes", ListRuntimes), + ("--list-sdks", ListSdks) + ) + .AddArgs(Args.ToArray()); + } + + /// + public override string ToString() => (ExecutablePath == string.Empty ? "dotnet" : Path.GetFileNameWithoutExtension(ExecutablePath)).GetShortName("Runs a dotnet application.", ShortName, PathToApplication.ToArg()); +} + +/// +/// Executes a dotnet application. +///

+/// 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. +///

+///
.NET CLI command
+/// +/// +/// using HostApi; +/// new DotNetExec() +/// .WithPathToApplication(Path.Combine(path, "MyApp.dll")) +/// .Run().EnsureSuccess(); +/// +/// +///
+/// 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. +/// Paths containing probing policy and assemblies to probe. +/// Overrides the tool executable path. +/// Specifies the working directory for the tool to be started. +/// 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. +/// 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. +/// 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. +/// Version of the .NET runtime to use to run the application. +/// Controls how roll forward is applied to the app. The SETTING can be one of the following values. If not specified, is the default. +/// Path to a runtimeconfig.json file. A runtimeconfig.json file contains run-time settings and is typically named <applicationname>.runtimeconfig.json. +/// Enables diagnostic output. +/// Specifies a short name for this operation. +[Target] +public partial record DotNetExec( + IEnumerable Args, + IEnumerable<(string name, string value)> Vars, + IEnumerable AdditionalProbingPaths, + string PathToApplication = "", + string DepsFile = "", + string AdditionalDeps = "", + string FxVersion = "", + DotNetRollForward? RollForward = default, + string RuntimeConfig = "", + bool? Diagnostics = default, + string ExecutablePath = "", + string WorkingDirectory = "", + string ShortName = "") +{ + /// + /// Create a new instance of the command. + /// + /// Specifies the set of command line arguments to use when starting the tool. + public DotNetExec(params string[] args) + : this(args, [], []) + { + } + + /// + /// Create a new instance of the command. + /// + public DotNetExec() + : this([], [], []) + { + } + + /// + public IStartInfo GetStartInfo(IHost host) + { + if (host == null) throw new ArgumentNullException(nameof(host)); + return host.CreateCommandLine(ExecutablePath) + .WithShortName(ToString()) + .WithWorkingDirectory(WorkingDirectory) + .WithVars(Vars.ToArray()) + .AddArgs("exec") + .AddNotEmptyArgs(PathToApplication.ToArg()) + .AddArgs(AdditionalProbingPaths.ToArgs("--additionalprobingpath", "")) + .AddArgs(DepsFile.ToArgs("--depsfile", "")) + .AddArgs(AdditionalDeps.ToArgs("--additional-deps", "")) + .AddArgs(FxVersion.ToArgs("--fx-version", "")) + .AddArgs(RollForward.ToArgs("--roll-forward", "")) + .AddArgs(RuntimeConfig.ToArgs("--runtimeconfig", "")) + .AddBooleanArgs( + ("--diagnostics", Diagnostics) + ) + .AddArgs(Args.ToArray()); + } + + /// + public override string ToString() => (ExecutablePath == string.Empty ? "dotnet" : Path.GetFileNameWithoutExtension(ExecutablePath)).GetShortName("Executes a dotnet application.", ShortName, "exec", PathToApplication.ToArg()); +} + +/// +/// Adds or updates a package reference in a project file. +///

+/// 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. +///

+///
.NET CLI command
+/// +/// +/// using HostApi; +/// +/// var result = new DotNetAddPackage() +/// .WithWorkingDirectory("MyLib") +/// .WithPackage("Pure.DI") +/// .Run().EnsureSuccess(); +/// +/// +///
+/// 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. +/// The URI of the NuGet package source to use during this operation. +/// Overrides the tool executable path. +/// Specifies the working directory for the tool to be started. +/// 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. +/// The package reference to add. +/// Adds a package reference only when targeting a specific framework. +/// Doesn't execute an implicit restore when running the command. +/// 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. +/// Allows prerelease packages to be installed. Available since .NET Core 5 SDK. +/// Version of the package +/// Enables diagnostic output. +/// Specifies a short name for this operation. +[Target] +public partial record DotNetAddPackage( + IEnumerable Args, + IEnumerable<(string name, string value)> Vars, + IEnumerable Sources, + string Project = "", + string Package = "", + string Framework = "", + bool? NoRestore = default, + string PackageDirectory = "", + bool? Prerelease = default, + string Version = "", + bool? Diagnostics = default, + string ExecutablePath = "", + string WorkingDirectory = "", + string ShortName = "") +{ + /// + /// Create a new instance of the command. + /// + /// Specifies the set of command line arguments to use when starting the tool. + public DotNetAddPackage(params string[] args) + : this(args, [], []) + { + } + + /// + /// Create a new instance of the command. + /// + public DotNetAddPackage() + : this([], [], []) + { + } + + /// + public IStartInfo GetStartInfo(IHost host) + { + if (host == null) throw new ArgumentNullException(nameof(host)); + return host.CreateCommandLine(ExecutablePath) + .WithShortName(ToString()) + .WithWorkingDirectory(WorkingDirectory) + .WithVars(Vars.ToArray()) + .AddArgs("add") + .AddNotEmptyArgs(Project.ToArg()) + .AddArgs("package") + .AddNotEmptyArgs(Package.ToArg()) + .AddArgs(Sources.ToArgs("--source", "")) + .AddArgs(Framework.ToArgs("--framework", "")) + .AddArgs(PackageDirectory.ToArgs("--package-directory", "")) + .AddArgs(Version.ToArgs("--version", "")) + .AddBooleanArgs( + ("--no-restore", NoRestore), + ("--prerelease", Prerelease), + ("--diagnostics", Diagnostics) + ) + .AddArgs(Args.ToArray()); + } + + /// + public override string ToString() => (ExecutablePath == string.Empty ? "dotnet" : Path.GetFileNameWithoutExtension(ExecutablePath)).GetShortName("Adds or updates a package reference in a project file.", ShortName, "add", Project.ToArg(), "package", Package.ToArg()); +} + +/// +/// Lists the package references for a project or solution. +///

+/// 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. +///

+///
.NET CLI command
+/// +/// +/// using HostApi; +/// +/// new DotNetAddPackage() +/// .WithWorkingDirectory("MyLib") +/// .WithPackage("Pure.DI") +/// .Run().EnsureSuccess(); +/// +/// var lines = new List<string>(); +/// new DotNetListPackage() +/// .WithWorkingDirectory("MyLib") +/// .WithVerbosity(DotNetVerbosity.Minimal) +/// .Run(output => lines.Add(output.Line)); +/// +/// lines.Any(i => i.Contains("Pure.DI")).ShouldBeTrue(); +/// +/// +///
+/// 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. +/// Displays only the packages applicable for the specified target framework. +/// The URI of the NuGet package source to use during this operation. +/// Overrides the tool executable path. +/// Specifies the working directory for the tool to be started. +/// 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. +/// The NuGet sources to use when searching for newer packages. Requires the --outdated option. +/// Displays packages that have been deprecated. +/// Considers only the packages with a matching major version number when searching for newer packages. Requires the --outdated or --deprecated option. +/// Considers only the packages with a matching major and minor version numbers when searching for newer packages. Requires the --outdated or --deprecated option. +/// Considers packages with prerelease versions when searching for newer packages. Requires the --outdated or --deprecated option. +/// 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. +/// Lists packages that have newer versions available. +/// Sets the verbosity level of the command. Allowed values are , , , , and . The default is . For more information, see . +/// Enables diagnostic output. +/// Specifies a short name for this operation. +[Target] +public partial record DotNetListPackage( + IEnumerable Args, + IEnumerable<(string name, string value)> Vars, + IEnumerable Frameworks, + IEnumerable Sources, + string Project = "", + string Config = "", + bool? Deprecated = default, + bool? HighestMinor = default, + bool? HighestPatch = default, + bool? IncludePrerelease = default, + bool? IncludeTransitive = default, + bool? Outdated = default, + DotNetVerbosity? Verbosity = default, + bool? Diagnostics = default, + string ExecutablePath = "", + string WorkingDirectory = "", + string ShortName = "") +{ + /// + /// Create a new instance of the command. + /// + /// Specifies the set of command line arguments to use when starting the tool. + public DotNetListPackage(params string[] args) + : this(args, [], [], []) + { + } + + /// + /// Create a new instance of the command. + /// + public DotNetListPackage() + : this([], [], [], []) + { + } + + /// + public IStartInfo GetStartInfo(IHost host) + { + if (host == null) throw new ArgumentNullException(nameof(host)); + return host.CreateCommandLine(ExecutablePath) + .WithShortName(ToString()) + .WithWorkingDirectory(WorkingDirectory) + .WithVars(Vars.ToArray()) + .AddArgs("list") + .AddNotEmptyArgs(Project.ToArg()) + .AddArgs("package") + .AddArgs(Frameworks.ToArgs("--framework", "")) + .AddArgs(Sources.ToArgs("--source", "")) + .AddArgs(Config.ToArgs("--config", "")) + .AddArgs(Verbosity.ToArgs("--verbosity", "")) + .AddBooleanArgs( + ("--deprecated", Deprecated), + ("--highest-minor", HighestMinor), + ("--highest-patch", HighestPatch), + ("--include-prerelease", IncludePrerelease), + ("--include-transitive", IncludeTransitive), + ("--outdated", Outdated), + ("--diagnostics", Diagnostics) + ) + .AddArgs(Args.ToArray()); + } + + /// + public override string ToString() => (ExecutablePath == string.Empty ? "dotnet" : Path.GetFileNameWithoutExtension(ExecutablePath)).GetShortName("Lists the package references for a project or solution.", ShortName, "list", Project.ToArg(), "package"); +} + +/// +/// Removes package reference from a project file. +///

+/// This command provides a convenient option to remove a NuGet package reference from a project. +///

+///
.NET CLI command
+/// +/// +/// using HostApi; +/// +/// new DotNetAddPackage() +/// .WithWorkingDirectory("MyLib") +/// .WithPackage("Pure.DI") +/// .Run().EnsureSuccess(); +/// +/// new DotNetRemovePackage() +/// .WithWorkingDirectory("MyLib") +/// .WithPackage("Pure.DI") +/// .Run().EnsureSuccess(); +/// +/// +///
+/// 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. +/// Overrides the tool executable path. +/// Specifies the working directory for the tool to be started. +/// 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. +/// The package reference to add. +/// Enables diagnostic output. +/// Specifies a short name for this operation. +[Target] +public partial record DotNetRemovePackage( + IEnumerable Args, + IEnumerable<(string name, string value)> Vars, + string Project = "", + string Package = "", + bool? Diagnostics = default, + string ExecutablePath = "", + string WorkingDirectory = "", + string ShortName = "") +{ + /// + /// Create a new instance of the command. + /// + /// Specifies the set of command line arguments to use when starting the tool. + public DotNetRemovePackage(params string[] args) + : this(args, []) + { + } + + /// + /// Create a new instance of the command. + /// + public DotNetRemovePackage() + : this([], []) + { + } + + /// + public IStartInfo GetStartInfo(IHost host) + { + if (host == null) throw new ArgumentNullException(nameof(host)); + return host.CreateCommandLine(ExecutablePath) + .WithShortName(ToString()) + .WithWorkingDirectory(WorkingDirectory) + .WithVars(Vars.ToArray()) + .AddArgs("remove") + .AddNotEmptyArgs(Project.ToArg()) + .AddArgs("package") + .AddNotEmptyArgs(Package.ToArg()) + .AddBooleanArgs( + ("--diagnostics", Diagnostics) + ) + .AddArgs(Args.ToArray()); + } + + /// + public override string ToString() => (ExecutablePath == string.Empty ? "dotnet" : Path.GetFileNameWithoutExtension(ExecutablePath)).GetShortName("Removes package reference from a project file.", ShortName, "remove", Project.ToArg(), "package", Package.ToArg()); +} + +/// +/// Adds project-to-project (P2P) references. +///

+/// 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. +///

+///
.NET CLI command
+/// +/// +/// using HostApi; +/// +/// var result = new DotNetAddReference() +/// .WithProject(Path.Combine("MyTests", "MyTests.csproj")) +/// .WithReferences(Path.Combine("MyLib", "MyLib.csproj")) +/// .Run().EnsureSuccess(); +/// +/// +/// +///
+/// 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. +/// Project-to-project (P2P) references to add. Specify one or more projects. Glob patterns are supported on Unix/Linux-based systems. +/// Overrides the tool executable path. +/// Specifies the working directory for the tool to be started. +/// 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. +/// Adds project references only when targeting a specific framework using the TFM format. +/// Enables diagnostic output. +/// Specifies a short name for this operation. +[Target] +public partial record DotNetAddReference( + IEnumerable Args, + IEnumerable<(string name, string value)> Vars, + IEnumerable References, + string Project = "", + string Framework = "", + bool? Diagnostics = default, + string ExecutablePath = "", + string WorkingDirectory = "", + string ShortName = "") +{ + /// + /// Create a new instance of the command. + /// + /// Specifies the set of command line arguments to use when starting the tool. + public DotNetAddReference(params string[] args) + : this(args, [], []) + { + } + + /// + /// Create a new instance of the command. + /// + public DotNetAddReference() + : this([], [], []) + { + } + + /// + public IStartInfo GetStartInfo(IHost host) + { + if (host == null) throw new ArgumentNullException(nameof(host)); + return host.CreateCommandLine(ExecutablePath) + .WithShortName(ToString()) + .WithWorkingDirectory(WorkingDirectory) + .WithVars(Vars.ToArray()) + .AddArgs("add") + .AddNotEmptyArgs(Project.ToArg()) + .AddArgs("reference") + .AddNotEmptyArgs(References.ToArray()) + .AddArgs(Framework.ToArgs("--framework", "")) + .AddBooleanArgs( + ("--diagnostics", Diagnostics) + ) + .AddArgs(Args.ToArray()); + } + + /// + public override string ToString() => (ExecutablePath == string.Empty ? "dotnet" : Path.GetFileNameWithoutExtension(ExecutablePath)).GetShortName("Adds project-to-project (P2P) references.", ShortName, new [] {"add", Project.ToArg(), "reference"}.Concat(References).ToArray()); +} + +/// +/// Lists project-to-project references. +///

+/// This command provides a convenient option to list project references for a given project. +///

+///
.NET CLI command
+/// +/// +/// using HostApi; +/// +/// new DotNetAddReference() +/// .WithProject(Path.Combine("MyTests", "MyTests.csproj")) +/// .WithReferences(Path.Combine("MyLib", "MyLib.csproj")) +/// .Run().EnsureSuccess(); +/// +/// var lines = new List<string>(); +/// new DotNetListReference() +/// .WithProject(Path.Combine("MyTests", "MyTests.csproj")) +/// .Run(output => lines.Add(output.Line)); +/// +/// lines.Any(i => i.Contains("MyLib.csproj")).ShouldBeTrue(); +/// +/// +///
+/// 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. +/// Overrides the tool executable path. +/// Specifies the working directory for the tool to be started. +/// 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. +/// Enables diagnostic output. +/// Specifies a short name for this operation. +[Target] +public partial record DotNetListReference( + IEnumerable Args, + IEnumerable<(string name, string value)> Vars, + string Project = "", + bool? Diagnostics = default, + string ExecutablePath = "", + string WorkingDirectory = "", + string ShortName = "") +{ + /// + /// Create a new instance of the command. + /// + /// Specifies the set of command line arguments to use when starting the tool. + public DotNetListReference(params string[] args) + : this(args, []) + { + } + + /// + /// Create a new instance of the command. + /// + public DotNetListReference() + : this([], []) + { + } + + /// + public IStartInfo GetStartInfo(IHost host) + { + if (host == null) throw new ArgumentNullException(nameof(host)); + return host.CreateCommandLine(ExecutablePath) + .WithShortName(ToString()) + .WithWorkingDirectory(WorkingDirectory) + .WithVars(Vars.ToArray()) + .AddArgs("list") + .AddNotEmptyArgs(Project.ToArg()) + .AddArgs("reference") + .AddBooleanArgs( + ("--diagnostics", Diagnostics) + ) + .AddArgs(Args.ToArray()); + } + + /// + public override string ToString() => (ExecutablePath == string.Empty ? "dotnet" : Path.GetFileNameWithoutExtension(ExecutablePath)).GetShortName("Lists project-to-project references.", ShortName, "list", Project.ToArg(), "reference"); +} + +/// +/// Removes project-to-project (P2P) references. +///

+/// This command provides a convenient option to remove project references from a project. +///

+///
.NET CLI command
+/// +/// +/// using HostApi; +/// +/// new DotNetAddReference() +/// .WithProject(Path.Combine("MyTests", "MyTests.csproj")) +/// .WithReferences(Path.Combine("MyLib", "MyLib.csproj")) +/// .Run().EnsureSuccess(); +/// +/// new DotNetRemoveReference() +/// .WithProject(Path.Combine("MyTests", "MyTests.csproj")) +/// .WithReferences(Path.Combine("MyLib", "MyLib.csproj")) +/// .Run().EnsureSuccess(); +/// +/// var lines = new List<string>(); +/// new DotNetListReference() +/// .WithProject(Path.Combine("MyTests", "MyTests.csproj")) +/// .Run(output => lines.Add(output.Line)); +/// +/// lines.Any(i => i.Contains("MyLib.csproj")).ShouldBeFalse(); +/// +/// +///
+/// 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. +/// Project-to-project (P2P) references to remove. You can specify one or multiple projects. Glob patterns are supported on Unix/Linux based terminals. +/// Overrides the tool executable path. +/// Specifies the working directory for the tool to be started. +/// 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. +/// Removes the reference only when targeting a specific framework using the TFM format. +/// Enables diagnostic output. +/// Specifies a short name for this operation. +[Target] +public partial record DotNetRemoveReference( + IEnumerable Args, + IEnumerable<(string name, string value)> Vars, + IEnumerable References, + string Project = "", + string Framework = "", + bool? Diagnostics = default, + string ExecutablePath = "", + string WorkingDirectory = "", + string ShortName = "") +{ + /// + /// Create a new instance of the command. + /// + /// Specifies the set of command line arguments to use when starting the tool. + public DotNetRemoveReference(params string[] args) + : this(args, [], []) + { + } + + /// + /// Create a new instance of the command. + /// + public DotNetRemoveReference() + : this([], [], []) + { + } + + /// + public IStartInfo GetStartInfo(IHost host) + { + if (host == null) throw new ArgumentNullException(nameof(host)); + return host.CreateCommandLine(ExecutablePath) + .WithShortName(ToString()) + .WithWorkingDirectory(WorkingDirectory) + .WithVars(Vars.ToArray()) + .AddArgs("remove") + .AddNotEmptyArgs(Project.ToArg()) + .AddArgs("reference") + .AddNotEmptyArgs(References.ToArray()) + .AddArgs(Framework.ToArgs("--framework", "")) + .AddBooleanArgs( + ("--diagnostics", Diagnostics) + ) + .AddArgs(Args.ToArray()); + } + + /// + public override string ToString() => (ExecutablePath == string.Empty ? "dotnet" : Path.GetFileNameWithoutExtension(ExecutablePath)).GetShortName("Removes project-to-project (P2P) references.", ShortName, new [] {"remove", Project.ToArg(), "reference"}.Concat(References).ToArray()); +} + +/// +/// Builds a project and all of its dependencies. +///

+/// This command builds the project and its dependencies into a set of binaries. The binaries include the project's code in Intermediate Language (IL) files with a .dll extension. For executable projects targeting versions earlier than .NET Core 3.0, library dependencies from NuGet are typically NOT copied to the output folder. They're resolved from the NuGet global packages folder at run time. With that in mind, the product of dotnet build isn't ready to be transferred to another machine to run. To create a version of the application that can be deployed, you need to publish it (for example, with the dotnet publish command). +///

+///

+/// For executable projects targeting .NET Core 3.0 and later, library dependencies are copied to the output folder. This means that if there isn't any other publish-specific logic (such as Web projects have), the build output should be deployable. +///

+///
.NET CLI command
+/// +/// +/// using HostApi; +/// +/// var messages = new List<BuildMessage>(); +/// var result = new DotNetBuild() +/// .WithWorkingDirectory("MyTests") +/// .Build(message => messages.Add(message)).EnsureSuccess(); +/// +/// result.Errors.Any(message => message.State == BuildMessageState.StdError).ShouldBeFalse(result.ToString()); +/// result.ExitCode.ShouldBe(0, result.ToString()); +/// +/// +///
+/// 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. +/// MSBuild options for setting properties. +/// The URI of the NuGet package source to use during this operation. +/// Overrides the tool executable path. +/// Specifies the working directory for the tool to be started. +/// 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. +/// 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. +/// All build output files from the executed command will go in subfolders under the specified path, separated by project. +/// Defines the build configuration. The default for most projects is Debug, but you can override the build configuration settings in your project. +/// 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. +/// Builds and runs the app using the specified framework. The framework must be specified in the project file. +/// 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. +/// When restoring a project with project-to-project (P2P) references, restores the root project and not the references. +/// 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. +/// Doesn't execute an implicit restore when running the command. +/// Doesn't display the startup banner or the copyright message. +/// 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. +/// 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. +/// 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. +/// 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. +/// 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. +/// Specifies whether the terminal logger should be used for the build output. +/// Sets the verbosity level of the command. Allowed values are , , , , and . The default is . For more information, see . +/// 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. +/// 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. +/// Enables diagnostic output. +/// Specifies a short name for this operation. +[Target] +public partial record DotNetBuild( + IEnumerable Args, + IEnumerable<(string name, string value)> Vars, + IEnumerable<(string name, string value)> Props, + IEnumerable Sources, + string Project = "", + string Arch = "", + string ArtifactsPath = "", + string Configuration = "", + bool? DisableBuildServers = default, + string Framework = "", + bool? Force = default, + bool? NoDependencies = default, + bool? NoIncremental = default, + bool? NoRestore = default, + bool? NoLogo = default, + bool? NoSelfContained = default, + string Output = "", + string OS = "", + string Runtime = "", + bool? SelfContained = default, + DotNetTerminalLogger? TerminalLogger = default, + DotNetVerbosity? Verbosity = default, + bool? UseCurrentRuntime = default, + string VersionSuffix = "", + bool? Diagnostics = default, + string ExecutablePath = "", + string WorkingDirectory = "", + string ShortName = "") +{ + /// + /// Create a new instance of the command. + /// + /// Specifies the set of command line arguments to use when starting the tool. + public DotNetBuild(params string[] args) + : this(args, [], [], []) + { + } + + /// + /// Create a new instance of the command. + /// + public DotNetBuild() + : this([], [], [], []) + { + } + + /// + public IStartInfo GetStartInfo(IHost host) + { + if (host == null) throw new ArgumentNullException(nameof(host)); + return host.CreateCommandLine(ExecutablePath) + .WithShortName(ToString()) + .WithWorkingDirectory(WorkingDirectory) + .WithVars(Vars.ToArray()) + .AddArgs("build") + .AddNotEmptyArgs(Project.ToArg()) + .AddMSBuildLoggers(host, Verbosity) + .AddArgs(Sources.ToArgs("--source", "")) + .AddArgs(Arch.ToArgs("--arch", "")) + .AddArgs(ArtifactsPath.ToArgs("--artifacts-path", "")) + .AddArgs(Configuration.ToArgs("--configuration", "")) + .AddArgs(Framework.ToArgs("--framework", "")) + .AddArgs(Output.ToArgs("--output", "")) + .AddArgs(OS.ToArgs("--os", "")) + .AddArgs(Runtime.ToArgs("--runtime", "")) + .AddArgs(TerminalLogger.ToArgs("--tl", "")) + .AddArgs(Verbosity.ToArgs("--verbosity", "")) + .AddArgs(VersionSuffix.ToArgs("--version-suffix", "")) + .AddBooleanArgs( + ("--disable-build-servers", DisableBuildServers), + ("--force", Force), + ("--no-dependencies", NoDependencies), + ("--no-incremental", NoIncremental), + ("--no-restore", NoRestore), + ("--nologo", NoLogo), + ("--no-self-contained", NoSelfContained), + ("--self-contained", SelfContained), + ("--use-current-runtime", UseCurrentRuntime), + ("--diagnostics", Diagnostics) + ) + .AddProps("--property", Props.ToArray()) + .AddArgs(Args.ToArray()); + } + + /// + public override string ToString() => (ExecutablePath == string.Empty ? "dotnet" : Path.GetFileNameWithoutExtension(ExecutablePath)).GetShortName("Builds a project and all of its dependencies.", ShortName, "build", Project.ToArg()); +} + +/// +/// Shuts down build servers that are started from dotnet. +///

+/// By default, all servers are shut down. +///

+///
.NET CLI command
+/// +/// +/// using HostApi; +/// +/// // Shuts down all build servers that are started from dotnet. +/// new DotNetBuildServerShutdown() +/// .Run().EnsureSuccess(); +/// +/// +///
+/// 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. +/// Shuts down build servers that are started from dotnet. By default, all servers are shut down. +/// Overrides the tool executable path. +/// Specifies the working directory for the tool to be started. +/// Enables diagnostic output. +/// Specifies a short name for this operation. +[Target] +public partial record DotNetBuildServerShutdown( + IEnumerable Args, + IEnumerable<(string name, string value)> Vars, + IEnumerable Servers, + bool? Diagnostics = default, + string ExecutablePath = "", + string WorkingDirectory = "", + string ShortName = "") +{ + /// + /// Create a new instance of the command. + /// + /// Specifies the set of command line arguments to use when starting the tool. + public DotNetBuildServerShutdown(params string[] args) + : this(args, [], []) + { + } + + /// + /// Create a new instance of the command. + /// + public DotNetBuildServerShutdown() + : this([], [], []) + { + } + + /// + public IStartInfo GetStartInfo(IHost host) + { + if (host == null) throw new ArgumentNullException(nameof(host)); + return host.CreateCommandLine(ExecutablePath) + .WithShortName(ToString()) + .WithWorkingDirectory(WorkingDirectory) + .WithVars(Vars.ToArray()) + .AddArgs("build-server") + .AddArgs("shutdown") + .AddArgs(Servers.ToArgs("", "")) + .AddBooleanArgs( + ("--diagnostics", Diagnostics) + ) + .AddArgs(Args.ToArray()); + } + + /// + public override string ToString() => (ExecutablePath == string.Empty ? "dotnet" : Path.GetFileNameWithoutExtension(ExecutablePath)).GetShortName("Shuts down build servers that are started from dotnet.", ShortName, "build-server", "shutdown"); +} + +/// +/// Cleans the output of a project. +///

+/// 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. +///

+///
.NET CLI command
+/// +/// +/// using HostApi; +/// +/// // Clean the project, running a command like: "dotnet clean" from the directory "MyLib" +/// new DotNetClean() +/// .WithWorkingDirectory("MyLib") +/// .Build().EnsureSuccess(); +/// +/// +///
+/// 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. +/// MSBuild options for setting properties. +/// Overrides the tool executable path. +/// Specifies the working directory for the tool to be started. +/// 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. +/// All build output files from the executed command will go in subfolders under the specified path, separated by project. +/// Defines the build configuration. The default for most projects is Debug, but you can override the build configuration settings in your project. +/// Builds and runs the app using the specified framework. The framework must be specified in the project file. +/// Doesn't display the startup banner or the copyright message. +/// 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. +/// 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. +/// Specifies whether the terminal logger should be used for the build output. +/// Sets the verbosity level of the command. Allowed values are , , , , and . The default is . For more information, see . +/// Enables diagnostic output. +/// Specifies a short name for this operation. +[Target] +public partial record DotNetClean( + IEnumerable Args, + IEnumerable<(string name, string value)> Vars, + IEnumerable<(string name, string value)> Props, + string Project = "", + string ArtifactsPath = "", + string Configuration = "", + string Framework = "", + bool? NoLogo = default, + string Output = "", + string Runtime = "", + DotNetTerminalLogger? TerminalLogger = default, + DotNetVerbosity? Verbosity = default, + bool? Diagnostics = default, + string ExecutablePath = "", + string WorkingDirectory = "", + string ShortName = "") +{ + /// + /// Create a new instance of the command. + /// + /// Specifies the set of command line arguments to use when starting the tool. + public DotNetClean(params string[] args) + : this(args, [], []) + { + } + + /// + /// Create a new instance of the command. + /// + public DotNetClean() + : this([], [], []) + { + } + + /// + public IStartInfo GetStartInfo(IHost host) + { + if (host == null) throw new ArgumentNullException(nameof(host)); + return host.CreateCommandLine(ExecutablePath) + .WithShortName(ToString()) + .WithWorkingDirectory(WorkingDirectory) + .WithVars(Vars.ToArray()) + .AddArgs("clean") + .AddNotEmptyArgs(Project.ToArg()) + .AddMSBuildLoggers(host, Verbosity) + .AddArgs(ArtifactsPath.ToArgs("--artifacts-path", "")) + .AddArgs(Configuration.ToArgs("--configuration", "")) + .AddArgs(Framework.ToArgs("--framework", "")) + .AddArgs(Output.ToArgs("--output", "")) + .AddArgs(Runtime.ToArgs("--runtime", "")) + .AddArgs(TerminalLogger.ToArgs("--tl", "")) + .AddArgs(Verbosity.ToArgs("--verbosity", "")) + .AddBooleanArgs( + ("--nologo", NoLogo), + ("--diagnostics", Diagnostics) + ) + .AddProps("--property", Props.ToArray()) + .AddArgs(Args.ToArray()); + } + + /// + public override string ToString() => (ExecutablePath == string.Empty ? "dotnet" : Path.GetFileNameWithoutExtension(ExecutablePath)).GetShortName("Cleans the output of a project.", ShortName, "clean", Project.ToArg()); +} + +/// +/// Generates a self-signed certificate to enable HTTPS use in development. +///

+/// This command manages a self-signed certificate to enable HTTPS use in local web app development. Its main functions are: +///
- Generating a certificate for use with HTTPS endpoints during development. +///
- Trusting the generated certificate on the local machine. +///
- Removing the generated certificate from the local machine. +///
- 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. +///

+///
.NET CLI command
+/// +/// +/// using HostApi; +/// +/// // Create a certificate, trust it, and export it to a PEM file. +/// new DotNetDevCertsHttps() +/// .WithExportPath("certificate.pem") +/// .WithTrust(true) +/// .WithFormat(DotNetCertificateFormat.Pem) +/// .WithPassword("Abc") +/// .Run().EnsureSuccess(); +/// +/// +///
+/// 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. +/// Overrides the tool executable path. +/// Specifies the working directory for the tool to be started. +/// 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. +/// 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. +/// 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. +/// 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. +/// 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. +/// 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. +/// Specifies the password to use. +/// Display warnings and errors only. +/// 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. +/// Display debug information. +/// Enables diagnostic output. +/// Specifies a short name for this operation. +[Target] +public partial record DotNetDevCertsHttps( + IEnumerable Args, + IEnumerable<(string name, string value)> Vars, + bool? Check = default, + bool? Clean = default, + string ExportPath = "", + DotNetCertificateFormat? Format = default, + bool? Import = default, + bool? NoPassword = default, + string Password = "", + bool? Quiet = default, + bool? Trust = default, + bool? Verbose = default, + bool? Diagnostics = default, + string ExecutablePath = "", + string WorkingDirectory = "", + string ShortName = "") +{ + /// + /// Create a new instance of the command. + /// + /// Specifies the set of command line arguments to use when starting the tool. + public DotNetDevCertsHttps(params string[] args) + : this(args, []) + { + } + + /// + /// Create a new instance of the command. + /// + public DotNetDevCertsHttps() + : this([], []) + { + } + + /// + public IStartInfo GetStartInfo(IHost host) + { + if (host == null) throw new ArgumentNullException(nameof(host)); + return host.CreateCommandLine(ExecutablePath) + .WithShortName(ToString()) + .WithWorkingDirectory(WorkingDirectory) + .WithVars(Vars.ToArray()) + .AddArgs("dev-certs") + .AddArgs("https") + .AddArgs(ExportPath.ToArgs("--export-path", "")) + .AddArgs(Format.ToArgs("--format", "")) + .AddArgs(Password.ToArgs("--password", "")) + .AddBooleanArgs( + ("--check", Check), + ("--clean", Clean), + ("--import", Import), + ("--no-password", NoPassword), + ("--quiet", Quiet), + ("--trust", Trust), + ("--verbose", Verbose), + ("--diagnostics", Diagnostics) + ) + .AddArgs(Args.ToArray()); + } + + /// + public override string ToString() => (ExecutablePath == string.Empty ? "dotnet" : Path.GetFileNameWithoutExtension(ExecutablePath)).GetShortName("Generates a self-signed certificate to enable HTTPS use in development.", ShortName, "dev-certs", "https"); +} + +/// +/// Formats code to match editorconfig settings. +///

+/// This command formats a code that applies style preferences and static analysis recommendations to a project or solution. Preferences will be read from an .editorconfig file, if present, otherwise a default set of preferences will be used. For more information, see the EditorConfig documentation. +///

+///
.NET CLI command
+/// +/// +/// using HostApi; +/// +/// new DotNetFormat() +/// .WithWorkingDirectory("MyLib") +/// .WithProject("MyLib.csproj") +/// .AddDiagnostics("IDE0005", "IDE0006") +/// .AddIncludes(".", "./tests") +/// .AddExcludes("./obj") +/// .WithSeverity(DotNetFormatSeverity.Information) +/// .Run().EnsureSuccess(); +/// +/// +///
+/// 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. +/// A list of diagnostic IDs to use as a filter when fixing code style or third-party issues. Default value is whichever IDs are listed in the .editorconfig file. For a list of built-in analyzer rule IDs that you can specify, see the list of IDs for code-analysis style rules. +/// A list of relative file or folder paths to include in formatting. The default is all files in the solution or project. +/// A space-separated list of relative file or folder paths to exclude from formatting. The default is none. +/// Overrides the tool executable path. +/// Specifies the working directory for the tool to be started. +/// The MSBuild project or solution to run code formatting on. If a project or solution file is not specified, MSBuild searches the current working directory for a file that has a file extension that ends in proj or sln, and uses that file. +/// The minimum severity of diagnostics to fix. Allowed values are Information, Warning, and Error. The default value is Warning. +/// Doesn't execute an implicit restore when running the command. +/// Verifies that no formatting changes would be performed. Terminates with a non zero exit code if any files would have been formatted. +/// Formats files generated by the SDK. +/// Sets the verbosity level of the command. Allowed values are , , , , and . The default is . For more information, see . +/// Logs all project or solution load information to a binary log file. +/// Produces a JSON report in the specified directory. +/// Specifies a short name for this operation. +[Target] +public partial record DotNetFormat( + IEnumerable Args, + IEnumerable<(string name, string value)> Vars, + IEnumerable Diagnostics, + IEnumerable Includes, + IEnumerable Excludes, + string Project = "", + DotNetFormatSeverity? Severity = default, + bool? NoRestore = default, + bool? VerifyNoChanges = default, + bool? IncludeGenerated = default, + DotNetVerbosity? Verbosity = default, + string BinaryLog = "", + string Report = "", + string ExecutablePath = "", + string WorkingDirectory = "", + string ShortName = "") +{ + /// + /// Create a new instance of the command. + /// + /// Specifies the set of command line arguments to use when starting the tool. + public DotNetFormat(params string[] args) + : this(args, [], [], [], []) + { + } + + /// + /// Create a new instance of the command. + /// + public DotNetFormat() + : this([], [], [], [], []) + { + } + + /// + public IStartInfo GetStartInfo(IHost host) + { + if (host == null) throw new ArgumentNullException(nameof(host)); + return host.CreateCommandLine(ExecutablePath) + .WithShortName(ToString()) + .WithWorkingDirectory(WorkingDirectory) + .WithVars(Vars.ToArray()) + .AddArgs("format") + .AddNotEmptyArgs(Project.ToArg()) + .AddArgs(Diagnostics.ToArgs("--diagnostics", " ")) + .AddArgs(Includes.ToArgs("--include", " ")) + .AddArgs(Excludes.ToArgs("--exclude", " ")) + .AddArgs(Severity.ToArgs("--severity", "")) + .AddArgs(Verbosity.ToArgs("--verbosity", "")) + .AddArgs(BinaryLog.ToArgs("--binarylog", "")) + .AddArgs(Report.ToArgs("--report", "")) + .AddBooleanArgs( + ("--no-restore", NoRestore), + ("--verify-no-changes", VerifyNoChanges), + ("--include-generated", IncludeGenerated) + ) + .AddArgs(Args.ToArray()); + } + + /// + public override string ToString() => (ExecutablePath == string.Empty ? "dotnet" : Path.GetFileNameWithoutExtension(ExecutablePath)).GetShortName("Formats code to match editorconfig settings.", ShortName, "format", Project.ToArg()); +} + +/// +/// Formats code to match EditorConfig settings for code style. +///

+/// This command only runs formatting rules associated with code style formatting. For a complete list of formatting options that you can specify in your editorconfig file. +///

+///
.NET CLI command
+/// +/// +/// using HostApi; +/// +/// new DotNetFormatStyle() +/// .WithWorkingDirectory("MyLib") +/// .WithProject("MyLib.csproj") +/// .AddDiagnostics("IDE0005", "IDE0006") +/// .WithSeverity(DotNetFormatSeverity.Information) +/// .Run().EnsureSuccess(); +/// +/// +///
+/// 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. +/// A list of diagnostic IDs to use as a filter when fixing code style issues. Default value is whichever IDs are listed in the .editorconfig file. For a list of built-in code style analyzer rule IDs that you can specify, see the list of IDs for code-analysis style rules. +/// A list of relative file or folder paths to include in formatting. The default is all files in the solution or project. +/// A space-separated list of relative file or folder paths to exclude from formatting. The default is none. +/// Overrides the tool executable path. +/// Specifies the working directory for the tool to be started. +/// The MSBuild project or solution to run code formatting on. If a project or solution file is not specified, MSBuild searches the current working directory for a file that has a file extension that ends in proj or sln, and uses that file. +/// Treat the Project argument as a path to a simple folder of code files. +/// The minimum severity of diagnostics to fix. Allowed values are Information, Warning, and Error. The default value is Warning. +/// Doesn't execute an implicit restore when running the command. +/// Verifies that no formatting changes would be performed. Terminates with a non zero exit code if any files would have been formatted. +/// Formats files generated by the SDK. +/// Sets the verbosity level of the command. Allowed values are , , , , and . The default is . For more information, see . +/// Logs all project or solution load information to a binary log file. +/// Produces a JSON report in the specified directory. +/// Specifies a short name for this operation. +[Target] +public partial record DotNetFormatStyle( + IEnumerable Args, + IEnumerable<(string name, string value)> Vars, + IEnumerable Diagnostics, + IEnumerable Includes, + IEnumerable Excludes, + string Project = "", + bool? Folder = default, + DotNetFormatSeverity? Severity = default, + bool? NoRestore = default, + bool? VerifyNoChanges = default, + bool? IncludeGenerated = default, + DotNetVerbosity? Verbosity = default, + string BinaryLog = "", + string Report = "", + string ExecutablePath = "", + string WorkingDirectory = "", + string ShortName = "") +{ + /// + /// Create a new instance of the command. + /// + /// Specifies the set of command line arguments to use when starting the tool. + public DotNetFormatStyle(params string[] args) + : this(args, [], [], [], []) + { + } + + /// + /// Create a new instance of the command. + /// + public DotNetFormatStyle() + : this([], [], [], [], []) + { + } + + /// + public IStartInfo GetStartInfo(IHost host) + { + if (host == null) throw new ArgumentNullException(nameof(host)); + return host.CreateCommandLine(ExecutablePath) + .WithShortName(ToString()) + .WithWorkingDirectory(WorkingDirectory) + .WithVars(Vars.ToArray()) + .AddArgs("format") + .AddArgs("style") + .AddNotEmptyArgs(Project.ToArg()) + .AddArgs(Diagnostics.ToArgs("--diagnostics", " ")) + .AddArgs(Includes.ToArgs("--include", " ")) + .AddArgs(Excludes.ToArgs("--exclude", " ")) + .AddArgs(Severity.ToArgs("--severity", "")) + .AddArgs(Verbosity.ToArgs("--verbosity", "")) + .AddArgs(BinaryLog.ToArgs("--binarylog", "")) + .AddArgs(Report.ToArgs("--report", "")) + .AddBooleanArgs( + ("--folder", Folder), + ("--no-restore", NoRestore), + ("--verify-no-changes", VerifyNoChanges), + ("--include-generated", IncludeGenerated) + ) + .AddArgs(Args.ToArray()); + } + + /// + public override string ToString() => (ExecutablePath == string.Empty ? "dotnet" : Path.GetFileNameWithoutExtension(ExecutablePath)).GetShortName("Formats code to match EditorConfig settings for code style.", ShortName, "format", "style", Project.ToArg()); +} + +/// +/// Formats code to match editorconfig settings for analyzers (excluding code style rules). +///

+/// This command only runs formatting rules associated with analyzers. For a list of analyzer rules that you can specify in your editorconfig file, see Quality rules. +///

+///
.NET CLI command
+/// +/// +/// using HostApi; +/// +/// new DotNetFormatAnalyzers() +/// .WithWorkingDirectory("MyLib") +/// .WithProject("MyLib.csproj") +/// .AddDiagnostics("CA1831", "CA1832") +/// .WithSeverity(DotNetFormatSeverity.Warning) +/// .Run().EnsureSuccess(); +/// +/// +///
+/// 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. +/// A list of diagnostic IDs to use as a filter when fixing non code style issues. Default value is whichever IDs are listed in the .editorconfig file. For a list of built-in analyzer rule IDs that you can specify, see the list of IDs for quality rules. For third-party analyzers refer to their documentation. +/// A list of relative file or folder paths to include in formatting. The default is all files in the solution or project. +/// A space-separated list of relative file or folder paths to exclude from formatting. The default is none. +/// Overrides the tool executable path. +/// Specifies the working directory for the tool to be started. +/// The MSBuild project or solution to run code formatting on. If a project or solution file is not specified, MSBuild searches the current working directory for a file that has a file extension that ends in proj or sln, and uses that file. +/// The minimum severity of diagnostics to fix. Allowed values are Information, Warning, and Error. The default value is Warning. +/// Doesn't execute an implicit restore when running the command. +/// Verifies that no formatting changes would be performed. Terminates with a non zero exit code if any files would have been formatted. +/// Formats files generated by the SDK. +/// Sets the verbosity level of the command. Allowed values are , , , , and . The default is . For more information, see . +/// Logs all project or solution load information to a binary log file. +/// Produces a JSON report in the specified directory. +/// Specifies a short name for this operation. +[Target] +public partial record DotNetFormatAnalyzers( + IEnumerable Args, + IEnumerable<(string name, string value)> Vars, + IEnumerable Diagnostics, + IEnumerable Includes, + IEnumerable Excludes, + string Project = "", + DotNetFormatSeverity? Severity = default, + bool? NoRestore = default, + bool? VerifyNoChanges = default, + bool? IncludeGenerated = default, + DotNetVerbosity? Verbosity = default, + string BinaryLog = "", + string Report = "", + string ExecutablePath = "", + string WorkingDirectory = "", + string ShortName = "") +{ + /// + /// Create a new instance of the command. + /// + /// Specifies the set of command line arguments to use when starting the tool. + public DotNetFormatAnalyzers(params string[] args) + : this(args, [], [], [], []) + { + } + + /// + /// Create a new instance of the command. + /// + public DotNetFormatAnalyzers() + : this([], [], [], [], []) + { + } + + /// + public IStartInfo GetStartInfo(IHost host) + { + if (host == null) throw new ArgumentNullException(nameof(host)); + return host.CreateCommandLine(ExecutablePath) + .WithShortName(ToString()) + .WithWorkingDirectory(WorkingDirectory) + .WithVars(Vars.ToArray()) + .AddArgs("format") + .AddArgs("analyzers") + .AddNotEmptyArgs(Project.ToArg()) + .AddArgs(Diagnostics.ToArgs("--diagnostics", " ")) + .AddArgs(Includes.ToArgs("--include", " ")) + .AddArgs(Excludes.ToArgs("--exclude", " ")) + .AddArgs(Severity.ToArgs("--severity", "")) + .AddArgs(Verbosity.ToArgs("--verbosity", "")) + .AddArgs(BinaryLog.ToArgs("--binarylog", "")) + .AddArgs(Report.ToArgs("--report", "")) + .AddBooleanArgs( + ("--no-restore", NoRestore), + ("--verify-no-changes", VerifyNoChanges), + ("--include-generated", IncludeGenerated) + ) + .AddArgs(Args.ToArray()); + } + + /// + public override string ToString() => (ExecutablePath == string.Empty ? "dotnet" : Path.GetFileNameWithoutExtension(ExecutablePath)).GetShortName("Formats code to match editorconfig settings for analyzers (excluding code style rules).", ShortName, "format", "analyzers", Project.ToArg()); +} + +/// +/// Creates a new project, configuration file, or solution based on the specified template. +///

+/// 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. +///

+///
.NET CLI command
+/// +/// +/// using HostApi; +/// +/// new DotNetNew() +/// .WithTemplateName("classlib") +/// .WithName("MyLib") +/// .WithForce(true) +/// .Run().EnsureSuccess(); +/// +/// +///
+/// 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. +/// Overrides the tool executable path. +/// Specifies the working directory for the tool to be started. +/// The template to instantiate when the command is invoked. Each template might have specific options you can pass. +/// 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. +/// 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. +/// 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. +/// The name for the created output. If no name is specified, the name of the current directory is used. +/// 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. +/// Disables checking for template package updates when instantiating a template. Available since .NET SDK 6.0.100. +/// Location to place the generated output. The default is the current directory. +/// Doesn't execute an implicit restore when running the command. +/// 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. +/// Sets the verbosity level of the command. Allowed values are , , , , and . The default is . For more information, see . +/// Enables diagnostic output. +/// Specifies a short name for this operation. +[Target] +public partial record DotNetNew( + IEnumerable Args, + IEnumerable<(string name, string value)> Vars, + string TemplateName = "", + bool? DryRun = default, + bool? Force = default, + DotNetLanguage? Language = default, + string Name = "", + string Framework = "", + bool? NoUpdateCheck = default, + string Output = "", + bool? NoRestore = default, + string Project = "", + DotNetVerbosity? Verbosity = default, + bool? Diagnostics = default, + string ExecutablePath = "", + string WorkingDirectory = "", + string ShortName = "") +{ + /// + /// Create a new instance of the command. + /// + /// Specifies the set of command line arguments to use when starting the tool. + public DotNetNew(params string[] args) + : this(args, []) + { + } + + /// + /// Create a new instance of the command. + /// + public DotNetNew() + : this([], []) + { + } + + /// + public IStartInfo GetStartInfo(IHost host) + { + if (host == null) throw new ArgumentNullException(nameof(host)); + return host.CreateCommandLine(ExecutablePath) + .WithShortName(ToString()) + .WithWorkingDirectory(WorkingDirectory) + .WithVars(Vars.ToArray()) + .AddArgs("new") + .AddNotEmptyArgs(TemplateName.ToArg()) + .AddArgs(Language.ToArgs("--language", "")) + .AddArgs(Name.ToArgs("--name", "")) + .AddArgs(Framework.ToArgs("--framework", "")) + .AddArgs(Output.ToArgs("--output", "")) + .AddArgs(Project.ToArgs("--project", "")) + .AddArgs(Verbosity.ToArgs("--verbosity", "")) + .AddBooleanArgs( + ("--dry-run", DryRun), + ("--force", Force), + ("-no-update-check", NoUpdateCheck), + ("--no-restore", NoRestore), + ("--diagnostics", Diagnostics) + ) + .AddArgs(Args.ToArray()); + } + + /// + public override string ToString() => (ExecutablePath == string.Empty ? "dotnet" : Path.GetFileNameWithoutExtension(ExecutablePath)).GetShortName("Creates a new project, configuration file, or solution based on the specified template.", ShortName, "new", TemplateName.ToArg()); +} + +/// +/// Lists available templates to be run using dotnet new. +///

+/// 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. +///

+///
.NET CLI command
+/// +/// +/// using HostApi; +/// +/// new DotNetNewList() +/// .Run().EnsureSuccess(); +/// +/// +///
+/// 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. +/// Columns to display in the output. +/// Overrides the tool executable path. +/// Specifies the working directory for the tool to be started. +/// If the argument is specified, only the templates containing TEMPLATE_NAME in template name or short name will be shown. +/// Filters templates based on template author. Partial match is supported. Available since .NET SDK 5.0.300. +/// Displays all columns in the output. Available since .NET SDK 5.0.300. +/// Disables checking if the template meets the constraints to be run. Available since .NET SDK 7.0.100. +/// Filters templates based on language supported by the template. The language accepted varies by the template. Not valid for some templates. +/// 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. +/// 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. +/// 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. +/// Filters templates based on template type. +/// Sets the verbosity level of the command. Allowed values are , , , , and . The default is . For more information, see . +/// Enables diagnostic output. +/// Specifies a short name for this operation. +[Target] +public partial record DotNetNewList( + IEnumerable Args, + IEnumerable<(string name, string value)> Vars, + IEnumerable Columns, + string TemplateName = "", + string Author = "", + bool? ColumnsAll = default, + bool? IgnoreConstraints = default, + DotNetLanguage? Language = default, + string Output = "", + string Project = "", + string Tag = "", + DotNetTemplateType? Type = default, + DotNetVerbosity? Verbosity = default, + bool? Diagnostics = default, + string ExecutablePath = "", + string WorkingDirectory = "", + string ShortName = "") +{ + /// + /// Create a new instance of the command. + /// + /// Specifies the set of command line arguments to use when starting the tool. + public DotNetNewList(params string[] args) + : this(args, [], []) + { + } + + /// + /// Create a new instance of the command. + /// + public DotNetNewList() + : this([], [], []) + { + } + + /// + public IStartInfo GetStartInfo(IHost host) + { + if (host == null) throw new ArgumentNullException(nameof(host)); + return host.CreateCommandLine(ExecutablePath) + .WithShortName(ToString()) + .WithWorkingDirectory(WorkingDirectory) + .WithVars(Vars.ToArray()) + .AddArgs("new") + .AddArgs("list") + .AddNotEmptyArgs(TemplateName.ToArg()) + .AddArgs(Columns.ToArgs("--columns", "")) + .AddArgs(Author.ToArgs("--author", "")) + .AddArgs(Language.ToArgs("--language", "")) + .AddArgs(Output.ToArgs("--output", "")) + .AddArgs(Project.ToArgs("--project", "")) + .AddArgs(Tag.ToArgs("--tag", "")) + .AddArgs(Type.ToArgs("--type", "")) + .AddArgs(Verbosity.ToArgs("--verbosity", "")) + .AddBooleanArgs( + ("--columns-all", ColumnsAll), + ("--ignore-constraints", IgnoreConstraints), + ("--diagnostics", Diagnostics) + ) + .AddArgs(Args.ToArray()); + } + + /// + public override string ToString() => (ExecutablePath == string.Empty ? "dotnet" : Path.GetFileNameWithoutExtension(ExecutablePath)).GetShortName("Lists available templates to be run using dotnet new.", ShortName, "new", "list", TemplateName.ToArg()); +} + +/// +/// Searches for the templates supported by dotnet new on NuGet.org. +///

+/// 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. +///

+///
.NET CLI command
+/// +/// +/// using HostApi; +/// +/// new DotNetNewSearch() +/// .WithTemplateName("build") +/// .Run().EnsureSuccess(); +/// +/// +///
+/// 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. +/// Columns to display in the output. +/// Overrides the tool executable path. +/// Specifies the working directory for the tool to be started. +/// If the argument is specified, only the templates containing TEMPLATE_NAME in template name or short name will be shown. +/// Filters templates based on template author. Partial match is supported. Available since .NET SDK 5.0.300. +/// Displays all columns in the output. Available since .NET SDK 5.0.300. +/// Filters templates based on language supported by the template. +/// Filters templates based on NuGet package ID. A partial match is supported. +/// Filters templates based on template tags. To be selected, a template must have at least one tag that exactly matches the criteria. +/// Filters templates based on template type. +/// Sets the verbosity level of the command. Allowed values are , , , , and . The default is . For more information, see . +/// Enables diagnostic output. +/// Specifies a short name for this operation. +[Target] +public partial record DotNetNewSearch( + IEnumerable Args, + IEnumerable<(string name, string value)> Vars, + IEnumerable Columns, + string TemplateName = "", + string Author = "", + bool? ColumnsAll = default, + DotNetLanguage? Language = default, + string Package = "", + string Tag = "", + DotNetTemplateType? Type = default, + DotNetVerbosity? Verbosity = default, + bool? Diagnostics = default, + string ExecutablePath = "", + string WorkingDirectory = "", + string ShortName = "") +{ + /// + /// Create a new instance of the command. + /// + /// Specifies the set of command line arguments to use when starting the tool. + public DotNetNewSearch(params string[] args) + : this(args, [], []) + { + } + + /// + /// Create a new instance of the command. + /// + public DotNetNewSearch() + : this([], [], []) + { + } + + /// + public IStartInfo GetStartInfo(IHost host) + { + if (host == null) throw new ArgumentNullException(nameof(host)); + return host.CreateCommandLine(ExecutablePath) + .WithShortName(ToString()) + .WithWorkingDirectory(WorkingDirectory) + .WithVars(Vars.ToArray()) + .AddArgs("new") + .AddArgs("search") + .AddNotEmptyArgs(TemplateName.ToArg()) + .AddArgs(Columns.ToArgs("--columns", "")) + .AddArgs(Author.ToArgs("--author", "")) + .AddArgs(Language.ToArgs("--language", "")) + .AddArgs(Package.ToArgs("--package", "")) + .AddArgs(Tag.ToArgs("--tag", "")) + .AddArgs(Type.ToArgs("--type", "")) + .AddArgs(Verbosity.ToArgs("--verbosity", "")) + .AddBooleanArgs( + ("--columns-all", ColumnsAll), + ("--diagnostics", Diagnostics) + ) + .AddArgs(Args.ToArray()); + } + + /// + public override string ToString() => (ExecutablePath == string.Empty ? "dotnet" : Path.GetFileNameWithoutExtension(ExecutablePath)).GetShortName("Searches for the templates supported by dotnet new on NuGet.org.", ShortName, "new", "search", TemplateName.ToArg()); +} + +/// +/// Displays template package metadata. +///

+/// 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. +///

+///
.NET CLI command
+/// +/// +/// using HostApi; +/// +/// new DotNetNewDetails() +/// .WithTemplateName("CSharpInteractive.Templates") +/// .Run().EnsureSuccess(); +/// +/// +///
+/// 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. +/// The URI of the NuGet package source to use during this operation. +/// Overrides the tool executable path. +/// Specifies the working directory for the tool to be started. +/// If the argument is specified, only the templates containing TEMPLATE_NAME in template name or short name will be shown. +/// 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. +/// Sets the verbosity level of the command. Allowed values are , , , , and . The default is . For more information, see . +/// Enables diagnostic output. +/// Specifies a short name for this operation. +[Target] +public partial record DotNetNewDetails( + IEnumerable Args, + IEnumerable<(string name, string value)> Vars, + IEnumerable Sources, + string TemplateName = "", + bool? Force = default, + DotNetVerbosity? Verbosity = default, + bool? Diagnostics = default, + string ExecutablePath = "", + string WorkingDirectory = "", + string ShortName = "") +{ + /// + /// Create a new instance of the command. + /// + /// Specifies the set of command line arguments to use when starting the tool. + public DotNetNewDetails(params string[] args) + : this(args, [], []) + { + } + + /// + /// Create a new instance of the command. + /// + public DotNetNewDetails() + : this([], [], []) + { + } + + /// + public IStartInfo GetStartInfo(IHost host) + { + if (host == null) throw new ArgumentNullException(nameof(host)); + return host.CreateCommandLine(ExecutablePath) + .WithShortName(ToString()) + .WithWorkingDirectory(WorkingDirectory) + .WithVars(Vars.ToArray()) + .AddArgs("new") + .AddArgs("details") + .AddNotEmptyArgs(TemplateName.ToArg()) + .AddArgs(Sources.ToArgs("--add-source", "")) + .AddArgs(Verbosity.ToArgs("--verbosity", "")) + .AddBooleanArgs( + ("--force", Force), + ("--diagnostics", Diagnostics) + ) + .AddArgs(Args.ToArray()); + } + + /// + public override string ToString() => (ExecutablePath == string.Empty ? "dotnet" : Path.GetFileNameWithoutExtension(ExecutablePath)).GetShortName("Displays template package metadata.", ShortName, "new", "details", TemplateName.ToArg()); +} + +/// +/// Installs a template package. +///

+/// 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. +///

+///
.NET CLI command
+/// +/// +/// using HostApi; +/// +/// new DotNetNewInstall() +/// .WithPackage("Pure.DI.Templates") +/// .Run().EnsureSuccess(); +/// +/// +///
+/// 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. +/// The URI of the NuGet package source to use during this operation. +/// Overrides the tool executable path. +/// Specifies the working directory for the tool to be started. +/// 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>. +/// 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. +/// Sets the verbosity level of the command. Allowed values are , , , , and . The default is . For more information, see . +/// Enables diagnostic output. +/// Specifies a short name for this operation. +[Target] +public partial record DotNetNewInstall( + IEnumerable Args, + IEnumerable<(string name, string value)> Vars, + IEnumerable Sources, + string Package = "", + bool? Force = default, + DotNetVerbosity? Verbosity = default, + bool? Diagnostics = default, + string ExecutablePath = "", + string WorkingDirectory = "", + string ShortName = "") +{ + /// + /// Create a new instance of the command. + /// + /// Specifies the set of command line arguments to use when starting the tool. + public DotNetNewInstall(params string[] args) + : this(args, [], []) + { + } + + /// + /// Create a new instance of the command. + /// + public DotNetNewInstall() + : this([], [], []) + { + } + + /// + public IStartInfo GetStartInfo(IHost host) + { + if (host == null) throw new ArgumentNullException(nameof(host)); + return host.CreateCommandLine(ExecutablePath) + .WithShortName(ToString()) + .WithWorkingDirectory(WorkingDirectory) + .WithVars(Vars.ToArray()) + .AddArgs("new") + .AddArgs("install") + .AddNotEmptyArgs(Package.ToArg()) + .AddArgs(Sources.ToArgs("--add-source", "")) + .AddArgs(Verbosity.ToArgs("--verbosity", "")) + .AddBooleanArgs( + ("--force", Force), + ("--diagnostics", Diagnostics) + ) + .AddArgs(Args.ToArray()); + } + + /// + public override string ToString() => (ExecutablePath == string.Empty ? "dotnet" : Path.GetFileNameWithoutExtension(ExecutablePath)).GetShortName("Installs a template package.", ShortName, "new", "install", Package.ToArg()); +} + +/// +/// Uninstalls a template package. +///

+/// 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. +///

+///
.NET CLI command
+/// +/// +/// using HostApi; +/// +/// new DotNetNewUninstall() +/// .WithPackage("Pure.DI.Templates") +/// .Run(); +/// +/// +///
+/// 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. +/// Overrides the tool executable path. +/// Specifies the working directory for the tool to be started. +/// 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. +/// Sets the verbosity level of the command. Allowed values are , , , , and . The default is . For more information, see . +/// Enables diagnostic output. +/// Specifies a short name for this operation. +[Target] +public partial record DotNetNewUninstall( + IEnumerable Args, + IEnumerable<(string name, string value)> Vars, + string Package = "", + DotNetVerbosity? Verbosity = default, + bool? Diagnostics = default, + string ExecutablePath = "", + string WorkingDirectory = "", + string ShortName = "") +{ + /// + /// Create a new instance of the command. + /// + /// Specifies the set of command line arguments to use when starting the tool. + public DotNetNewUninstall(params string[] args) + : this(args, []) + { + } + + /// + /// Create a new instance of the command. + /// + public DotNetNewUninstall() + : this([], []) + { + } + + /// + public IStartInfo GetStartInfo(IHost host) + { + if (host == null) throw new ArgumentNullException(nameof(host)); + return host.CreateCommandLine(ExecutablePath) + .WithShortName(ToString()) + .WithWorkingDirectory(WorkingDirectory) + .WithVars(Vars.ToArray()) + .AddArgs("new") + .AddArgs("uninstall") + .AddNotEmptyArgs(Package.ToArg()) + .AddArgs(Verbosity.ToArgs("--verbosity", "")) + .AddBooleanArgs( + ("--diagnostics", Diagnostics) + ) + .AddArgs(Args.ToArray()); + } + + /// + public override string ToString() => (ExecutablePath == string.Empty ? "dotnet" : Path.GetFileNameWithoutExtension(ExecutablePath)).GetShortName("Uninstalls a template package.", ShortName, "new", "uninstall", Package.ToArg()); +} + +/// +/// Updates installed template packages. +///

+/// 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. +///

+///
.NET CLI command
+/// +/// +/// using HostApi; +/// +/// new DotNetNewUpdate() +/// .Run().EnsureSuccess(); +/// +/// +///
+/// 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. +/// The URI of the NuGet package source to use during this operation. +/// Overrides the tool executable path. +/// Specifies the working directory for the tool to be started. +/// Only checks for updates and displays the template packages to be updated, without applying any updates. +/// Only checks for updates and displays the template packages to be updated, without applying any updates. +/// Sets the verbosity level of the command. Allowed values are , , , , and . The default is . For more information, see . +/// Enables diagnostic output. +/// Specifies a short name for this operation. +[Target] +public partial record DotNetNewUpdate( + IEnumerable Args, + IEnumerable<(string name, string value)> Vars, + IEnumerable Sources, + bool? CheckOnly = default, + bool? DryRun = default, + DotNetVerbosity? Verbosity = default, + bool? Diagnostics = default, + string ExecutablePath = "", + string WorkingDirectory = "", + string ShortName = "") +{ + /// + /// Create a new instance of the command. + /// + /// Specifies the set of command line arguments to use when starting the tool. + public DotNetNewUpdate(params string[] args) + : this(args, [], []) + { + } + + /// + /// Create a new instance of the command. + /// + public DotNetNewUpdate() + : this([], [], []) + { + } + + /// + public IStartInfo GetStartInfo(IHost host) + { + if (host == null) throw new ArgumentNullException(nameof(host)); + return host.CreateCommandLine(ExecutablePath) + .WithShortName(ToString()) + .WithWorkingDirectory(WorkingDirectory) + .WithVars(Vars.ToArray()) + .AddArgs("new") + .AddArgs("update") + .AddArgs(Sources.ToArgs("--add-source", "")) + .AddArgs(Verbosity.ToArgs("--verbosity", "")) + .AddBooleanArgs( + ("--check-only", CheckOnly), + ("--dry-run", DryRun), + ("--diagnostics", Diagnostics) + ) + .AddArgs(Args.ToArray()); + } + + /// + public override string ToString() => (ExecutablePath == string.Empty ? "dotnet" : Path.GetFileNameWithoutExtension(ExecutablePath)).GetShortName("Updates installed template packages.", ShortName, "new", "update"); +} + +/// +/// Deletes or unlists a package from the server. +///

+/// This command deletes or unlists a package from the server. For nuget.org, the action is to unlist the package. +///

+///
.NET CLI command
+/// +/// +/// using HostApi; +/// +/// new DotNetNuGetDelete() +/// .WithPackage("MyLib") +/// .WithPackageVersion("1.0.0") +/// .WithSource(repoUrl) +/// .Run().EnsureSuccess(); +/// +/// +///
+/// 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. +/// Overrides the tool executable path. +/// Specifies the working directory for the tool to be started. +/// Name/ID of the package to delete. +/// Version of the package to delete. +/// Forces the application to run using an invariant, English-based culture. +/// The API key for the server. +/// Doesn't append "api/v2/package" to the source URL. +/// Specifies the server URL. NuGet identifies a UNC or local folder source and simply copies the file there instead of pushing it using HTTP. +/// Enables diagnostic output. +/// Specifies a short name for this operation. +[Target] +public partial record DotNetNuGetDelete( + IEnumerable Args, + IEnumerable<(string name, string value)> Vars, + string Package = "", + string PackageVersion = "", + bool? ForceEnglishOutput = default, + string ApiKey = "", + bool? NoServiceEndpoint = default, + string Source = "", + bool? Diagnostics = default, + string ExecutablePath = "", + string WorkingDirectory = "", + string ShortName = "") +{ + /// + /// Create a new instance of the command. + /// + /// Specifies the set of command line arguments to use when starting the tool. + public DotNetNuGetDelete(params string[] args) + : this(args, []) + { + } + + /// + /// Create a new instance of the command. + /// + public DotNetNuGetDelete() + : this([], []) + { + } + + /// + public IStartInfo GetStartInfo(IHost host) + { + if (host == null) throw new ArgumentNullException(nameof(host)); + return host.CreateCommandLine(ExecutablePath) + .WithShortName(ToString()) + .WithWorkingDirectory(WorkingDirectory) + .WithVars(Vars.ToArray()) + .AddArgs("nuget") + .AddArgs("delete") + .AddNotEmptyArgs(Package.ToArg()) + .AddNotEmptyArgs(PackageVersion.ToArg()) + .AddArgs("--non-interactive") + .AddArgs(ApiKey.ToArgs("--api-key", "")) + .AddArgs(Source.ToArgs("--source", "")) + .AddBooleanArgs( + ("--force-english-output", ForceEnglishOutput), + ("--no-service-endpoint", NoServiceEndpoint), + ("--diagnostics", Diagnostics) + ) + .AddArgs(Args.ToArray()); + } + + /// + public override string ToString() => (ExecutablePath == string.Empty ? "dotnet" : Path.GetFileNameWithoutExtension(ExecutablePath)).GetShortName("Deletes or unlists a package from the server.", ShortName, "nuget", "delete", Package.ToArg(), PackageVersion.ToArg()); +} + +/// +/// Clears local NuGet resources. +///

+/// This command clears local NuGet resources in the http-request cache, temporary cache, or machine-wide global packages folder. +///

+///
.NET CLI command
+/// +/// +/// using HostApi; +/// +/// new DotNetNuGetLocalsClear() +/// .WithCacheLocation(NuGetCacheLocation.Temp) +/// .Run().EnsureSuccess(); +/// +/// +///
+/// 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. +/// Overrides the tool executable path. +/// Specifies the working directory for the tool to be started. +/// The cache location to clear. +/// Forces the application to run using an invariant, English-based culture. +/// Enables diagnostic output. +/// Specifies a short name for this operation. +[Target] +public partial record DotNetNuGetLocalsClear( + IEnumerable Args, + IEnumerable<(string name, string value)> Vars, + NuGetCacheLocation? CacheLocation = default, + bool? ForceEnglishOutput = default, + bool? Diagnostics = default, + string ExecutablePath = "", + string WorkingDirectory = "", + string ShortName = "") +{ + /// + /// Create a new instance of the command. + /// + /// Specifies the set of command line arguments to use when starting the tool. + public DotNetNuGetLocalsClear(params string[] args) + : this(args, []) + { + } + + /// + /// Create a new instance of the command. + /// + public DotNetNuGetLocalsClear() + : this([], []) + { + } + + /// + public IStartInfo GetStartInfo(IHost host) + { + if (host == null) throw new ArgumentNullException(nameof(host)); + return host.CreateCommandLine(ExecutablePath) + .WithShortName(ToString()) + .WithWorkingDirectory(WorkingDirectory) + .WithVars(Vars.ToArray()) + .AddArgs("nuget") + .AddArgs("locals") + .AddNotEmptyArgs(CacheLocation.ToArg()) + .AddArgs("--clear") + .AddBooleanArgs( + ("--force-english-output", ForceEnglishOutput), + ("--diagnostics", Diagnostics) + ) + .AddArgs(Args.ToArray()); + } + + /// + public override string ToString() => (ExecutablePath == string.Empty ? "dotnet" : Path.GetFileNameWithoutExtension(ExecutablePath)).GetShortName("Clears local NuGet resources.", ShortName, "nuget", "locals", CacheLocation.ToArg()); +} + +/// +/// Displays the location of the specified cache type. +///
.NET CLI command
+/// +/// +/// using HostApi; +/// +/// new DotNetNuGetLocalsList() +/// .WithCacheLocation(NuGetCacheLocation.GlobalPackages) +/// .Run().EnsureSuccess(); +/// +/// +///
+/// 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. +/// Overrides the tool executable path. +/// Specifies the working directory for the tool to be started. +/// The cache location to list. +/// Forces the application to run using an invariant, English-based culture. +/// Enables diagnostic output. +/// Specifies a short name for this operation. +[Target] +public partial record DotNetNuGetLocalsList( + IEnumerable Args, + IEnumerable<(string name, string value)> Vars, + NuGetCacheLocation? CacheLocation = default, + bool? ForceEnglishOutput = default, + bool? Diagnostics = default, + string ExecutablePath = "", + string WorkingDirectory = "", + string ShortName = "") +{ + /// + /// Create a new instance of the command. + /// + /// Specifies the set of command line arguments to use when starting the tool. + public DotNetNuGetLocalsList(params string[] args) + : this(args, []) + { + } + + /// + /// Create a new instance of the command. + /// + public DotNetNuGetLocalsList() + : this([], []) + { + } + + /// + public IStartInfo GetStartInfo(IHost host) + { + if (host == null) throw new ArgumentNullException(nameof(host)); + return host.CreateCommandLine(ExecutablePath) + .WithShortName(ToString()) + .WithWorkingDirectory(WorkingDirectory) + .WithVars(Vars.ToArray()) + .AddArgs("nuget") + .AddArgs("locals") + .AddNotEmptyArgs(CacheLocation.ToArg()) + .AddArgs("--list") + .AddBooleanArgs( + ("--force-english-output", ForceEnglishOutput), + ("--diagnostics", Diagnostics) + ) + .AddArgs(Args.ToArray()); + } + + /// + public override string ToString() => (ExecutablePath == string.Empty ? "dotnet" : Path.GetFileNameWithoutExtension(ExecutablePath)).GetShortName("Displays the location of the specified cache type.", ShortName, "nuget", "locals", CacheLocation.ToArg()); +} + +/// +/// Pushes a package to the server and publishes it. +///

+/// 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. +///

+///
.NET CLI command
+/// +/// +/// using HostApi; +/// +/// new DotNetNuGetPush() +/// .WithWorkingDirectory("MyLib") +/// .WithPackage(Path.Combine("packages", "MyLib.1.0.0.nupkg")) +/// .WithSource(repoUrl) +/// .Run().EnsureSuccess(); +/// +/// +///
+/// 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. +/// Overrides the tool executable path. +/// Specifies the working directory for the tool to be started. +/// Specifies the file path to the package to be pushed. +/// Disables buffering when pushing to an HTTP(S) server to reduce memory usage. +/// Forces the application to run using an invariant, English-based culture. +/// The API key for the server. +/// Doesn't push symbols (even if present). +/// Doesn't append "api/v2/package" to the source URL. +/// Specifies the server URL. NuGet identifies a UNC or local folder source and simply copies the file there instead of pushing it using HTTP. +/// When pushing multiple packages to an HTTP(S) server, treats any 409 Conflict response as a warning so that other pushes can continue. +/// The API key for the symbol server. +/// Specifies the symbol server URL. +/// Specifies the timeout for pushing to a server in seconds. Defaults to 300 seconds (5 minutes). Specifying 0 applies the default value. +/// Sets the verbosity level of the command. Allowed values are , , , , and . The default is . For more information, see . +/// Enables diagnostic output. +/// Specifies a short name for this operation. +[Target] +public partial record DotNetNuGetPush( + IEnumerable Args, + IEnumerable<(string name, string value)> Vars, + string Package = "", + bool? DisableBuffering = default, + bool? ForceEnglishOutput = default, + string ApiKey = "", + bool? NoSymbols = default, + bool? NoServiceEndpoint = default, + string Source = "", + bool? SkipDuplicate = default, + string SymbolApiKey = "", + string SymbolSource = "", + int? Timeout = default, + DotNetVerbosity? Verbosity = default, + bool? Diagnostics = default, + string ExecutablePath = "", + string WorkingDirectory = "", + string ShortName = "") +{ + /// + /// Create a new instance of the command. + /// + /// Specifies the set of command line arguments to use when starting the tool. + public DotNetNuGetPush(params string[] args) + : this(args, []) + { + } + + /// + /// Create a new instance of the command. + /// + public DotNetNuGetPush() + : this([], []) + { + } + + /// + public IStartInfo GetStartInfo(IHost host) + { + if (host == null) throw new ArgumentNullException(nameof(host)); + return host.CreateCommandLine(ExecutablePath) + .WithShortName(ToString()) + .WithWorkingDirectory(WorkingDirectory) + .WithVars(Vars.ToArray()) + .AddArgs("nuget") + .AddArgs("push") + .AddNotEmptyArgs(Package.ToArg()) + .AddArgs(ApiKey.ToArgs("--api-key", "")) + .AddArgs(Source.ToArgs("--source", "")) + .AddArgs(SymbolApiKey.ToArgs("--symbol-api-key", "")) + .AddArgs(SymbolSource.ToArgs("--symbol-source", "")) + .AddArgs(Timeout.ToArgs("--timeout", "")) + .AddArgs(Verbosity.ToArgs("--verbosity", "")) + .AddBooleanArgs( + ("--disable-buffering", DisableBuffering), + ("--force-english-output", ForceEnglishOutput), + ("--no-symbols", NoSymbols), + ("--no-service-endpoint", NoServiceEndpoint), + ("--skip-duplicate", SkipDuplicate), + ("--diagnostics", Diagnostics) + ) + .AddArgs(Args.ToArray()); + } + + /// + public override string ToString() => (ExecutablePath == string.Empty ? "dotnet" : Path.GetFileNameWithoutExtension(ExecutablePath)).GetShortName("Pushes a package to the server and publishes it.", ShortName, "nuget", "push", Package.ToArg()); +} + +/// +/// Add a NuGet source. +///

+/// 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. +///

+///
.NET CLI command
+/// +/// +/// using HostApi; +/// +/// new DotNetNuGetAddSource() +/// .WithName("TestSource") +/// .WithSource(source) +/// .Run().EnsureSuccess(); +/// +/// +///
+/// 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. +/// 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. +/// Overrides the tool executable path. +/// Specifies the working directory for the tool to be started. +/// Path to the package source. +/// 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. +/// Allows HTTP connections for adding or updating packages. This method is not secure. Available since .NET 9 SDK. +/// Name of the source. +/// Password to be used when connecting to an authenticated source. +/// Enables storing portable package source credentials by disabling password encryption. Storing passwords in clear text is strongly discouraged. +/// Username to be used when connecting to an authenticated source. +/// Enables diagnostic output. +/// Specifies a short name for this operation. +[Target] +public partial record DotNetNuGetAddSource( + IEnumerable Args, + IEnumerable<(string name, string value)> Vars, + IEnumerable ValidAuthenticationTypes, + string Source = "", + string ConfigFile = "", + bool? AllowInsecureConnections = default, + string Name = "", + string Password = "", + bool? StorePasswordInClearText = default, + string Username = "", + bool? Diagnostics = default, + string ExecutablePath = "", + string WorkingDirectory = "", + string ShortName = "") +{ + /// + /// Create a new instance of the command. + /// + /// Specifies the set of command line arguments to use when starting the tool. + public DotNetNuGetAddSource(params string[] args) + : this(args, [], []) + { + } + + /// + /// Create a new instance of the command. + /// + public DotNetNuGetAddSource() + : this([], [], []) + { + } + + /// + public IStartInfo GetStartInfo(IHost host) + { + if (host == null) throw new ArgumentNullException(nameof(host)); + return host.CreateCommandLine(ExecutablePath) + .WithShortName(ToString()) + .WithWorkingDirectory(WorkingDirectory) + .WithVars(Vars.ToArray()) + .AddArgs("nuget") + .AddArgs("add") + .AddArgs("source") + .AddNotEmptyArgs(Source.ToArg()) + .AddArgs(ValidAuthenticationTypes.ToArgs("--valid-authentication-types", "")) + .AddArgs(ConfigFile.ToArgs("--configfile", "")) + .AddArgs(Name.ToArgs("--name", "")) + .AddArgs(Password.ToArgs("--password", "")) + .AddArgs(Username.ToArgs("--username", "")) + .AddBooleanArgs( + ("--allow-insecure-connections", AllowInsecureConnections), + ("--store-password-in-clear-text", StorePasswordInClearText), + ("--diagnostics", Diagnostics) + ) + .AddArgs(Args.ToArray()); + } + + /// + public override string ToString() => (ExecutablePath == string.Empty ? "dotnet" : Path.GetFileNameWithoutExtension(ExecutablePath)).GetShortName("Add a NuGet source.", ShortName, "nuget", "add", "source", Source.ToArg()); +} + +/// +/// Disable a NuGet source. +///

+/// This command disables an existing source in your NuGet configuration files. +///

+///
.NET CLI command
+/// +/// +/// using HostApi; +/// +/// new DotNetNuGetDisableSource() +/// .WithName("TestSource") +/// .Run().EnsureSuccess(); +/// +/// +///
+/// 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. +/// Overrides the tool executable path. +/// Specifies the working directory for the tool to be started. +/// Name of the source. +/// 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. +/// Enables diagnostic output. +/// Specifies a short name for this operation. +[Target] +public partial record DotNetNuGetDisableSource( + IEnumerable Args, + IEnumerable<(string name, string value)> Vars, + string Name = "", + string ConfigFile = "", + bool? Diagnostics = default, + string ExecutablePath = "", + string WorkingDirectory = "", + string ShortName = "") +{ + /// + /// Create a new instance of the command. + /// + /// Specifies the set of command line arguments to use when starting the tool. + public DotNetNuGetDisableSource(params string[] args) + : this(args, []) + { + } + + /// + /// Create a new instance of the command. + /// + public DotNetNuGetDisableSource() + : this([], []) + { + } + + /// + public IStartInfo GetStartInfo(IHost host) + { + if (host == null) throw new ArgumentNullException(nameof(host)); + return host.CreateCommandLine(ExecutablePath) + .WithShortName(ToString()) + .WithWorkingDirectory(WorkingDirectory) + .WithVars(Vars.ToArray()) + .AddArgs("nuget") + .AddArgs("disable") + .AddArgs("source") + .AddNotEmptyArgs(Name.ToArg()) + .AddArgs(ConfigFile.ToArgs("--configfile", "")) + .AddBooleanArgs( + ("--diagnostics", Diagnostics) + ) + .AddArgs(Args.ToArray()); + } + + /// + public override string ToString() => (ExecutablePath == string.Empty ? "dotnet" : Path.GetFileNameWithoutExtension(ExecutablePath)).GetShortName("Disable a NuGet source.", ShortName, "nuget", "disable", "source", Name.ToArg()); +} + +/// +/// Enable a NuGet source. +///

+/// This command enables an existing source in your NuGet configuration files. +///

+///
.NET CLI command
+/// +/// +/// using HostApi; +/// +/// new DotNetNuGetEnableSource() +/// .WithName("TestSource") +/// .Run().EnsureSuccess(); +/// +/// +///
+/// 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. +/// Overrides the tool executable path. +/// Specifies the working directory for the tool to be started. +/// Name of the source. +/// 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. +/// Enables diagnostic output. +/// Specifies a short name for this operation. +[Target] +public partial record DotNetNuGetEnableSource( + IEnumerable Args, + IEnumerable<(string name, string value)> Vars, + string Name = "", + string ConfigFile = "", + bool? Diagnostics = default, + string ExecutablePath = "", + string WorkingDirectory = "", + string ShortName = "") +{ + /// + /// Create a new instance of the command. + /// + /// Specifies the set of command line arguments to use when starting the tool. + public DotNetNuGetEnableSource(params string[] args) + : this(args, []) + { + } + + /// + /// Create a new instance of the command. + /// + public DotNetNuGetEnableSource() + : this([], []) + { + } + + /// + public IStartInfo GetStartInfo(IHost host) + { + if (host == null) throw new ArgumentNullException(nameof(host)); + return host.CreateCommandLine(ExecutablePath) + .WithShortName(ToString()) + .WithWorkingDirectory(WorkingDirectory) + .WithVars(Vars.ToArray()) + .AddArgs("nuget") + .AddArgs("enable") + .AddArgs("source") + .AddNotEmptyArgs(Name.ToArg()) + .AddArgs(ConfigFile.ToArgs("--configfile", "")) + .AddBooleanArgs( + ("--diagnostics", Diagnostics) + ) + .AddArgs(Args.ToArray()); + } + + /// + public override string ToString() => (ExecutablePath == string.Empty ? "dotnet" : Path.GetFileNameWithoutExtension(ExecutablePath)).GetShortName("Enable a NuGet source.", ShortName, "nuget", "enable", "source", Name.ToArg()); +} + +/// +/// Lists all configured NuGet sources. +///

+/// This command lists all existing sources from your NuGet configuration files. +///

+///
.NET CLI command
+/// +/// +/// using HostApi; +/// +/// new DotNetNuGetListSource() +/// .WithFormat(NuGetListFormat.Short) +/// .Run().EnsureSuccess(); +/// +/// +///
+/// 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. +/// Overrides the tool executable path. +/// Specifies the working directory for the tool to be started. +/// 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. +/// The format of the list command output: Detailed (the default) and Short. +/// Enables diagnostic output. +/// Specifies a short name for this operation. +[Target] +public partial record DotNetNuGetListSource( + IEnumerable Args, + IEnumerable<(string name, string value)> Vars, + string ConfigFile = "", + NuGetListFormat? Format = default, + bool? Diagnostics = default, + string ExecutablePath = "", + string WorkingDirectory = "", + string ShortName = "") +{ + /// + /// Create a new instance of the command. + /// + /// Specifies the set of command line arguments to use when starting the tool. + public DotNetNuGetListSource(params string[] args) + : this(args, []) + { + } + + /// + /// Create a new instance of the command. + /// + public DotNetNuGetListSource() + : this([], []) + { + } + + /// + public IStartInfo GetStartInfo(IHost host) + { + if (host == null) throw new ArgumentNullException(nameof(host)); + return host.CreateCommandLine(ExecutablePath) + .WithShortName(ToString()) + .WithWorkingDirectory(WorkingDirectory) + .WithVars(Vars.ToArray()) + .AddArgs("nuget") + .AddArgs("list") + .AddArgs("source") + .AddArgs(ConfigFile.ToArgs("--configfile", "")) + .AddArgs(Format.ToArgs("--format", "")) + .AddBooleanArgs( + ("--diagnostics", Diagnostics) + ) + .AddArgs(Args.ToArray()); + } + + /// + public override string ToString() => (ExecutablePath == string.Empty ? "dotnet" : Path.GetFileNameWithoutExtension(ExecutablePath)).GetShortName("Lists all configured NuGet sources.", ShortName, "nuget", "list", "source"); +} + +/// +/// Remove a NuGet source. +///

+/// This command removes an existing source from your NuGet configuration files. +///

+///
.NET CLI command
+/// +/// +/// using HostApi; +/// +/// new DotNetNuGetRemoveSource() +/// .WithName("TestSource") +/// .Run().EnsureSuccess(); +/// +/// +///
+/// 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. +/// Overrides the tool executable path. +/// Specifies the working directory for the tool to be started. +/// Name of the source. +/// 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. +/// Enables diagnostic output. +/// Specifies a short name for this operation. +[Target] +public partial record DotNetNuGetRemoveSource( + IEnumerable Args, + IEnumerable<(string name, string value)> Vars, + string Name = "", + string ConfigFile = "", + bool? Diagnostics = default, + string ExecutablePath = "", + string WorkingDirectory = "", + string ShortName = "") +{ + /// + /// Create a new instance of the command. + /// + /// Specifies the set of command line arguments to use when starting the tool. + public DotNetNuGetRemoveSource(params string[] args) + : this(args, []) + { + } + + /// + /// Create a new instance of the command. + /// + public DotNetNuGetRemoveSource() + : this([], []) + { + } + + /// + public IStartInfo GetStartInfo(IHost host) + { + if (host == null) throw new ArgumentNullException(nameof(host)); + return host.CreateCommandLine(ExecutablePath) + .WithShortName(ToString()) + .WithWorkingDirectory(WorkingDirectory) + .WithVars(Vars.ToArray()) + .AddArgs("nuget") + .AddArgs("remove") + .AddArgs("source") + .AddNotEmptyArgs(Name.ToArg()) + .AddArgs(ConfigFile.ToArgs("--configfile", "")) + .AddBooleanArgs( + ("--diagnostics", Diagnostics) + ) + .AddArgs(Args.ToArray()); + } + + /// + public override string ToString() => (ExecutablePath == string.Empty ? "dotnet" : Path.GetFileNameWithoutExtension(ExecutablePath)).GetShortName("Remove a NuGet source.", ShortName, "nuget", "remove", "source", Name.ToArg()); +} + +/// +/// Update a NuGet source. +///

+/// This command updates an existing source in your NuGet configuration files. +///

+///
.NET CLI command
+/// +/// +/// using HostApi; +/// +/// new DotNetNuGetUpdateSource() +/// .WithName("TestSource") +/// .WithSource(newSource) +/// .Run().EnsureSuccess(); +/// +/// +///
+/// 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. +/// 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. +/// Overrides the tool executable path. +/// Specifies the working directory for the tool to be started. +/// Name of the source. +/// 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 to be used when connecting to an authenticated source. +/// Path to the package source. +/// Enables storing portable package source credentials by disabling password encryption. Storing passwords in clear text is strongly discouraged. +/// Username to be used when connecting to an authenticated source. +/// Enables diagnostic output. +/// Specifies a short name for this operation. +[Target] +public partial record DotNetNuGetUpdateSource( + IEnumerable Args, + IEnumerable<(string name, string value)> Vars, + IEnumerable ValidAuthenticationTypes, + string Name = "", + string ConfigFile = "", + string Password = "", + string Source = "", + bool? StorePasswordInClearText = default, + string Username = "", + bool? Diagnostics = default, + string ExecutablePath = "", + string WorkingDirectory = "", + string ShortName = "") +{ + /// + /// Create a new instance of the command. + /// + /// Specifies the set of command line arguments to use when starting the tool. + public DotNetNuGetUpdateSource(params string[] args) + : this(args, [], []) + { + } + + /// + /// Create a new instance of the command. + /// + public DotNetNuGetUpdateSource() + : this([], [], []) + { + } + + /// + public IStartInfo GetStartInfo(IHost host) + { + if (host == null) throw new ArgumentNullException(nameof(host)); + return host.CreateCommandLine(ExecutablePath) + .WithShortName(ToString()) + .WithWorkingDirectory(WorkingDirectory) + .WithVars(Vars.ToArray()) + .AddArgs("nuget") + .AddArgs("update") + .AddArgs("source") + .AddNotEmptyArgs(Name.ToArg()) + .AddArgs(ValidAuthenticationTypes.ToArgs("--valid-authentication-types", "")) + .AddArgs(ConfigFile.ToArgs("--configfile", "")) + .AddArgs(Password.ToArgs("--password", "")) + .AddArgs(Source.ToArgs("--source", "")) + .AddArgs(Username.ToArgs("--username", "")) + .AddBooleanArgs( + ("--store-password-in-clear-text", StorePasswordInClearText), + ("--diagnostics", Diagnostics) + ) + .AddArgs(Args.ToArray()); + } + + /// + public override string ToString() => (ExecutablePath == string.Empty ? "dotnet" : Path.GetFileNameWithoutExtension(ExecutablePath)).GetShortName("Update a NuGet source.", ShortName, "nuget", "update", "source", Name.ToArg()); +} + +/// +/// Verifies a signed NuGet package. +///

+/// 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. +///

+///
.NET CLI command
+///
+/// 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. +/// Specifies the file path to the package(s) to be verified. +/// Verify that the signer certificate matches with one of the specified SHA256 fingerprints. This option can be supplied multiple times to provide multiple fingerprints. +/// Overrides the tool executable path. +/// Specifies the working directory for the tool to be started. +/// Specifies that all verifications possible should be performed on the package(s). By default, only signatures are verified. +/// 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. +/// Sets the verbosity level of the command. Allowed values are , , , , and . The default is . For more information, see . +/// Enables diagnostic output. +/// Specifies a short name for this operation. +[Target] +public partial record DotNetNuGetVerify( + IEnumerable Args, + IEnumerable<(string name, string value)> Vars, + IEnumerable Packages, + IEnumerable Fingerprints, + bool? All = default, + string ConfigFile = "", + DotNetVerbosity? Verbosity = default, + bool? Diagnostics = default, + string ExecutablePath = "", + string WorkingDirectory = "", + string ShortName = "") +{ + /// + /// Create a new instance of the command. + /// + /// Specifies the set of command line arguments to use when starting the tool. + public DotNetNuGetVerify(params string[] args) + : this(args, [], [], []) + { + } + + /// + /// Create a new instance of the command. + /// + public DotNetNuGetVerify() + : this([], [], [], []) + { + } + + /// + public IStartInfo GetStartInfo(IHost host) + { + if (host == null) throw new ArgumentNullException(nameof(host)); + return host.CreateCommandLine(ExecutablePath) + .WithShortName(ToString()) + .WithWorkingDirectory(WorkingDirectory) + .WithVars(Vars.ToArray()) + .AddArgs("nuget") + .AddArgs("verify") + .AddNotEmptyArgs(Packages.ToArray()) + .AddArgs(Packages.ToArgs("", "")) + .AddArgs(Fingerprints.ToArgs("--certificate-fingerprint", "")) + .AddArgs(ConfigFile.ToArgs("--configfile", "")) + .AddArgs(Verbosity.ToArgs("--verbosity", "")) + .AddBooleanArgs( + ("--all", All), + ("--diagnostics", Diagnostics) + ) + .AddArgs(Args.ToArray()); + } + + /// + public override string ToString() => (ExecutablePath == string.Empty ? "dotnet" : Path.GetFileNameWithoutExtension(ExecutablePath)).GetShortName("Verifies a signed NuGet package.", ShortName, new [] {"nuget", "verify"}.Concat(Packages).ToArray()); +} + +/// +/// Lists all the trusted signers in the configuration. +///

+/// 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. +///

+///
.NET CLI command
+///
+/// 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. +/// Overrides the tool executable path. +/// Specifies the working directory for the tool to be started. +/// 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. +/// Sets the verbosity level of the command. Allowed values are , , , , and . The default is . For more information, see . +/// Enables diagnostic output. +/// Specifies a short name for this operation. +[Target] +public partial record DotNetNuGetTrustList( + IEnumerable Args, + IEnumerable<(string name, string value)> Vars, + string ConfigFile = "", + DotNetVerbosity? Verbosity = default, + bool? Diagnostics = default, + string ExecutablePath = "", + string WorkingDirectory = "", + string ShortName = "") +{ + /// + /// Create a new instance of the command. + /// + /// Specifies the set of command line arguments to use when starting the tool. + public DotNetNuGetTrustList(params string[] args) + : this(args, []) + { + } + + /// + /// Create a new instance of the command. + /// + public DotNetNuGetTrustList() + : this([], []) + { + } + + /// + public IStartInfo GetStartInfo(IHost host) + { + if (host == null) throw new ArgumentNullException(nameof(host)); + return host.CreateCommandLine(ExecutablePath) + .WithShortName(ToString()) + .WithWorkingDirectory(WorkingDirectory) + .WithVars(Vars.ToArray()) + .AddArgs("nuget") + .AddArgs("trust") + .AddArgs("list") + .AddArgs(ConfigFile.ToArgs("--configfile", "")) + .AddArgs(Verbosity.ToArgs("--verbosity", "")) + .AddBooleanArgs( + ("--diagnostics", Diagnostics) + ) + .AddArgs(Args.ToArray()); + } + + /// + public override string ToString() => (ExecutablePath == string.Empty ? "dotnet" : Path.GetFileNameWithoutExtension(ExecutablePath)).GetShortName("Lists all the trusted signers in the configuration.", ShortName, "nuget", "trust", "list"); +} + +/// +/// Deletes the current list of certificates and replaces them with an up-to-date list from the repository. +///
.NET CLI command
+///
+/// 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. +/// Overrides the tool executable path. +/// Specifies the working directory for the tool to be started. +/// The name of the existing trusted signer to sync. +/// 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. +/// Sets the verbosity level of the command. Allowed values are , , , , and . The default is . For more information, see . +/// Enables diagnostic output. +/// Specifies a short name for this operation. +[Target] +public partial record DotNetNuGetTrustSync( + IEnumerable Args, + IEnumerable<(string name, string value)> Vars, + string Name = "", + string ConfigFile = "", + DotNetVerbosity? Verbosity = default, + bool? Diagnostics = default, + string ExecutablePath = "", + string WorkingDirectory = "", + string ShortName = "") +{ + /// + /// Create a new instance of the command. + /// + /// Specifies the set of command line arguments to use when starting the tool. + public DotNetNuGetTrustSync(params string[] args) + : this(args, []) + { + } + + /// + /// Create a new instance of the command. + /// + public DotNetNuGetTrustSync() + : this([], []) + { + } + + /// + public IStartInfo GetStartInfo(IHost host) + { + if (host == null) throw new ArgumentNullException(nameof(host)); + return host.CreateCommandLine(ExecutablePath) + .WithShortName(ToString()) + .WithWorkingDirectory(WorkingDirectory) + .WithVars(Vars.ToArray()) + .AddArgs("nuget") + .AddArgs("trust") + .AddArgs("sync") + .AddNotEmptyArgs(Name.ToArg()) + .AddArgs(ConfigFile.ToArgs("--configfile", "")) + .AddArgs(Verbosity.ToArgs("--verbosity", "")) + .AddBooleanArgs( + ("--diagnostics", Diagnostics) + ) + .AddArgs(Args.ToArray()); + } + + /// + public override string ToString() => (ExecutablePath == string.Empty ? "dotnet" : Path.GetFileNameWithoutExtension(ExecutablePath)).GetShortName("Deletes the current list of certificates and replaces them with an up-to-date list from the repository.", ShortName, "nuget", "trust", "sync", Name.ToArg()); +} + +/// +/// Removes any trusted signers that match the given name. +///
.NET CLI command
+///
+/// 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. +/// Overrides the tool executable path. +/// Specifies the working directory for the tool to be started. +/// The name of the existing trusted signer to remove. +/// 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. +/// Sets the verbosity level of the command. Allowed values are , , , , and . The default is . For more information, see . +/// Enables diagnostic output. +/// Specifies a short name for this operation. +[Target] +public partial record DotNetNuGetTrustRemove( + IEnumerable Args, + IEnumerable<(string name, string value)> Vars, + string Name = "", + string ConfigFile = "", + DotNetVerbosity? Verbosity = default, + bool? Diagnostics = default, + string ExecutablePath = "", + string WorkingDirectory = "", + string ShortName = "") +{ + /// + /// Create a new instance of the command. + /// + /// Specifies the set of command line arguments to use when starting the tool. + public DotNetNuGetTrustRemove(params string[] args) + : this(args, []) + { + } + + /// + /// Create a new instance of the command. + /// + public DotNetNuGetTrustRemove() + : this([], []) + { + } + + /// + public IStartInfo GetStartInfo(IHost host) + { + if (host == null) throw new ArgumentNullException(nameof(host)); + return host.CreateCommandLine(ExecutablePath) + .WithShortName(ToString()) + .WithWorkingDirectory(WorkingDirectory) + .WithVars(Vars.ToArray()) + .AddArgs("nuget") + .AddArgs("trust") + .AddArgs("remove") + .AddNotEmptyArgs(Name.ToArg()) + .AddArgs(ConfigFile.ToArgs("--configfile", "")) + .AddArgs(Verbosity.ToArgs("--verbosity", "")) + .AddBooleanArgs( + ("--diagnostics", Diagnostics) + ) + .AddArgs(Args.ToArray()); + } + + /// + public override string ToString() => (ExecutablePath == string.Empty ? "dotnet" : Path.GetFileNameWithoutExtension(ExecutablePath)).GetShortName("Removes any trusted signers that match the given name.", ShortName, "nuget", "trust", "remove", Name.ToArg()); +} + +/// +/// Adds a trusted signer with the given name, based on the author signature of the package. +///
.NET CLI command
+///
+/// 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. +/// Overrides the tool executable path. +/// Specifies the working directory for the tool to be started. +/// The name of the trusted signer to add. If NAME already exists in the configuration, the signature is appended. +/// The given PACKAGE should be a local path to the signed .nupkg file. +/// Specifies if the certificate for the trusted signer should be allowed to chain to an untrusted root. This is not recommended. +/// 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. +/// Sets the verbosity level of the command. Allowed values are , , , , and . The default is . For more information, see . +/// Enables diagnostic output. +/// Specifies a short name for this operation. +[Target] +public partial record DotNetNuGetTrustAuthor( + IEnumerable Args, + IEnumerable<(string name, string value)> Vars, + string Name = "", + string Package = "", + bool? AllowUntrustedRoot = default, + string ConfigFile = "", + DotNetVerbosity? Verbosity = default, + bool? Diagnostics = default, + string ExecutablePath = "", + string WorkingDirectory = "", + string ShortName = "") +{ + /// + /// Create a new instance of the command. + /// + /// Specifies the set of command line arguments to use when starting the tool. + public DotNetNuGetTrustAuthor(params string[] args) + : this(args, []) + { + } + + /// + /// Create a new instance of the command. + /// + public DotNetNuGetTrustAuthor() + : this([], []) + { + } + + /// + public IStartInfo GetStartInfo(IHost host) + { + if (host == null) throw new ArgumentNullException(nameof(host)); + return host.CreateCommandLine(ExecutablePath) + .WithShortName(ToString()) + .WithWorkingDirectory(WorkingDirectory) + .WithVars(Vars.ToArray()) + .AddArgs("nuget") + .AddArgs("trust") + .AddArgs("author") + .AddNotEmptyArgs(Name.ToArg()) + .AddNotEmptyArgs(Package.ToArg()) + .AddArgs(ConfigFile.ToArgs("--configfile", "")) + .AddArgs(Verbosity.ToArgs("--verbosity", "")) + .AddBooleanArgs( + ("--allow-untrusted-root", AllowUntrustedRoot), + ("--diagnostics", Diagnostics) + ) + .AddArgs(Args.ToArray()); + } + + /// + public override string ToString() => (ExecutablePath == string.Empty ? "dotnet" : Path.GetFileNameWithoutExtension(ExecutablePath)).GetShortName("Adds a trusted signer with the given name, based on the author signature of the package.", ShortName, "nuget", "trust", "author", Name.ToArg(), Package.ToArg()); +} + +/// +/// Adds a trusted signer with the given name, based on the repository signature or countersignature of a signed package. +///
.NET CLI command
+///
+/// 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. +/// List of trusted owners to further restrict the trust of a repository. +/// Overrides the tool executable path. +/// Specifies the working directory for the tool to be started. +/// The name of the trusted signer to add. If NAME already exists in the configuration, the signature is appended. +/// The given PACKAGE should be a local path to the signed .nupkg file. +/// Specifies if the certificate for the trusted signer should be allowed to chain to an untrusted root. This is not recommended. +/// 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. +/// Sets the verbosity level of the command. Allowed values are , , , , and . The default is . For more information, see . +/// Enables diagnostic output. +/// Specifies a short name for this operation. +[Target] +public partial record DotNetNuGetTrustRepository( + IEnumerable Args, + IEnumerable<(string name, string value)> Vars, + IEnumerable Owners, + string Name = "", + string Package = "", + bool? AllowUntrustedRoot = default, + string ConfigFile = "", + DotNetVerbosity? Verbosity = default, + bool? Diagnostics = default, + string ExecutablePath = "", + string WorkingDirectory = "", + string ShortName = "") +{ + /// + /// Create a new instance of the command. + /// + /// Specifies the set of command line arguments to use when starting the tool. + public DotNetNuGetTrustRepository(params string[] args) + : this(args, [], []) + { + } + + /// + /// Create a new instance of the command. + /// + public DotNetNuGetTrustRepository() + : this([], [], []) + { + } + + /// + public IStartInfo GetStartInfo(IHost host) + { + if (host == null) throw new ArgumentNullException(nameof(host)); + return host.CreateCommandLine(ExecutablePath) + .WithShortName(ToString()) + .WithWorkingDirectory(WorkingDirectory) + .WithVars(Vars.ToArray()) + .AddArgs("nuget") + .AddArgs("trust") + .AddArgs("repository") + .AddNotEmptyArgs(Name.ToArg()) + .AddNotEmptyArgs(Package.ToArg()) + .AddArgs(Owners.ToArgs("--owners", ",")) + .AddArgs(ConfigFile.ToArgs("--configfile", "")) + .AddArgs(Verbosity.ToArgs("--verbosity", "")) + .AddBooleanArgs( + ("--allow-untrusted-root", AllowUntrustedRoot), + ("--diagnostics", Diagnostics) + ) + .AddArgs(Args.ToArray()); + } + + /// + public override string ToString() => (ExecutablePath == string.Empty ? "dotnet" : Path.GetFileNameWithoutExtension(ExecutablePath)).GetShortName("Adds a trusted signer with the given name, based on the repository signature or countersignature of a signed package.", ShortName, "nuget", "trust", "repository", Name.ToArg(), Package.ToArg()); +} + +/// +/// Adds a trusted signer with the given name, based on a certificate fingerprint. +///
.NET CLI command
+///
+/// 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. +/// Overrides the tool executable path. +/// Specifies the working directory for the tool to be started. +/// 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. +/// The fingerprint of the certificate. +/// Specifies the hash algorithm used to calculate the certificate fingerprint. Defaults to SHA256. Values supported are SHA256, SHA384 and SHA512. +/// Specifies if the certificate for the trusted signer should be allowed to chain to an untrusted root. This is not recommended. +/// 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. +/// Sets the verbosity level of the command. Allowed values are , , , , and . The default is . For more information, see . +/// Enables diagnostic output. +/// Specifies a short name for this operation. +[Target] +public partial record DotNetNuGetTrustCertificate( + IEnumerable Args, + IEnumerable<(string name, string value)> Vars, + string Name = "", + string Fingerprint = "", + NuGetCertificateAlgorithm? Algorithm = default, + bool? AllowUntrustedRoot = default, + string ConfigFile = "", + DotNetVerbosity? Verbosity = default, + bool? Diagnostics = default, + string ExecutablePath = "", + string WorkingDirectory = "", + string ShortName = "") +{ + /// + /// Create a new instance of the command. + /// + /// Specifies the set of command line arguments to use when starting the tool. + public DotNetNuGetTrustCertificate(params string[] args) + : this(args, []) + { + } + + /// + /// Create a new instance of the command. + /// + public DotNetNuGetTrustCertificate() + : this([], []) + { + } + + /// + public IStartInfo GetStartInfo(IHost host) + { + if (host == null) throw new ArgumentNullException(nameof(host)); + return host.CreateCommandLine(ExecutablePath) + .WithShortName(ToString()) + .WithWorkingDirectory(WorkingDirectory) + .WithVars(Vars.ToArray()) + .AddArgs("nuget") + .AddArgs("trust") + .AddArgs("certificate") + .AddNotEmptyArgs(Name.ToArg()) + .AddNotEmptyArgs(Fingerprint.ToArg()) + .AddArgs(Algorithm.ToArgs("--algorithm", "")) + .AddArgs(ConfigFile.ToArgs("--configfile", "")) + .AddArgs(Verbosity.ToArgs("--verbosity", "")) + .AddBooleanArgs( + ("--allow-untrusted-root", AllowUntrustedRoot), + ("--diagnostics", Diagnostics) + ) + .AddArgs(Args.ToArray()); + } + + /// + public override string ToString() => (ExecutablePath == string.Empty ? "dotnet" : Path.GetFileNameWithoutExtension(ExecutablePath)).GetShortName("Adds a trusted signer with the given name, based on a certificate fingerprint.", ShortName, "nuget", "trust", "certificate", Name.ToArg(), Fingerprint.ToArg()); +} + +/// +/// Adds a trusted signer based on a given package source. +///
.NET CLI command
+///
+/// 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. +/// List of trusted owners to further restrict the trust of a repository. +/// Overrides the tool executable path. +/// Specifies the working directory for the tool to be started. +/// 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. +/// 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. +/// 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. +/// Sets the verbosity level of the command. Allowed values are , , , , and . The default is . For more information, see . +/// Enables diagnostic output. +/// Specifies a short name for this operation. +[Target] +public partial record DotNetNuGetTrustSource( + IEnumerable Args, + IEnumerable<(string name, string value)> Vars, + IEnumerable Owners, + string Name = "", + string ConfigFile = "", + string SourceUrl = "", + DotNetVerbosity? Verbosity = default, + bool? Diagnostics = default, + string ExecutablePath = "", + string WorkingDirectory = "", + string ShortName = "") +{ + /// + /// Create a new instance of the command. + /// + /// Specifies the set of command line arguments to use when starting the tool. + public DotNetNuGetTrustSource(params string[] args) + : this(args, [], []) + { + } + + /// + /// Create a new instance of the command. + /// + public DotNetNuGetTrustSource() + : this([], [], []) + { + } + + /// + public IStartInfo GetStartInfo(IHost host) + { + if (host == null) throw new ArgumentNullException(nameof(host)); + return host.CreateCommandLine(ExecutablePath) + .WithShortName(ToString()) + .WithWorkingDirectory(WorkingDirectory) + .WithVars(Vars.ToArray()) + .AddArgs("nuget") + .AddArgs("trust") + .AddArgs("source") + .AddNotEmptyArgs(Name.ToArg()) + .AddArgs(Owners.ToArgs("--owners", ",")) + .AddArgs(ConfigFile.ToArgs("--configfile", "")) + .AddArgs(SourceUrl.ToArgs("--source-url", "")) + .AddArgs(Verbosity.ToArgs("--verbosity", "")) + .AddBooleanArgs( + ("--diagnostics", Diagnostics) + ) + .AddArgs(Args.ToArray()); + } + + /// + public override string ToString() => (ExecutablePath == string.Empty ? "dotnet" : Path.GetFileNameWithoutExtension(ExecutablePath)).GetShortName("Adds a trusted signer based on a given package source.", ShortName, "nuget", "trust", "source", Name.ToArg()); +} + +/// +/// Signs the NuGet packages with a certificate. +///

+/// 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. +///

+///
.NET CLI command
+/// +/// +/// using HostApi; +/// +/// new DotNetNuGetSign() +/// .AddPackages("MyLib.1.2.3.nupkg") +/// .WithCertificatePath("certificate.pfx") +/// .WithCertificatePassword("Abc") +/// .WithTimestampingServer("http://timestamp.digicert.com/") +/// .Run().EnsureSuccess(); +/// +/// +///
+/// 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. +/// Specifies the file path to the packages to be signed. +/// Overrides the tool executable path. +/// Specifies the working directory for the tool to be started. +/// 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. +/// 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. +/// 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. +/// 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. +/// 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. +/// Specifies the certificate password, if needed. If a certificate is password protected but no password is provided, the sign command will fail. +/// Hash algorithm to be used to sign the package. Defaults to SHA256. Possible values are SHA256, SHA384, and SHA512. +/// 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. +/// Indicate that the current signature should be overwritten. By default the command will fail if the package already has a signature. +/// Hash algorithm to be used by the RFC 3161 timestamp server. Defaults to SHA256. +/// URL to an RFC 3161 timestamping server. +/// Sets the verbosity level of the command. Allowed values are , , , , and . The default is . For more information, see . +/// Enables diagnostic output. +/// Specifies a short name for this operation. +[Target] +public partial record DotNetNuGetSign( + IEnumerable Args, + IEnumerable<(string name, string value)> Vars, + IEnumerable Packages, + string CertificatePath = "", + string CertificateStoreName = "", + string CertificateStoreLocation = "", + string CertificateSubjectName = "", + string CertificateFingerprint = "", + string CertificatePassword = "", + NuGetCertificateAlgorithm? HashAlgorithm = default, + string Output = "", + bool? Overwrite = default, + NuGetCertificateAlgorithm? TimestampHashAlgorithm = default, + string TimestampingServer = "", + DotNetVerbosity? Verbosity = default, + bool? Diagnostics = default, + string ExecutablePath = "", + string WorkingDirectory = "", + string ShortName = "") +{ + /// + /// Create a new instance of the command. + /// + /// Specifies the set of command line arguments to use when starting the tool. + public DotNetNuGetSign(params string[] args) + : this(args, [], []) + { + } + + /// + /// Create a new instance of the command. + /// + public DotNetNuGetSign() + : this([], [], []) + { + } + + /// + public IStartInfo GetStartInfo(IHost host) + { + if (host == null) throw new ArgumentNullException(nameof(host)); + return host.CreateCommandLine(ExecutablePath) + .WithShortName(ToString()) + .WithWorkingDirectory(WorkingDirectory) + .WithVars(Vars.ToArray()) + .AddArgs("nuget") + .AddArgs("sign") + .AddNotEmptyArgs(Packages.ToArray()) + .AddArgs(CertificatePath.ToArgs("--certificate-path", "")) + .AddArgs(CertificateStoreName.ToArgs("--certificate-store-name", "")) + .AddArgs(CertificateStoreLocation.ToArgs("--certificate-store-location", "")) + .AddArgs(CertificateSubjectName.ToArgs("--certificate-subject-name", "")) + .AddArgs(CertificateFingerprint.ToArgs("--certificate-fingerprint", "")) + .AddArgs(CertificatePassword.ToArgs("--certificate-password", "")) + .AddArgs(HashAlgorithm.ToArgs("--hash-algorithm", "")) + .AddArgs(Output.ToArgs("--output", "")) + .AddArgs(TimestampHashAlgorithm.ToArgs("--timestamp-hash-algorithm", "")) + .AddArgs(TimestampingServer.ToArgs("--timestamper", "")) + .AddArgs(Verbosity.ToArgs("--verbosity", "")) + .AddBooleanArgs( + ("--overwrite", Overwrite), + ("--diagnostics", Diagnostics) + ) + .AddArgs(Args.ToArray()); + } + + /// + public override string ToString() => (ExecutablePath == string.Empty ? "dotnet" : Path.GetFileNameWithoutExtension(ExecutablePath)).GetShortName("Signs the NuGet packages with a certificate.", ShortName, new [] {"nuget", "sign"}.Concat(Packages).ToArray()); +} + +/// +/// Shows the dependency graph for a particular package. +///

+/// 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. +///

+///
.NET CLI command
+/// +/// +/// using HostApi; +/// +/// new DotNetNuGetWhy() +/// .WithProject(Path.Combine("MyLib", "MyLib.csproj")) +/// .WithPackage("MyLib.1.2.3.nupkg") +/// .Run().EnsureSuccess(); +/// +/// +///
+/// 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. +/// The target frameworks for which dependency graphs are shown. +/// Overrides the tool executable path. +/// Specifies the working directory for the tool to be started. +/// 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. +/// The package name to look up in the dependency graph. +/// Enables diagnostic output. +/// Specifies a short name for this operation. +[Target] +public partial record DotNetNuGetWhy( + IEnumerable Args, + IEnumerable<(string name, string value)> Vars, + IEnumerable Frameworks, + string Project = "", + string Package = "", + bool? Diagnostics = default, + string ExecutablePath = "", + string WorkingDirectory = "", + string ShortName = "") +{ + /// + /// Create a new instance of the command. + /// + /// Specifies the set of command line arguments to use when starting the tool. + public DotNetNuGetWhy(params string[] args) + : this(args, [], []) + { + } + + /// + /// Create a new instance of the command. + /// + public DotNetNuGetWhy() + : this([], [], []) + { + } + + /// + public IStartInfo GetStartInfo(IHost host) + { + if (host == null) throw new ArgumentNullException(nameof(host)); + return host.CreateCommandLine(ExecutablePath) + .WithShortName(ToString()) + .WithWorkingDirectory(WorkingDirectory) + .WithVars(Vars.ToArray()) + .AddArgs("nuget") + .AddArgs("why") + .AddNotEmptyArgs(Project.ToArg()) + .AddNotEmptyArgs(Package.ToArg()) + .AddArgs(Frameworks.ToArgs("--framework", "")) + .AddBooleanArgs( + ("--diagnostics", Diagnostics) + ) + .AddArgs(Args.ToArray()); + } + + /// + public override string ToString() => (ExecutablePath == string.Empty ? "dotnet" : Path.GetFileNameWithoutExtension(ExecutablePath)).GetShortName("Shows the dependency graph for a particular package.", ShortName, "nuget", "why", Project.ToArg(), Package.ToArg()); +} + +/// +/// Gets the NuGet configuration settings that will be applied. +///

+/// This command gets the NuGet configuration settings that will be applied from the config section. +///

+///
.NET CLI command
+/// +/// +/// using HostApi; +/// +/// string? repositoryPath = default; +/// new DotNetNuGetConfigGet() +/// .WithConfigKey("repositoryPath") +/// .Run(output => repositoryPath = output.Line).EnsureSuccess(); +/// +/// +///
+/// 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. +/// Overrides the tool executable path. +/// Specifies the working directory for the tool to be started. +/// ALL is default value, 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. +/// Indicate that the NuGet configuration file path will be shown beside the configuration settings. +/// Specifies the directory to start from when listing configuration files. If not specified, the current directory is used. +/// Enables diagnostic output. +/// Specifies a short name for this operation. +[Target] +public partial record DotNetNuGetConfigGet( + IEnumerable Args, + IEnumerable<(string name, string value)> Vars, + string ConfigKey = "ALL", + bool? ShowPath = default, + string Directory = "", + bool? Diagnostics = default, + string ExecutablePath = "", + string WorkingDirectory = "", + string ShortName = "") +{ + /// + /// Create a new instance of the command. + /// + /// Specifies the set of command line arguments to use when starting the tool. + public DotNetNuGetConfigGet(params string[] args) + : this(args, []) + { + } + + /// + /// Create a new instance of the command. + /// + public DotNetNuGetConfigGet() + : this([], []) + { + } + + /// + public IStartInfo GetStartInfo(IHost host) + { + if (host == null) throw new ArgumentNullException(nameof(host)); + return host.CreateCommandLine(ExecutablePath) + .WithShortName(ToString()) + .WithWorkingDirectory(WorkingDirectory) + .WithVars(Vars.ToArray()) + .AddArgs("nuget") + .AddArgs("config") + .AddArgs("get") + .AddNotEmptyArgs(ConfigKey.ToArg()) + .AddArgs(Directory.ToArgs("--working-directory", "")) + .AddBooleanArgs( + ("--show-path", ShowPath), + ("--diagnostics", Diagnostics) + ) + .AddArgs(Args.ToArray()); + } + + /// + public override string ToString() => (ExecutablePath == string.Empty ? "dotnet" : Path.GetFileNameWithoutExtension(ExecutablePath)).GetShortName("Gets the NuGet configuration settings that will be applied.", ShortName, "nuget", "config", "get", ConfigKey.ToArg()); +} + +/// +/// Set the value of a specified NuGet configuration setting. +///

+/// This command sets the values for NuGet configuration settings that will be applied from the config section. +///

+///
.NET CLI command
+/// +/// +/// using HostApi; +/// +/// new DotNetNuGetConfigSet() +/// .WithConfigFile(configFile) +/// .WithConfigKey("repositoryPath") +/// .WithConfigValue("MyValue") +/// .Run().EnsureSuccess(); +/// +/// +///
+/// 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. +/// Overrides the tool executable path. +/// Specifies the working directory for the tool to be started. +/// The key of the settings that are to be set. +/// The value of the settings that are to be set. +/// 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. +/// Enables diagnostic output. +/// Specifies a short name for this operation. +[Target] +public partial record DotNetNuGetConfigSet( + IEnumerable Args, + IEnumerable<(string name, string value)> Vars, + string ConfigKey = "", + string ConfigValue = "", + string ConfigFile = "", + bool? Diagnostics = default, + string ExecutablePath = "", + string WorkingDirectory = "", + string ShortName = "") +{ + /// + /// Create a new instance of the command. + /// + /// Specifies the set of command line arguments to use when starting the tool. + public DotNetNuGetConfigSet(params string[] args) + : this(args, []) + { + } + + /// + /// Create a new instance of the command. + /// + public DotNetNuGetConfigSet() + : this([], []) + { + } + + /// + public IStartInfo GetStartInfo(IHost host) + { + if (host == null) throw new ArgumentNullException(nameof(host)); + return host.CreateCommandLine(ExecutablePath) + .WithShortName(ToString()) + .WithWorkingDirectory(WorkingDirectory) + .WithVars(Vars.ToArray()) + .AddArgs("nuget") + .AddArgs("config") + .AddArgs("set") + .AddNotEmptyArgs(ConfigKey.ToArg()) + .AddNotEmptyArgs(ConfigValue.ToArg()) + .AddArgs(ConfigFile.ToArgs("--configfile", "")) + .AddBooleanArgs( + ("--diagnostics", Diagnostics) + ) + .AddArgs(Args.ToArray()); + } + + /// + public override string ToString() => (ExecutablePath == string.Empty ? "dotnet" : Path.GetFileNameWithoutExtension(ExecutablePath)).GetShortName("Set the value of a specified NuGet configuration setting.", ShortName, "nuget", "config", "set", ConfigKey.ToArg(), ConfigValue.ToArg()); +} + +/// +/// Removes the key-value pair from a specified NuGet configuration setting. +///

+/// This command unsets the values for NuGet configuration settings that will be applied from the config section. +///

+///
.NET CLI command
+/// +/// +/// using HostApi; +/// +/// new DotNetNuGetConfigUnset() +/// .WithConfigKey("repositoryPath") +/// .Run().EnsureSuccess(); +/// +/// +///
+/// 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. +/// Overrides the tool executable path. +/// Specifies the working directory for the tool to be started. +/// The key of the settings that are to be removed. +/// 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. +/// Enables diagnostic output. +/// Specifies a short name for this operation. +[Target] +public partial record DotNetNuGetConfigUnset( + IEnumerable Args, + IEnumerable<(string name, string value)> Vars, + string ConfigKey = "", + string ConfigFile = "", + bool? Diagnostics = default, + string ExecutablePath = "", + string WorkingDirectory = "", + string ShortName = "") +{ + /// + /// Create a new instance of the command. + /// + /// Specifies the set of command line arguments to use when starting the tool. + public DotNetNuGetConfigUnset(params string[] args) + : this(args, []) + { + } + + /// + /// Create a new instance of the command. + /// + public DotNetNuGetConfigUnset() + : this([], []) + { + } + + /// + public IStartInfo GetStartInfo(IHost host) + { + if (host == null) throw new ArgumentNullException(nameof(host)); + return host.CreateCommandLine(ExecutablePath) + .WithShortName(ToString()) + .WithWorkingDirectory(WorkingDirectory) + .WithVars(Vars.ToArray()) + .AddArgs("nuget") + .AddArgs("config") + .AddArgs("unset") + .AddNotEmptyArgs(ConfigKey.ToArg()) + .AddArgs(ConfigFile.ToArgs("--configfile", "")) + .AddBooleanArgs( + ("--diagnostics", Diagnostics) + ) + .AddArgs(Args.ToArray()); + } + + /// + public override string ToString() => (ExecutablePath == string.Empty ? "dotnet" : Path.GetFileNameWithoutExtension(ExecutablePath)).GetShortName("Removes the key-value pair from a specified NuGet configuration setting.", ShortName, "nuget", "config", "unset", ConfigKey.ToArg()); +} + +/// +/// Lists nuget configuration files currently being applied to a directory. +///

+/// This command lists the paths to all NuGet configuration files that will be applied when invoking NuGet commands in a specific directory. +///

+///
.NET CLI command
+/// +/// +/// using HostApi; +/// +/// var configPaths = new List<string>(); +/// new DotNetNuGetConfigPaths() +/// .Run(output => configPaths.Add(output.Line)).EnsureSuccess(); +/// +/// +///
+/// 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. +/// Overrides the tool executable path. +/// Specifies the working directory for the tool to be started. +/// Specifies the directory to start from when listing configuration files. If not specified, the current directory is used. +/// Enables diagnostic output. +/// Specifies a short name for this operation. +[Target] +public partial record DotNetNuGetConfigPaths( + IEnumerable Args, + IEnumerable<(string name, string value)> Vars, + string Directory = "", + bool? Diagnostics = default, + string ExecutablePath = "", + string WorkingDirectory = "", + string ShortName = "") +{ + /// + /// Create a new instance of the command. + /// + /// Specifies the set of command line arguments to use when starting the tool. + public DotNetNuGetConfigPaths(params string[] args) + : this(args, []) + { + } + + /// + /// Create a new instance of the command. + /// + public DotNetNuGetConfigPaths() + : this([], []) + { + } + + /// + public IStartInfo GetStartInfo(IHost host) + { + if (host == null) throw new ArgumentNullException(nameof(host)); + return host.CreateCommandLine(ExecutablePath) + .WithShortName(ToString()) + .WithWorkingDirectory(WorkingDirectory) + .WithVars(Vars.ToArray()) + .AddArgs("nuget") + .AddArgs("config") + .AddArgs("paths") + .AddArgs(Directory.ToArgs("--working-directory", "")) + .AddBooleanArgs( + ("--diagnostics", Diagnostics) + ) + .AddArgs(Args.ToArray()); + } + + /// + public override string ToString() => (ExecutablePath == string.Empty ? "dotnet" : Path.GetFileNameWithoutExtension(ExecutablePath)).GetShortName("Lists nuget configuration files currently being applied to a directory.", ShortName, "nuget", "config", "paths"); +} + +/// +/// Packs the code into a NuGet package. +///

+/// The dotnet pack command builds the project and creates NuGet packages. The result of this command is a NuGet package (that is, a .nupkg file). +///

+///

+/// NuGet dependencies of the packed project are added to the .nuspec file, so they're properly resolved when the package is installed. If the packed project has references to other projects, the other projects aren't included in the package. Currently, you must have a package per project if you have project-to-project dependencies. +///

+///

+/// By default, dotnet pack builds the project first. If you wish to avoid this behavior, pass the --no-build option. This option is often useful in Continuous Integration (CI) build scenarios where you know the code was previously built. +///

+///
.NET CLI command
+/// +/// +/// using HostApi; +/// +/// // Creates a NuGet package of version 1.2.3 for the project +/// new DotNetPack() +/// .WithWorkingDirectory("MyLib") +/// .WithOutput(path) +/// .AddProps(("version", "1.2.3")) +/// .Build().EnsureSuccess(); +/// +/// +///
+/// 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. +/// MSBuild options for setting properties. +/// The URI of the NuGet package source to use during this operation. +/// Overrides the tool executable path. +/// Specifies the working directory for the tool to be started. +/// The project or solution to pack. It's either a path to a csproj, vbproj, or fsproj file, or to a solution file or directory. If not specified, the command searches the current directory for a project or solution file. +/// All build output files from the executed command will go in subfolders under the specified path, separated by project. +/// Defines the build configuration. The default for most projects is Debug, but you can override the build configuration settings in your project. +/// 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. +/// Includes the debug symbols NuGet packages in addition to the regular NuGet packages in the output directory. The sources files are included in the src folder within the symbols package. +/// Includes the debug symbols NuGet packages in addition to the regular NuGet packages in the output directory. +/// Doesn't build the project before packing. It also implicitly sets the --no-restore flag. +/// When restoring a project with project-to-project (P2P) references, restores the root project and not the references. +/// 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. +/// Doesn't execute an implicit restore when running the command. +/// Doesn't display the startup banner or the copyright message. +/// 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. +/// 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. +/// 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. +/// 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. +/// 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. +/// Specifies whether the terminal logger should be used for the build output. +/// Sets the verbosity level of the command. Allowed values are , , , , and . The default is . For more information, see . +/// 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. +/// 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. +/// Enables diagnostic output. +/// Specifies a short name for this operation. +[Target] +public partial record DotNetPack( + IEnumerable Args, + IEnumerable<(string name, string value)> Vars, + IEnumerable<(string name, string value)> Props, + IEnumerable Sources, + string Project = "", + string ArtifactsPath = "", + string Configuration = "", + bool? Force = default, + string IncludeSource = "", + string IncludeSymbols = "", + bool? NoBuild = default, + bool? NoDependencies = default, + bool? NoIncremental = default, + bool? NoRestore = default, + bool? NoLogo = default, + bool? NoSelfContained = default, + string Output = "", + string OS = "", + string Runtime = "", + bool? SelfContained = default, + DotNetTerminalLogger? TerminalLogger = default, + DotNetVerbosity? Verbosity = default, + bool? UseCurrentRuntime = default, + string VersionSuffix = "", + bool? Diagnostics = default, + string ExecutablePath = "", + string WorkingDirectory = "", + string ShortName = "") +{ + /// + /// Create a new instance of the command. + /// + /// Specifies the set of command line arguments to use when starting the tool. + public DotNetPack(params string[] args) + : this(args, [], [], []) + { + } + + /// + /// Create a new instance of the command. + /// + public DotNetPack() + : this([], [], [], []) + { + } + + /// + public IStartInfo GetStartInfo(IHost host) + { + if (host == null) throw new ArgumentNullException(nameof(host)); + return host.CreateCommandLine(ExecutablePath) + .WithShortName(ToString()) + .WithWorkingDirectory(WorkingDirectory) + .WithVars(Vars.ToArray()) + .AddArgs("pack") + .AddNotEmptyArgs(Project.ToArg()) + .AddMSBuildLoggers(host, Verbosity) + .AddArgs(Sources.ToArgs("--source", "")) + .AddArgs(ArtifactsPath.ToArgs("--artifacts-path", "")) + .AddArgs(Configuration.ToArgs("--configuration", "")) + .AddArgs(IncludeSource.ToArgs("--include-source", "")) + .AddArgs(IncludeSymbols.ToArgs("--include-symbols", "")) + .AddArgs(Output.ToArgs("--output", "")) + .AddArgs(OS.ToArgs("--os", "")) + .AddArgs(Runtime.ToArgs("--runtime", "")) + .AddArgs(TerminalLogger.ToArgs("--tl", "")) + .AddArgs(Verbosity.ToArgs("--verbosity", "")) + .AddArgs(VersionSuffix.ToArgs("--version-suffix", "")) + .AddBooleanArgs( + ("--force", Force), + ("--no-build", NoBuild), + ("--no-dependencies", NoDependencies), + ("--no-incremental", NoIncremental), + ("--no-restore", NoRestore), + ("--nologo", NoLogo), + ("--no-self-contained", NoSelfContained), + ("--self-contained", SelfContained), + ("--use-current-runtime", UseCurrentRuntime), + ("--diagnostics", Diagnostics) + ) + .AddProps("--property", Props.ToArray()) + .AddArgs(Args.ToArray()); + } + + /// + public override string ToString() => (ExecutablePath == string.Empty ? "dotnet" : Path.GetFileNameWithoutExtension(ExecutablePath)).GetShortName("Packs the code into a NuGet package.", ShortName, "pack", Project.ToArg()); +} + +/// +/// Searches for a NuGet package. +///

+/// This command searches for a NuGet package. +///

+///
.NET CLI command
+/// +/// +/// using System.Text; +/// using System.Text.Json; +/// using HostApi; +/// +/// var packagesJson = new StringBuilder(); +/// new DotNetPackageSearch() +/// .WithSearchTerm("Pure.DI") +/// .WithFormat(DotNetPackageSearchResultFormat.Json) +/// .Run(output => packagesJson.AppendLine(output.Line)).EnsureSuccess(); +/// +/// var result = JsonSerializer.Deserialize<Result>( +/// packagesJson.ToString(), +/// new JsonSerializerOptions { PropertyNameCaseInsensitive = true }); +/// +/// result.ShouldNotBeNull(); +/// result.SearchResult.SelectMany(i => i.Packages).Count(i => i.Id == "Pure.DI").ShouldBe(1); +/// +/// record Result(int Version, IReadOnlyCollection<Source> SearchResult); +/// +/// record Source(string SourceName, IReadOnlyCollection<Package> Packages); +/// +/// record Package( +/// string Id, +/// string LatestVersion, +/// int TotalDownloads, +/// string Owners); +/// +/// +///
+/// 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. +/// The URI of the NuGet package source to use during this operation. +/// Overrides the tool executable path. +/// Specifies the working directory for the tool to be started. +/// Specifies the search term to filter results. Use this argument to search for packages matching the provided query. +/// 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. +/// This option narrows the search to only include packages whose IDs exactly match the specified search term, effectively filtering out any partial matches. It provides a concise list of all available versions for the identified package. Causes --take and --skip options to be ignored. Utilize this option to display all available versions of a specified package. +/// The format options are table and json. The default is table. +/// Allow prerelease packages to be shown. +/// The number of results to skip, for pagination. The default value is 0. +/// The number of results to return. The default value is 20. +/// Sets the verbosity level of the command. Allowed values are , , , , and . The default is . For more information, see . +/// Enables diagnostic output. +/// Specifies a short name for this operation. +[Target] +public partial record DotNetPackageSearch( + IEnumerable Args, + IEnumerable<(string name, string value)> Vars, + IEnumerable Sources, + string SearchTerm = "", + string ConfigFile = "", + bool? ExactMatch = default, + DotNetPackageSearchResultFormat? Format = default, + bool? Prerelease = default, + int? Skip = default, + int? Take = default, + DotNetVerbosity? Verbosity = default, + bool? Diagnostics = default, + string ExecutablePath = "", + string WorkingDirectory = "", + string ShortName = "") +{ + /// + /// Create a new instance of the command. + /// + /// Specifies the set of command line arguments to use when starting the tool. + public DotNetPackageSearch(params string[] args) + : this(args, [], []) + { + } + + /// + /// Create a new instance of the command. + /// + public DotNetPackageSearch() + : this([], [], []) + { + } + + /// + public IStartInfo GetStartInfo(IHost host) + { + if (host == null) throw new ArgumentNullException(nameof(host)); + return host.CreateCommandLine(ExecutablePath) + .WithShortName(ToString()) + .WithWorkingDirectory(WorkingDirectory) + .WithVars(Vars.ToArray()) + .AddArgs("package") + .AddArgs("search") + .AddNotEmptyArgs(SearchTerm.ToArg()) + .AddArgs(Sources.ToArgs("--source", "")) + .AddArgs(ConfigFile.ToArgs("--configfile", "")) + .AddArgs(Format.ToArgs("--format", "")) + .AddArgs(Skip.ToArgs("--skip", "")) + .AddArgs(Take.ToArgs("--take", "")) + .AddArgs(Verbosity.ToArgs("--verbosity", "")) + .AddBooleanArgs( + ("--exact-match", ExactMatch), + ("--prerelease", Prerelease), + ("--diagnostics", Diagnostics) + ) + .AddArgs(Args.ToArray()); + } + + /// + public override string ToString() => (ExecutablePath == string.Empty ? "dotnet" : Path.GetFileNameWithoutExtension(ExecutablePath)).GetShortName("Searches for a NuGet package.", ShortName, "package", "search", SearchTerm.ToArg()); +} + +/// +/// Publishes the application and its dependencies to a folder for deployment to a hosting system. +///

+/// This command compiles the application, reads through its dependencies specified in the project file, and publishes the resulting set of files to a directory. +///

+///
.NET CLI command
+/// +/// +/// using HostApi; +/// +/// new DotNetPublish() +/// .WithWorkingDirectory("MyLib") +/// .WithFramework("net8.0") +/// .WithOutput("bin") +/// .Build().EnsureSuccess(); +/// +/// +///
+/// 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. +/// MSBuild options for setting properties. +/// The URI of the NuGet package source to use during this operation. +/// Specifies one or several target manifests to use to trim the set of packages published with the app. The manifest file is part of the output of the dotnet store command. +/// Overrides the tool executable path. +/// Specifies the working directory for the tool to be started. +/// 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. +/// 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. +/// All build output files from the executed command will go in subfolders under the specified path, separated by project. +/// Defines the build configuration. The default for most projects is Debug, but you can override the build configuration settings in your project. +/// 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. +/// Builds and runs the app using the specified framework. The framework must be specified in the project file. +/// 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. +/// Doesn't build the project before publishing. It also implicitly sets the --no-restore flag. +/// When restoring a project with project-to-project (P2P) references, restores the root project and not the references. +/// Doesn't display the startup banner or the copyright message. +/// Doesn't execute an implicit restore when running the command. +/// Specifies the path for the output directory. If not specified, it defaults to [project_file_folder]/bin/[configuration]/[framework]/publish/ for a framework-dependent executable and cross-platform binaries. It defaults to [project_file_folder]/bin/[configuration]/[framework]/[runtime]/publish/ for a self-contained executable. In a web project, if the output folder is in the project folder, successive dotnet publish commands result in nested output folders. For example, if the project folder is myproject, and the publish output folder is myproject/publish, and you run dotnet publish twice, the second run puts content files such as .config and .json files in myproject/publish/publish. To avoid nesting publish folders, specify a publish folder that isn't directly under the project folder, or exclude the publish folder from the project. +/// 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. +/// Publishes the .NET runtime with your application so the runtime doesn't need to be installed on the target machine. Default is true if a runtime identifier is specified and the project is an executable project (not a library project). +/// 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. +/// Publishes the application for a given runtime. For a list of Runtime Identifiers (RIDs), see the RID catalog. +/// Specifies whether the terminal logger should be used for the build output. +/// 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. +/// Sets the verbosity level of the command. Allowed values are , , , , and . The default is . For more information, see . +/// 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. +/// Enables diagnostic output. +/// Specifies a short name for this operation. +[Target] +public partial record DotNetPublish( + IEnumerable Args, + IEnumerable<(string name, string value)> Vars, + IEnumerable<(string name, string value)> Props, + IEnumerable Sources, + IEnumerable Manifests, + string Project = "", + string Arch = "", + string ArtifactsPath = "", + string Configuration = "", + bool? DisableBuildServers = default, + string Framework = "", + bool? Force = default, + bool? NoBuild = default, + bool? NoDependencies = default, + bool? NoLogo = default, + bool? NoRestore = default, + string Output = "", + string OS = "", + bool? SelfContained = default, + bool? NoSelfContained = default, + string Runtime = "", + DotNetTerminalLogger? TerminalLogger = default, + bool? UseCurrentRuntime = default, + DotNetVerbosity? Verbosity = default, + string VersionSuffix = "", + bool? Diagnostics = default, + string ExecutablePath = "", + string WorkingDirectory = "", + string ShortName = "") +{ + /// + /// Create a new instance of the command. + /// + /// Specifies the set of command line arguments to use when starting the tool. + public DotNetPublish(params string[] args) + : this(args, [], [], [], []) + { + } + + /// + /// Create a new instance of the command. + /// + public DotNetPublish() + : this([], [], [], [], []) + { + } + + /// + public IStartInfo GetStartInfo(IHost host) + { + if (host == null) throw new ArgumentNullException(nameof(host)); + return host.CreateCommandLine(ExecutablePath) + .WithShortName(ToString()) + .WithWorkingDirectory(WorkingDirectory) + .WithVars(Vars.ToArray()) + .AddArgs("publish") + .AddNotEmptyArgs(Project.ToArg()) + .AddMSBuildLoggers(host, Verbosity) + .AddArgs(Sources.ToArgs("--source", "")) + .AddArgs(Manifests.ToArgs("--manifest", "")) + .AddArgs(Arch.ToArgs("--arch", "")) + .AddArgs(ArtifactsPath.ToArgs("--artifacts-path", "")) + .AddArgs(Configuration.ToArgs("--configuration", "")) + .AddArgs(Framework.ToArgs("--framework", "")) + .AddArgs(Output.ToArgs("--output", "")) + .AddArgs(OS.ToArgs("--os", "")) + .AddArgs(Runtime.ToArgs("--runtime", "")) + .AddArgs(TerminalLogger.ToArgs("--tl", "")) + .AddArgs(Verbosity.ToArgs("--verbosity", "")) + .AddArgs(VersionSuffix.ToArgs("--version-suffix", "")) + .AddBooleanArgs( + ("--disable-build-servers", DisableBuildServers), + ("--force", Force), + ("--no-build", NoBuild), + ("--no-dependencies", NoDependencies), + ("--nologo", NoLogo), + ("--no-restore", NoRestore), + ("--self-contained", SelfContained), + ("--no-self-contained", NoSelfContained), + ("--use-current-runtime", UseCurrentRuntime), + ("--diagnostics", Diagnostics) + ) + .AddProps("--property", Props.ToArray()) + .AddArgs(Args.ToArray()); + } + + /// + public override string ToString() => (ExecutablePath == string.Empty ? "dotnet" : Path.GetFileNameWithoutExtension(ExecutablePath)).GetShortName("Publishes the application and its dependencies to a folder for deployment to a hosting system.", ShortName, "publish", Project.ToArg()); +} + +/// +/// Restores the dependencies and tools of a project. +///

+/// A .NET project typically references external libraries in NuGet packages that provide additional functionality. These external dependencies are referenced in the project file (.csproj or .vbproj). When you run the dotnet restore command, the .NET CLI uses NuGet to look for these dependencies and download them if necessary. It also ensures that all the dependencies required by the project are compatible with each other and that there are no conflicts between them. Once the command is completed, all the dependencies required by the project are available in a local cache and can be used by the .NET CLI to build and run the application. +///

+///

+/// Sometimes, it might be inconvenient to run the implicit NuGet restore with these commands. For example, some automated systems, such as build systems, need to call dotnet restore explicitly to control when the restore occurs so that they can control network usage. To prevent the implicit NuGet restore, you can use the --no-restore flag with any of these commands. +///

+///
.NET CLI command
+/// +/// +/// using HostApi; +/// +/// new DotNetRestore() +/// .WithProject(Path.Combine("MyLib", "MyLib.csproj")) +/// .Build().EnsureSuccess(); +/// +/// +///
+/// 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. +/// MSBuild options for setting properties. +/// The URI of the NuGet package source to use during this operation. +/// Overrides the tool executable path. +/// Specifies the working directory for the tool to be started. +/// 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. +/// 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. +/// 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. +/// 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. +/// Disables restoring multiple projects in parallel. +/// 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. +/// Forces restore to reevaluate all dependencies even if a lock file already exists. +/// Only warn about failed sources if there are packages meeting the version requirement. +/// Output location where project lock file is written. By default, this is PROJECT_ROOT\packages.lock.json. +/// Don't allow updating project lock file. +/// Specifies to not cache HTTP requests. +/// When restoring a project with project-to-project (P2P) references, restores the root project and not the references. +/// Specifies the directory for restored packages. +/// 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. +/// Specifies whether the terminal logger should be used for the build output. +/// 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. +/// Enables project lock file to be generated and used with restore. +/// Sets the verbosity level of the command. Allowed values are , , , , and . The default is . For more information, see . +/// Enables diagnostic output. +/// Specifies a short name for this operation. +[Target] +public partial record DotNetRestore( + IEnumerable Args, + IEnumerable<(string name, string value)> Vars, + IEnumerable<(string name, string value)> Props, + IEnumerable Sources, + string Project = "", + string Arch = "", + string ConfigFile = "", + bool? DisableBuildServers = default, + bool? DisableParallel = default, + bool? Force = default, + bool? ForceEvaluate = default, + bool? IgnoreFailedSources = default, + string LockFilePath = "", + bool? LockedMode = default, + bool? NoCache = default, + bool? NoDependencies = default, + string Packages = "", + string Runtime = "", + DotNetTerminalLogger? TerminalLogger = default, + bool? UseCurrentRuntime = default, + bool? UseLockFile = default, + DotNetVerbosity? Verbosity = default, + bool? Diagnostics = default, + string ExecutablePath = "", + string WorkingDirectory = "", + string ShortName = "") +{ + /// + /// Create a new instance of the command. + /// + /// Specifies the set of command line arguments to use when starting the tool. + public DotNetRestore(params string[] args) + : this(args, [], [], []) + { + } + + /// + /// Create a new instance of the command. + /// + public DotNetRestore() + : this([], [], [], []) + { + } + + /// + public IStartInfo GetStartInfo(IHost host) + { + if (host == null) throw new ArgumentNullException(nameof(host)); + return host.CreateCommandLine(ExecutablePath) + .WithShortName(ToString()) + .WithWorkingDirectory(WorkingDirectory) + .WithVars(Vars.ToArray()) + .AddArgs("restore") + .AddNotEmptyArgs(Project.ToArg()) + .AddMSBuildLoggers(host, Verbosity) + .AddArgs(Sources.ToArgs("--source", "")) + .AddArgs(Arch.ToArgs("--arch", "")) + .AddArgs(ConfigFile.ToArgs("--configfile", "")) + .AddArgs(LockFilePath.ToArgs("--lock-file-path", "")) + .AddArgs(Packages.ToArgs("--packages", "")) + .AddArgs(Runtime.ToArgs("--runtime", "")) + .AddArgs(TerminalLogger.ToArgs("--tl", "")) + .AddArgs(Verbosity.ToArgs("--verbosity", "")) + .AddBooleanArgs( + ("--disable-build-servers", DisableBuildServers), + ("--disable-parallel", DisableParallel), + ("--force", Force), + ("--force-evaluate", ForceEvaluate), + ("--ignore-failed-sources", IgnoreFailedSources), + ("--locked-mode", LockedMode), + ("--no-cache", NoCache), + ("--no-dependencies", NoDependencies), + ("--use-current-runtime", UseCurrentRuntime), + ("--use-lock-file", UseLockFile), + ("--diagnostics", Diagnostics) + ) + .AddProps("--property", Props.ToArray()) + .AddArgs(Args.ToArray()); + } + + /// + public override string ToString() => (ExecutablePath == string.Empty ? "dotnet" : Path.GetFileNameWithoutExtension(ExecutablePath)).GetShortName("Restores the dependencies and tools of a project.", ShortName, "restore", Project.ToArg()); +} + +/// +/// Runs source code without any explicit compile or launch commands. +///

+/// This command provides a convenient option to run your application from the source code with one command. It's useful for fast iterative development from the command line. The command depends on the dotnet build command to build the code. Any requirements for the build apply to dotnet run as well. +///

+///

+/// To run the application, the dotnet run command resolves the dependencies of the application that are outside of the shared runtime from the NuGet cache. Because it uses cached dependencies, it's not recommended to use dotnet run to run applications in production. Instead, create a deployment using the dotnet publish command and deploy the published output. +///

+///
.NET CLI command
+/// +/// +/// using HostApi; +/// +/// var stdOut = new List<string>(); +/// new DotNetRun() +/// .WithProject(Path.Combine("MyApp", "MyApp.csproj")) +/// .Build(message => stdOut.Add(message.Text)) +/// .EnsureSuccess(); +/// +/// // Checks stdOut +/// stdOut.ShouldBe(new[] {"Hello, World!"}); +/// +/// +///
+/// 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. +/// MSBuild options for setting properties. +/// Overrides the tool executable path. +/// Specifies the working directory for the tool to be started. +/// 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. +/// Defines the build configuration. The default for most projects is Debug, but you can override the build configuration settings in your project. +/// Builds and runs the app using the specified framework. The framework must be specified in the project file. +/// 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. +/// 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. +/// Doesn't build the project before running this command. +/// When restoring a project with project-to-project (P2P) references, restores the root project and not the references. +/// Doesn't try to use launchSettings.json to configure the application. +/// Doesn't execute an implicit restore when running the command. +/// 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. +/// Specifies the path of the project file to run (folder name or full path). If not specified, it defaults to the current directory. +/// 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. +/// Specifies whether the terminal logger should be used for the build output. +/// Sets the verbosity level of the command. Allowed values are , , , , and . The default is . For more information, see . +/// Enables diagnostic output. +/// Specifies a short name for this operation. +[Target] +public partial record DotNetRun( + IEnumerable Args, + IEnumerable<(string name, string value)> Vars, + IEnumerable<(string name, string value)> Props, + string Arch = "", + string Configuration = "", + string Framework = "", + bool? Force = default, + string LaunchProfile = "", + bool? NoBuild = default, + bool? NoDependencies = default, + bool? NoLaunchProfile = default, + bool? NoRestore = default, + string OS = "", + string Project = "", + string Runtime = "", + DotNetTerminalLogger? TerminalLogger = default, + DotNetVerbosity? Verbosity = default, + bool? Diagnostics = default, + string ExecutablePath = "", + string WorkingDirectory = "", + string ShortName = "") +{ + /// + /// Create a new instance of the command. + /// + /// Specifies the set of command line arguments to use when starting the tool. + public DotNetRun(params string[] args) + : this(args, [], []) + { + } + + /// + /// Create a new instance of the command. + /// + public DotNetRun() + : this([], [], []) + { + } + + /// + public IStartInfo GetStartInfo(IHost host) + { + if (host == null) throw new ArgumentNullException(nameof(host)); + return host.CreateCommandLine(ExecutablePath) + .WithShortName(ToString()) + .WithWorkingDirectory(WorkingDirectory) + .WithVars(Vars.ToArray()) + .AddArgs("run") + .AddArgs(Arch.ToArgs("--arch", "")) + .AddArgs(Configuration.ToArgs("--configuration", "")) + .AddArgs(Framework.ToArgs("--framework", "")) + .AddArgs(LaunchProfile.ToArgs("--launch-profile", "")) + .AddArgs(OS.ToArgs("--os", "")) + .AddArgs(Project.ToArgs("--project", "")) + .AddArgs(Runtime.ToArgs("--runtime", "")) + .AddArgs(TerminalLogger.ToArgs("--tl", "")) + .AddArgs(Verbosity.ToArgs("--verbosity", "")) + .AddBooleanArgs( + ("--force", Force), + ("--no-build", NoBuild), + ("--no-dependencies", NoDependencies), + ("--no-launch-profile", NoLaunchProfile), + ("--no-restore", NoRestore), + ("--diagnostics", Diagnostics) + ) + .AddProps("--property", Props.ToArray()) + .AddArgs(Args.ToArray()); + } + + /// + public override string ToString() => (ExecutablePath == string.Empty ? "dotnet" : Path.GetFileNameWithoutExtension(ExecutablePath)).GetShortName("Runs source code without any explicit compile or launch commands.", ShortName, "run"); +} + +/// +/// Lists the latest available version of the .NET SDK and .NET Runtime, for each feature band. +///

+/// This command makes it easier to track when new versions of the SDK and Runtimes are available. +///

+///
.NET CLI command
+/// +/// +/// using HostApi; +/// +/// var sdks = new List<Sdk>(); +/// new DotNetSdkCheck() +/// .Run(output => +/// { +/// if (output.Line.StartsWith("Microsoft.")) +/// { +/// var data = output.Line.Split(' ', StringSplitOptions.RemoveEmptyEntries); +/// if (data.Length >= 2) +/// { +/// sdks.Add(new Sdk(data[0], NuGetVersion.Parse(data[1]))); +/// } +/// } +/// }) +/// .EnsureSuccess(); +/// +/// sdks.Count.ShouldBeGreaterThan(0); +/// +/// record Sdk(string Name, NuGetVersion Version); +/// +/// +///
+/// 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. +/// Overrides the tool executable path. +/// Specifies the working directory for the tool to be started. +/// Enables diagnostic output. +/// Specifies a short name for this operation. +[Target] +public partial record DotNetSdkCheck( + IEnumerable Args, + IEnumerable<(string name, string value)> Vars, + bool? Diagnostics = default, + string ExecutablePath = "", + string WorkingDirectory = "", + string ShortName = "") +{ + /// + /// Create a new instance of the command. + /// + /// Specifies the set of command line arguments to use when starting the tool. + public DotNetSdkCheck(params string[] args) + : this(args, []) + { + } + + /// + /// Create a new instance of the command. + /// + public DotNetSdkCheck() + : this([], []) + { + } + + /// + public IStartInfo GetStartInfo(IHost host) + { + if (host == null) throw new ArgumentNullException(nameof(host)); + return host.CreateCommandLine(ExecutablePath) + .WithShortName(ToString()) + .WithWorkingDirectory(WorkingDirectory) + .WithVars(Vars.ToArray()) + .AddArgs("sdk") + .AddArgs("check") + .AddBooleanArgs( + ("--diagnostics", Diagnostics) + ) + .AddArgs(Args.ToArray()); + } + + /// + public override string ToString() => (ExecutablePath == string.Empty ? "dotnet" : Path.GetFileNameWithoutExtension(ExecutablePath)).GetShortName("Lists the latest available version of the .NET SDK and .NET Runtime, for each feature band.", ShortName, "sdk", "check"); +} + +/// +/// Lists all projects in a solution file. +///
.NET CLI command
+/// +/// +/// using HostApi; +/// +/// var lines = new List<string>(); +/// new DotNetSlnList() +/// .WithSolution("NySolution.sln") +/// .Run(output => lines.Add(output.Line)) +/// .EnsureSuccess(); +/// +/// +///
+/// 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. +/// Overrides the tool executable path. +/// Specifies the working directory for the tool to be started. +/// The solution file to use. If this argument is omitted, the command searches the current directory for one. If it finds no solution file or multiple solution files, the command fails. +/// Enables diagnostic output. +/// Specifies a short name for this operation. +[Target] +public partial record DotNetSlnList( + IEnumerable Args, + IEnumerable<(string name, string value)> Vars, + string Solution = "", + bool? Diagnostics = default, + string ExecutablePath = "", + string WorkingDirectory = "", + string ShortName = "") +{ + /// + /// Create a new instance of the command. + /// + /// Specifies the set of command line arguments to use when starting the tool. + public DotNetSlnList(params string[] args) + : this(args, []) + { + } + + /// + /// Create a new instance of the command. + /// + public DotNetSlnList() + : this([], []) + { + } + + /// + public IStartInfo GetStartInfo(IHost host) + { + if (host == null) throw new ArgumentNullException(nameof(host)); + return host.CreateCommandLine(ExecutablePath) + .WithShortName(ToString()) + .WithWorkingDirectory(WorkingDirectory) + .WithVars(Vars.ToArray()) + .AddArgs("sln") + .AddNotEmptyArgs(Solution.ToArg()) + .AddArgs("list") + .AddBooleanArgs( + ("--diagnostics", Diagnostics) + ) + .AddArgs(Args.ToArray()); + } + + /// + public override string ToString() => (ExecutablePath == string.Empty ? "dotnet" : Path.GetFileNameWithoutExtension(ExecutablePath)).GetShortName("Lists all projects in a solution file.", ShortName, "sln", Solution.ToArg(), "list"); +} + +/// +/// Adds one or more projects to the solution file. +///
.NET CLI command
+/// +/// +/// using HostApi; +/// +/// new DotNetNew() +/// .WithTemplateName("sln") +/// .WithName("NySolution") +/// .WithForce(true) +/// .Run().EnsureSuccess(); +/// +/// new DotNetSlnAdd() +/// .WithSolution("NySolution.sln") +/// .AddProjects( +/// Path.Combine("MyLib", "MyLib.csproj"), +/// Path.Combine("MyTests", "MyTests.csproj")) +/// .Run().EnsureSuccess(); +/// +/// +///
+/// 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. +/// The path to the project or projects to add to the solution. Unix/Linux shell globbing pattern expansions are processed correctly by the dotnet sln command. +/// Overrides the tool executable path. +/// Specifies the working directory for the tool to be started. +/// The solution file to use. If this argument is omitted, the command searches the current directory for one. If it finds no solution file or multiple solution files, the command fails. +/// Places the projects in the root of the solution, rather than creating a solution folder. Can't be used with -s|--solution-folder. +/// The destination solution folder path to add the projects to. Can't be used with --in-root. +/// Enables diagnostic output. +/// Specifies a short name for this operation. +[Target] +public partial record DotNetSlnAdd( + IEnumerable Args, + IEnumerable<(string name, string value)> Vars, + IEnumerable Projects, + string Solution = "", + bool? InRoot = default, + string SolutionFolder = "", + bool? Diagnostics = default, + string ExecutablePath = "", + string WorkingDirectory = "", + string ShortName = "") +{ + /// + /// Create a new instance of the command. + /// + /// Specifies the set of command line arguments to use when starting the tool. + public DotNetSlnAdd(params string[] args) + : this(args, [], []) + { + } + + /// + /// Create a new instance of the command. + /// + public DotNetSlnAdd() + : this([], [], []) + { + } + + /// + public IStartInfo GetStartInfo(IHost host) + { + if (host == null) throw new ArgumentNullException(nameof(host)); + return host.CreateCommandLine(ExecutablePath) + .WithShortName(ToString()) + .WithWorkingDirectory(WorkingDirectory) + .WithVars(Vars.ToArray()) + .AddArgs("sln") + .AddNotEmptyArgs(Solution.ToArg()) + .AddArgs("add") + .AddNotEmptyArgs(Projects.ToArray()) + .AddArgs(SolutionFolder.ToArgs("--solution-folder", "")) + .AddBooleanArgs( + ("--in-root", InRoot), + ("--diagnostics", Diagnostics) + ) + .AddArgs(Args.ToArray()); + } + + /// + public override string ToString() => (ExecutablePath == string.Empty ? "dotnet" : Path.GetFileNameWithoutExtension(ExecutablePath)).GetShortName("Adds one or more projects to the solution file.", ShortName, new [] {"sln", Solution.ToArg(), "add"}.Concat(Projects).ToArray()); +} + +/// +/// Removes a project or multiple projects from the solution file. +///
.NET CLI command
+/// +/// +/// using HostApi; +/// +/// new DotNetSlnRemove() +/// .WithSolution("NySolution.sln") +/// .AddProjects( +/// Path.Combine("MyLib", "MyLib.csproj")) +/// .Run().EnsureSuccess(); +/// +/// +///
+/// 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. +/// The path to the project or projects to add to the solution. Unix/Linux shell globbing pattern expansions are processed correctly by the dotnet sln command. +/// Overrides the tool executable path. +/// Specifies the working directory for the tool to be started. +/// The solution file to use. If this argument is omitted, the command searches the current directory for one. If it finds no solution file or multiple solution files, the command fails. +/// Enables diagnostic output. +/// Specifies a short name for this operation. +[Target] +public partial record DotNetSlnRemove( + IEnumerable Args, + IEnumerable<(string name, string value)> Vars, + IEnumerable Projects, + string Solution = "", + bool? Diagnostics = default, + string ExecutablePath = "", + string WorkingDirectory = "", + string ShortName = "") +{ + /// + /// Create a new instance of the command. + /// + /// Specifies the set of command line arguments to use when starting the tool. + public DotNetSlnRemove(params string[] args) + : this(args, [], []) + { + } + + /// + /// Create a new instance of the command. + /// + public DotNetSlnRemove() + : this([], [], []) + { + } + + /// + public IStartInfo GetStartInfo(IHost host) + { + if (host == null) throw new ArgumentNullException(nameof(host)); + return host.CreateCommandLine(ExecutablePath) + .WithShortName(ToString()) + .WithWorkingDirectory(WorkingDirectory) + .WithVars(Vars.ToArray()) + .AddArgs("sln") + .AddNotEmptyArgs(Solution.ToArg()) + .AddArgs("remove") + .AddNotEmptyArgs(Projects.ToArray()) + .AddBooleanArgs( + ("--diagnostics", Diagnostics) + ) + .AddArgs(Args.ToArray()); + } + + /// + public override string ToString() => (ExecutablePath == string.Empty ? "dotnet" : Path.GetFileNameWithoutExtension(ExecutablePath)).GetShortName("Removes a project or multiple projects from the solution file.", ShortName, new [] {"sln", Solution.ToArg(), "remove"}.Concat(Projects).ToArray()); +} + +/// +/// Stores the specified assemblies in the runtime package store. +///

+/// This command stores the specified assemblies in the runtime package store. By default, assemblies are optimized for the target runtime and framework. +///

+///
.NET CLI command
+/// +/// +/// using HostApi; +/// +/// new DotNetStore() +/// .AddManifests(Path.Combine("MyLib", "MyLib.csproj")) +/// .WithFramework("net8.0") +/// .WithRuntime("win-x64") +/// .Build(); +/// +/// +/// +///
+/// 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. +/// The package store manifest file is an XML file that contains the list of packages to store. The format of the manifest file is compatible with the SDK-style project format. So, a project file that references the desired packages can be used with the -m|--manifest option to store assemblies in the runtime package store. +/// Overrides the tool executable path. +/// Specifies the working directory for the tool to be started. +/// Specifies the .NET SDK version. This option enables you to select a specific framework version beyond the framework specified by the -f|--framework option. +/// 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. +/// Specifies the .NET SDK version. This option enables you to select a specific framework version beyond the framework specified by the -f|--framework option. +/// Specifies the path to the runtime package store. If not specified, it defaults to the store subdirectory of the user profile .NET installation directory. +/// Skips the optimization phase. +/// Skips symbol generation. Currently, you can only generate symbols on Windows and Linux. +/// Sets the verbosity level of the command. Allowed values are , , , , and . The default is . For more information, see . +/// The working directory used by the command. If not specified, it uses the obj subdirectory of the current directory. +/// Enables diagnostic output. +/// Specifies a short name for this operation. +[Target] +public partial record DotNetStore( + IEnumerable Args, + IEnumerable<(string name, string value)> Vars, + IEnumerable Manifests, + string Framework = "", + string Runtime = "", + string FrameworkVersion = "", + string Output = "", + bool? SkipOptimization = default, + bool? SkipSymbols = default, + DotNetVerbosity? Verbosity = default, + string Directory = "", + bool? Diagnostics = default, + string ExecutablePath = "", + string WorkingDirectory = "", + string ShortName = "") +{ + /// + /// Create a new instance of the command. + /// + /// Specifies the set of command line arguments to use when starting the tool. + public DotNetStore(params string[] args) + : this(args, [], []) + { + } + + /// + /// Create a new instance of the command. + /// + public DotNetStore() + : this([], [], []) + { + } + + /// + public IStartInfo GetStartInfo(IHost host) + { + if (host == null) throw new ArgumentNullException(nameof(host)); + return host.CreateCommandLine(ExecutablePath) + .WithShortName(ToString()) + .WithWorkingDirectory(WorkingDirectory) + .WithVars(Vars.ToArray()) + .AddArgs("store") + .AddArgs(Manifests.ToArgs("--manifest", "")) + .AddArgs(Framework.ToArgs("--framework", "")) + .AddArgs(Runtime.ToArgs("--runtime", "")) + .AddArgs(FrameworkVersion.ToArgs("--framework-version", "")) + .AddArgs(Output.ToArgs("--output", "")) + .AddArgs(Verbosity.ToArgs("--verbosity", "")) + .AddArgs(Directory.ToArgs("--working-dir", "")) + .AddBooleanArgs( + ("--skip-optimization", SkipOptimization), + ("--skip-symbols", SkipSymbols), + ("--diagnostics", Diagnostics) + ) + .AddArgs(Args.ToArray()); + } + + /// + public override string ToString() => (ExecutablePath == string.Empty ? "dotnet" : Path.GetFileNameWithoutExtension(ExecutablePath)).GetShortName("Stores the specified assemblies in the runtime package store.", ShortName, "store"); +} + +/// +/// .NET test driver used to execute unit tests. +///

+/// This command is used to execute unit tests in a given solution. The dotnet test command builds the solution and runs a test host application for each test project in the solution using VSTest. The test host executes tests in the given project using a test framework, for example: MSTest, NUnit, or xUnit, and reports the success or failure of each test. If all tests are successful, the test runner returns 0 as an exit code; otherwise if any test fails, it returns 1. +///

+///

+/// For multi-targeted projects, tests are run for each targeted framework. The test host and the unit test framework are packaged as NuGet packages and are restored as ordinary dependencies for the project. Starting with the .NET 9 SDK, these tests are run in parallel by default. To disable parallel execution, set the TestTfmsInParallel MSBuild property to false. +///

+///
.NET CLI command
+/// +/// +/// using HostApi; +/// +/// // Runs tests +/// var result = new DotNetTest() +/// .WithWorkingDirectory("MyTests") +/// .Build().EnsureSuccess(); +/// +/// // The "result" variable provides details about build and tests +/// 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()); +/// +/// +///
+/// 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. +/// MSBuild options for setting properties. +/// Sets the value of an environment variable. Creates the variable if it does not exist, overrides if it does exist. Use of this option will force the tests to be run in an isolated process. +/// Specifies a logger for test results and optionally switches for the logger. +/// Overrides the tool executable path. +/// Specifies the working directory for the tool to be started. +/// Path to the test project.
Or path to the solution.
Or path to a directory that contains a project or a solution.
Or path to a test project .dll file.
Or path to a test project .exe file.
If not specified, the effect is the same as using the DIRECTORY argument to specify the current directory. +/// Path to a directory to be searched for additional test adapters. Only .dll files with suffix .TestAdapter.dll are inspected. If not specified, the directory of the test .dll is searched. +/// 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. +/// All build output files from the executed command will go in subfolders under the specified path, separated by project. +/// Runs the tests in blame mode. This option is helpful in isolating problematic tests that cause the test host to crash. When a crash is detected, it creates a sequence file in TestResults/<Guid>/<Guid>_Sequence.xml that captures the order of tests that were run before the crash.<br/>This option does not create a memory dump and is not helpful when the test is hanging. +/// Runs the tests in blame mode and collects a crash dump when the test host exits unexpectedly. This option depends on the version of .NET used, the type of error, and the operating system.
For exceptions in managed code, a dump will be automatically collected on .NET 5.0 and later versions. It will generate a dump for testhost or any child process that also ran on .NET 5.0 and crashed. Crashes in native code will not generate a dump. This option works on Windows, macOS, and Linux. +/// The type of crash dump to be collected. Supported dump types are full (default), and mini. +/// Collects a crash dump on expected as well as unexpected test host exit. +/// Run the tests in blame mode and collects a hang dump when a test exceeds the given timeout. +/// The type of crash dump to be collected. It should be full, mini, or none. When none is specified, test host is terminated on timeout, but no dump is collected. +/// Per-test timeout, after which a hang dump is triggered and the test host process and all of its child processes are dumped and terminated. +/// Defines the build configuration. The default for most projects is Debug, but you can override the build configuration settings in your project. +/// Enables data collector for the test run. +/// Enables diagnostic mode for the test platform and writes diagnostic messages to the specified file and to files next to it. The process that is logging the messages determines which files are created, such as *.host_&lt;date&gt;.txt for test host log, and *.datacollector_&lt;date&gt;.txt for data collector log. +/// Builds and runs the app using the specified framework. The framework must be specified in the project file. +/// Filters tests in the current project using the given expression. Only tests that match the filter expression are run. +/// Doesn't build the project before running this command. +/// Doesn't display the startup banner or the copyright message. +/// Doesn't execute an implicit restore when running the command. +/// 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. +/// 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. +/// The directory where the test results are going to be placed. If the specified directory doesn't exist, it's created. The default is TestResults in the directory that contains the project file. +/// The target runtime to test for. +/// The .runsettings file to use for running the tests. The TargetPlatform element (x86|x64) has no effect for dotnet test. To run tests that target x86, install the x86 version of .NET Core. The bitness of the dotnet.exe that is on the path is what will be used for running tests. +/// List the discovered tests instead of running the tests. +/// Sets the verbosity level of the command. Allowed values are , , , , and . The default is . For more information, see . +/// Enables diagnostic output. +/// Specifies a short name for this operation. +[Target] +public partial record DotNetTest( + IEnumerable Args, + IEnumerable<(string name, string value)> Vars, + IEnumerable<(string name, string value)> Props, + IEnumerable<(string name, string value)> Environments, + IEnumerable Loggers, + string Project = "", + string TestAdapterPath = "", + string Arch = "", + string ArtifactsPath = "", + bool? Blame = default, + bool? BlameCrash = default, + DotNetBlameDumpType? BlameCrashDumpType = default, + bool? BlameCrashCollectAlways = default, + bool? BlameHang = default, + DotNetBlameDumpType? BlameHangDumpType = default, + TimeSpan? BlameHangTimeout = default, + string Configuration = "", + string Collect = "", + string Diag = "", + string Framework = "", + string Filter = "", + bool? NoBuild = default, + bool? NoLogo = default, + bool? NoRestore = default, + string Output = "", + string OS = "", + string ResultsDirectory = "", + string Runtime = "", + string Settings = "", + bool? ListTests = default, + DotNetVerbosity? Verbosity = default, + bool? Diagnostics = default, + string ExecutablePath = "", + string WorkingDirectory = "", + string ShortName = "") +{ + /// + /// Create a new instance of the command. + /// + /// Specifies the set of command line arguments to use when starting the tool. + public DotNetTest(params string[] args) + : this(args, [], [], [], []) + { + } + + /// + /// Create a new instance of the command. + /// + public DotNetTest() + : this([], [], [], [], []) + { + } + + /// + public IStartInfo GetStartInfo(IHost host) + { + if (host == null) throw new ArgumentNullException(nameof(host)); + var components = host.GetService(); + var virtualContext = components.VirtualContext; + var settings = components.DotNetSettings; + return host.CreateCommandLine(ExecutablePath) + .WithShortName(ToString()) + .WithWorkingDirectory(WorkingDirectory) + .WithVars(Vars.ToArray()) + .AddArgs("test") + .AddNotEmptyArgs(Project.ToArg()) + .AddMSBuildLoggers(host, Verbosity) + .AddTestLoggers(host, Loggers) + .AddArgs(Environments.ToArgs("--environment", "=")) + .AddArgs(Loggers.ToArgs("--logger ", "")) + .AddArgs("--test-adapter-path", $"{string.Join(";", new[] {TestAdapterPath, virtualContext.Resolve(settings.DotNetVSTestLoggerDirectory)}.Where(i => !string.IsNullOrWhiteSpace(i)))}") + .AddArgs(Arch.ToArgs("--arch", "")) + .AddArgs(ArtifactsPath.ToArgs("--artifacts-path", "")) + .AddArgs(BlameCrashDumpType.ToArgs("--blame-crash-dump-type", "")) + .AddArgs(BlameHangDumpType.ToArgs("--blame-hang-dump-type", "")) + .AddArgs(BlameHangTimeout.ToArgs("--blame-hang-timeout", "")) + .AddArgs(Configuration.ToArgs("--configuration", "")) + .AddArgs(Collect.ToArgs("--collect", "")) + .AddArgs(Diag.ToArgs("--diag", "")) + .AddArgs(Framework.ToArgs("--framework", "")) + .AddArgs(Filter.ToArgs("--filter", "")) + .AddArgs(Output.ToArgs("--output", "")) + .AddArgs(OS.ToArgs("--os", "")) + .AddArgs(ResultsDirectory.ToArgs("--results-directory", "")) + .AddArgs(Runtime.ToArgs("--runtime", "")) + .AddArgs(Settings.ToArgs("--settings", "")) + .AddArgs(Verbosity.ToArgs("--verbosity", "")) + .AddBooleanArgs( + ("--blame", Blame), + ("--blame-crash", BlameCrash), + ("--blame-crash-collect-always", BlameCrashCollectAlways), + ("--blame-hang", BlameHang), + ("--no-build", NoBuild), + ("--nologo", NoLogo), + ("--no-restore", NoRestore), + ("--list-tests", ListTests), + ("--diagnostics", Diagnostics) + ) + .AddProps("--property", Props.ToArray()) + .AddArgs(Args.ToArray()); + } + + /// + public override string ToString() => (ExecutablePath == string.Empty ? "dotnet" : Path.GetFileNameWithoutExtension(ExecutablePath)).GetShortName(".NET test driver used to execute unit tests.", ShortName, "test", Project.ToArg()); +} + +/// +/// Installs the specified .NET tool on your machine. +///

+/// This command provides a way for you to install .NET tools on your machine. +///

+///
.NET CLI command
+/// +/// +/// using HostApi; +/// +/// new DotNetToolInstall() +/// .WithLocal(true) +/// .WithPackage("dotnet-csi") +/// .Run().EnsureSuccess(); +/// +/// +///
+/// 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. +/// Adds an additional NuGet package source to use during installation. Feeds are accessed in parallel, not sequentially in some order of precedence. If the same package and version is in multiple feeds, the fastest feed wins. +/// Overrides the tool executable path. +/// Specifies the working directory for the tool to be started. +/// Name/ID of the NuGet package that contains the .NET tool to install. +/// Allow package downgrade when installing or updating a .NET tool package. Suppresses the warning, "The requested version x.x.x is lower than existing version x.x.x." +/// 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. +/// 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. +/// Applies to local tools. Available starting with .NET 8 SDK. To find a manifest, the search algorithm searches up the directory tree for dotnet-tools.json or a .config folder that contains a dotnet-tools.json file. If a tool-manifest can't be found and the --create-manifest-if-needed option is set to false, the CannotFindAManifestFile error occurs. If a tool-manifest can't be found and the --create-manifest-if-needed option is set to true, the tool creates a manifest automatically. +/// Disables restoring multiple projects in parallel. +/// Specifies the target framework to install the tool for. By default, the .NET SDK tries to choose the most appropriate target framework. +/// Specifies that the installation is user wide. Can't be combined with the --tool-path option. Omitting both --global and --tool-path specifies a local tool installation. +/// Treat package source failures as warnings. +/// Update the tool and the local tool manifest. Can't be combined with the --global option or the --tool-path option. +/// Specifies to not cache HTTP requests. +/// Include prerelease packages. +/// Path to the manifest file. +/// Specifies the location where to install the Global Tool. PATH can be absolute or relative. If PATH doesn't exist, the command tries to create it. Omitting both --global and --tool-path specifies a local tool installation. +/// Sets the verbosity level of the command. Allowed values are , , , , and . The default is . For more information, see . +/// The version of the tool to install. By default, the latest stable package version is installed. Use this option to install preview or older versions of the tool.
Starting with .NET 8.0, --version Major.Minor.Patch refers to a specific major/minor/patch version, including unlisted versions. To get the latest version of a certain major/minor version instead, use --version Major.Minor.*. +/// Enables diagnostic output. +/// Specifies a short name for this operation. +[Target] +public partial record DotNetToolInstall( + IEnumerable Args, + IEnumerable<(string name, string value)> Vars, + IEnumerable Sources, + string Package = "", + bool? AllowDowngrade = default, + string Arch = "", + string ConfigFile = "", + bool? CreateManifestIfNeeded = default, + bool? DisableParallel = default, + string Framework = "", + bool? Global = default, + bool? IgnoreFailedSources = default, + bool? Local = default, + bool? NoCache = default, + bool? Prerelease = default, + string ToolManifest = "", + string ToolPath = "", + DotNetVerbosity? Verbosity = default, + string Version = "", + bool? Diagnostics = default, + string ExecutablePath = "", + string WorkingDirectory = "", + string ShortName = "") +{ + /// + /// Create a new instance of the command. + /// + /// Specifies the set of command line arguments to use when starting the tool. + public DotNetToolInstall(params string[] args) + : this(args, [], []) + { + } + + /// + /// Create a new instance of the command. + /// + public DotNetToolInstall() + : this([], [], []) + { + } + + /// + public IStartInfo GetStartInfo(IHost host) + { + if (host == null) throw new ArgumentNullException(nameof(host)); + return host.CreateCommandLine(ExecutablePath) + .WithShortName(ToString()) + .WithWorkingDirectory(WorkingDirectory) + .WithVars(Vars.ToArray()) + .AddArgs("tool") + .AddArgs("install") + .AddNotEmptyArgs(Package.ToArg()) + .AddArgs(Sources.ToArgs("--add-source", "")) + .AddArgs(Arch.ToArgs("--arch", "")) + .AddArgs(ConfigFile.ToArgs("--configfile", "")) + .AddArgs(Framework.ToArgs("--framework", "")) + .AddArgs(ToolManifest.ToArgs("--tool-manifest", "")) + .AddArgs(ToolPath.ToArgs("--tool-path", "")) + .AddArgs(Verbosity.ToArgs("--verbosity", "")) + .AddArgs(Version.ToArgs("--version", "")) + .AddBooleanArgs( + ("--allow-downgrade", AllowDowngrade), + ("--create-manifest-if-needed", CreateManifestIfNeeded), + ("--disable-parallel", DisableParallel), + ("--global", Global), + ("--ignore-failed-sources", IgnoreFailedSources), + ("--local", Local), + ("--no-cache", NoCache), + ("--prerelease", Prerelease), + ("--diagnostics", Diagnostics) + ) + .AddArgs(Args.ToArray()); + } + + /// + public override string ToString() => (ExecutablePath == string.Empty ? "dotnet" : Path.GetFileNameWithoutExtension(ExecutablePath)).GetShortName("Installs the specified .NET tool on your machine.", ShortName, "tool", "install", Package.ToArg()); +} + +/// +/// Lists all .NET tools of the specified type currently installed on your machine. +///

+/// This command provides a way for you to list .NET global, tool-path, or local tools installed on your machine. The command lists the package name, version installed, and the tool command. +///

+///
.NET CLI command
+/// +/// +/// using HostApi; +/// +/// new DotNetToolList() +/// .WithLocal(true) +/// .Run().EnsureSuccess(); +/// +/// new DotNetToolList() +/// .WithGlobal(true) +/// .Run().EnsureSuccess(); +/// +/// +///
+/// 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. +/// Overrides the tool executable path. +/// Specifies the working directory for the tool to be started. +/// Lists the tool that has the supplied package ID if the tool is installed. Can be used in conjunction with options. Provides a way to check if a specific tool was installed. If no tool with the specified package ID is found, the command lists headings with no detail rows. +/// Lists user-wide global tools. Can't be combined with the --tool-path option. Omitting both --global and --tool-path lists local tools. +/// Lists local tools for the current directory. Can't be combined with the --global or --tool-path options. Omitting both --global and --tool-path lists local tools even if --local is not specified. +/// Specifies a custom location where to find global tools. PATH can be absolute or relative. Can't be combined with the --global option. Omitting both --global and --tool-path lists local tools. +/// Enables diagnostic output. +/// Specifies a short name for this operation. +[Target] +public partial record DotNetToolList( + IEnumerable Args, + IEnumerable<(string name, string value)> Vars, + string Package = "", + bool? Global = default, + bool? Local = default, + string ToolPath = "", + bool? Diagnostics = default, + string ExecutablePath = "", + string WorkingDirectory = "", + string ShortName = "") +{ + /// + /// Create a new instance of the command. + /// + /// Specifies the set of command line arguments to use when starting the tool. + public DotNetToolList(params string[] args) + : this(args, []) + { + } + + /// + /// Create a new instance of the command. + /// + public DotNetToolList() + : this([], []) + { + } + + /// + public IStartInfo GetStartInfo(IHost host) + { + if (host == null) throw new ArgumentNullException(nameof(host)); + return host.CreateCommandLine(ExecutablePath) + .WithShortName(ToString()) + .WithWorkingDirectory(WorkingDirectory) + .WithVars(Vars.ToArray()) + .AddArgs("tool") + .AddArgs("list") + .AddNotEmptyArgs(Package.ToArg()) + .AddArgs(ToolPath.ToArgs("--tool-path", "")) + .AddBooleanArgs( + ("--global", Global), + ("--local", Local), + ("--diagnostics", Diagnostics) + ) + .AddArgs(Args.ToArray()); + } + + /// + public override string ToString() => (ExecutablePath == string.Empty ? "dotnet" : Path.GetFileNameWithoutExtension(ExecutablePath)).GetShortName("Lists all .NET tools of the specified type currently installed on your machine.", ShortName, "tool", "list", Package.ToArg()); +} + +/// +/// Installs the .NET local tools that are in scope for the current directory. +///

+/// This command finds the tool manifest file that is in scope for the current directory and installs the tools that are listed in it. For information about manifest files, see Install a local tool and Invoke a local tool. +///

+///
.NET CLI command
+/// +/// +/// using HostApi; +/// +/// // Creates a local tool manifest +/// new DotNetNew() +/// .WithTemplateName("tool-manifest") +/// .Run().EnsureSuccess(); +/// +/// new DotNetToolRestore() +/// .Run().EnsureSuccess(); +/// +/// +///
+/// 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. +/// Adds an additional NuGet package source to use during installation. Feeds are accessed in parallel, not sequentially in some order of precedence. If the same package and version is in multiple feeds, the fastest feed wins. +/// Overrides the tool executable path. +/// Specifies the working directory for the tool to be started. +/// 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. +/// Path to the manifest file. +/// Disables restoring multiple projects in parallel. +/// Treat package source failures as warnings. +/// Specifies to not cache HTTP requests. +/// Sets the verbosity level of the command. Allowed values are , , , , and . The default is . For more information, see . +/// Enables diagnostic output. +/// Specifies a short name for this operation. +[Target] +public partial record DotNetToolRestore( + IEnumerable Args, + IEnumerable<(string name, string value)> Vars, + IEnumerable Sources, + string ConfigFile = "", + string ToolManifest = "", + bool? DisableParallel = default, + bool? IgnoreFailedSources = default, + bool? NoCache = default, + DotNetVerbosity? Verbosity = default, + bool? Diagnostics = default, + string ExecutablePath = "", + string WorkingDirectory = "", + string ShortName = "") +{ + /// + /// Create a new instance of the command. + /// + /// Specifies the set of command line arguments to use when starting the tool. + public DotNetToolRestore(params string[] args) + : this(args, [], []) + { + } + + /// + /// Create a new instance of the command. + /// + public DotNetToolRestore() + : this([], [], []) + { + } + + /// + public IStartInfo GetStartInfo(IHost host) + { + if (host == null) throw new ArgumentNullException(nameof(host)); + return host.CreateCommandLine(ExecutablePath) + .WithShortName(ToString()) + .WithWorkingDirectory(WorkingDirectory) + .WithVars(Vars.ToArray()) + .AddArgs("tool") + .AddArgs("restore") + .AddArgs(Sources.ToArgs("--add-source", "")) + .AddArgs(ConfigFile.ToArgs("--configfile", "")) + .AddArgs(ToolManifest.ToArgs("--tool-manifest", "")) + .AddArgs(Verbosity.ToArgs("--verbosity", "")) + .AddBooleanArgs( + ("--disable-parallel", DisableParallel), + ("--ignore-failed-sources", IgnoreFailedSources), + ("--no-cache", NoCache), + ("--diagnostics", Diagnostics) + ) + .AddArgs(Args.ToArray()); + } + + /// + public override string ToString() => (ExecutablePath == string.Empty ? "dotnet" : Path.GetFileNameWithoutExtension(ExecutablePath)).GetShortName("Installs the .NET local tools that are in scope for the current directory.", ShortName, "tool", "restore"); +} + +/// +/// Invokes a local tool. +///

+/// This command searches tool manifest files that are in scope for the current directory. When it finds a reference to the specified tool, it runs the tool. +///

+///
.NET CLI command
+/// +/// +/// using HostApi; +/// +/// var script = Path.GetTempFileName(); +/// File.WriteAllText(script, "Console.WriteLine($\"Hello, {Args[0]}!\");"); +/// +/// var stdOut = new List<string>(); +/// new DotNetToolRun() +/// .WithCommandName("dotnet-csi") +/// .AddArgs(script) +/// .AddArgs("World") +/// .Run(output => stdOut.Add(output.Line)) +/// .EnsureSuccess(); +/// +/// // Checks stdOut +/// stdOut.Contains("Hello, World!").ShouldBeTrue(); +/// +/// +///
+/// 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. +/// Overrides the tool executable path. +/// Specifies the working directory for the tool to be started. +/// The command name of the tool to run. +/// Enables diagnostic output. +/// Specifies a short name for this operation. +[Target] +public partial record DotNetToolRun( + IEnumerable Args, + IEnumerable<(string name, string value)> Vars, + string CommandName = "", + bool? Diagnostics = default, + string ExecutablePath = "", + string WorkingDirectory = "", + string ShortName = "") +{ + /// + /// Create a new instance of the command. + /// + /// Specifies the set of command line arguments to use when starting the tool. + public DotNetToolRun(params string[] args) + : this(args, []) + { + } + + /// + /// Create a new instance of the command. + /// + public DotNetToolRun() + : this([], []) + { + } + + /// + public IStartInfo GetStartInfo(IHost host) + { + if (host == null) throw new ArgumentNullException(nameof(host)); + return host.CreateCommandLine(ExecutablePath) + .WithShortName(ToString()) + .WithWorkingDirectory(WorkingDirectory) + .WithVars(Vars.ToArray()) + .AddArgs("tool") + .AddArgs("run") + .AddNotEmptyArgs(CommandName.ToArg()) + .AddBooleanArgs( + ("--diagnostics", Diagnostics) + ) + .AddArgs(Args.ToArray()); + } + + /// + public override string ToString() => (ExecutablePath == string.Empty ? "dotnet" : Path.GetFileNameWithoutExtension(ExecutablePath)).GetShortName("Invokes a local tool.", ShortName, "tool", "run", CommandName.ToArg()); +} + +/// +/// Searches all .NET tools that are published to NuGet. +///

+/// This command provides a way for you to search NuGet for tools that can be used as .NET global, tool-path, or local tools. The command searches the tool names and metadata such as titles, descriptions, and tags. +///

+///
.NET CLI command
+/// +/// +/// using HostApi; +/// +/// new DotNetToolSearch() +/// .WithPackage("dotnet-csi") +/// .WithDetail(true) +/// .Run().EnsureSuccess(); +/// +/// +///
+/// 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. +/// Overrides the tool executable path. +/// Specifies the working directory for the tool to be started. +/// Name/description of the NuGet package. +/// Shows detailed results from the query. +/// Includes pre-release packages. +/// Specifies the number of query results to skip. Used for pagination. +/// Specifies the number of query results to show. Used for pagination. +/// Enables diagnostic output. +/// Specifies a short name for this operation. +[Target] +public partial record DotNetToolSearch( + IEnumerable Args, + IEnumerable<(string name, string value)> Vars, + string Package = "", + bool? Detail = default, + bool? Prerelease = default, + int? Skip = default, + int? Take = default, + bool? Diagnostics = default, + string ExecutablePath = "", + string WorkingDirectory = "", + string ShortName = "") +{ + /// + /// Create a new instance of the command. + /// + /// Specifies the set of command line arguments to use when starting the tool. + public DotNetToolSearch(params string[] args) + : this(args, []) + { + } + + /// + /// Create a new instance of the command. + /// + public DotNetToolSearch() + : this([], []) + { + } + + /// + public IStartInfo GetStartInfo(IHost host) + { + if (host == null) throw new ArgumentNullException(nameof(host)); + return host.CreateCommandLine(ExecutablePath) + .WithShortName(ToString()) + .WithWorkingDirectory(WorkingDirectory) + .WithVars(Vars.ToArray()) + .AddArgs("tool") + .AddArgs("search") + .AddNotEmptyArgs(Package.ToArg()) + .AddArgs(Skip.ToArgs("--skip", "")) + .AddArgs(Take.ToArgs("--take", "")) + .AddBooleanArgs( + ("--detail", Detail), + ("--prerelease", Prerelease), + ("--diagnostics", Diagnostics) + ) + .AddArgs(Args.ToArray()); + } + + /// + public override string ToString() => (ExecutablePath == string.Empty ? "dotnet" : Path.GetFileNameWithoutExtension(ExecutablePath)).GetShortName("Searches all .NET tools that are published to NuGet.", ShortName, "tool", "search", Package.ToArg()); +} + +/// +/// Uninstalls the specified .NET tool from your machine. +///

+/// This command provides a way for you to uninstall .NET tools from your machine. +///

+///
.NET CLI command
+/// +/// +/// using HostApi; +/// +/// new DotNetToolUninstall() +/// .WithPackage("dotnet-csi") +/// .Run().EnsureSuccess(); +/// +/// +///
+/// 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. +/// Overrides the tool executable path. +/// Specifies the working directory for the tool to be started. +/// Name/ID of the NuGet package that contains the .NET tool to uninstall. You can find the package name using the dotnet tool list command. +/// Specifies that the tool to be removed is from a user-wide installation. Can't be combined with the --tool-path option. Omitting both --global and --tool-path specifies that the tool to be removed is a local tool. +/// Specifies the location where to uninstall the tool. PATH can be absolute or relative. Can't be combined with the --global option. Omitting both --global and --tool-path specifies that the tool to be removed is a local tool. +/// Specifies the manifest file that the tool is to be removed from. PATH can be absolute or relative. Can't be combined with the --global option. +/// Enables diagnostic output. +/// Specifies a short name for this operation. +[Target] +public partial record DotNetToolUninstall( + IEnumerable Args, + IEnumerable<(string name, string value)> Vars, + string Package = "", + bool? Global = default, + string ToolPath = "", + string ToolManifest = "", + bool? Diagnostics = default, + string ExecutablePath = "", + string WorkingDirectory = "", + string ShortName = "") +{ + /// + /// Create a new instance of the command. + /// + /// Specifies the set of command line arguments to use when starting the tool. + public DotNetToolUninstall(params string[] args) + : this(args, []) + { + } + + /// + /// Create a new instance of the command. + /// + public DotNetToolUninstall() + : this([], []) + { + } + + /// + public IStartInfo GetStartInfo(IHost host) + { + if (host == null) throw new ArgumentNullException(nameof(host)); + return host.CreateCommandLine(ExecutablePath) + .WithShortName(ToString()) + .WithWorkingDirectory(WorkingDirectory) + .WithVars(Vars.ToArray()) + .AddArgs("tool") + .AddArgs("uninstall") + .AddNotEmptyArgs(Package.ToArg()) + .AddArgs(ToolPath.ToArgs("--tool-path", "")) + .AddArgs(ToolManifest.ToArgs("--tool-manifest", "")) + .AddBooleanArgs( + ("--global", Global), + ("--diagnostics", Diagnostics) + ) + .AddArgs(Args.ToArray()); + } + + /// + public override string ToString() => (ExecutablePath == string.Empty ? "dotnet" : Path.GetFileNameWithoutExtension(ExecutablePath)).GetShortName("Uninstalls the specified .NET tool from your machine.", ShortName, "tool", "uninstall", Package.ToArg()); +} + +/// +/// Updates the specified .NET tool on your machine. +///

+/// This command provides a way for you to update .NET tools on your machine to the latest stable version of the package. The command uninstalls and reinstalls a tool, effectively updating it. +///

+///
.NET CLI command
+/// +/// +/// using HostApi; +/// +/// new DotNetToolUpdate() +/// .WithLocal(true) +/// .WithPackage("dotnet-csi") +/// .Run().EnsureSuccess(); +/// +/// +///
+/// 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. +/// Adds an additional NuGet package source to use during installation. Feeds are accessed in parallel, not sequentially in some order of precedence. If the same package and version is in multiple feeds, the fastest feed wins. +/// Overrides the tool executable path. +/// Specifies the working directory for the tool to be started. +/// Name/ID of the NuGet package that contains the .NET global tool to update. You can find the package name using the dotnet tool list command. +/// Allow package downgrade when installing or updating a .NET tool package. Suppresses the warning, "The requested version x.x.x is lower than existing version x.x.x." +/// 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. +/// Disables restoring multiple projects in parallel. +/// Specifies the target framework to update the tool for. +/// Specifies that the update is for a user-wide tool. Can't be combined with the --tool-path option. Omitting both --global and --tool-path specifies that the tool to be updated is a local tool. +/// Treat package source failures as warnings. +/// Update the tool and the local tool manifest. Can't be combined with the --global option or the --tool-path option. +/// Specifies to not cache HTTP requests. +/// Include prerelease packages. +/// Path to the manifest file. +/// Specifies the location where the global tool is installed. PATH can be absolute or relative. Can't be combined with the --global option. Omitting both --global and --tool-path specifies that the tool to be updated is a local tool. +/// Sets the verbosity level of the command. Allowed values are , , , , and . The default is . For more information, see . +/// The version range of the tool package to update to. This cannot be used to downgrade versions, you must uninstall newer versions first.
Starting in .NET 8.0, --version Major.Minor.Patch refers to a specific major.minor.patch version, including unlisted versions. To get the latest version of a certain major.minor version instead, use --version Major.Minor.*. +/// Enables diagnostic output. +/// Specifies a short name for this operation. +[Target] +public partial record DotNetToolUpdate( + IEnumerable Args, + IEnumerable<(string name, string value)> Vars, + IEnumerable Sources, + string Package = "", + bool? AllowDowngrade = default, + string ConfigFile = "", + bool? DisableParallel = default, + string Framework = "", + bool? Global = default, + bool? IgnoreFailedSources = default, + bool? Local = default, + bool? NoCache = default, + bool? Prerelease = default, + string ToolManifest = "", + string ToolPath = "", + DotNetVerbosity? Verbosity = default, + string Version = "", + bool? Diagnostics = default, + string ExecutablePath = "", + string WorkingDirectory = "", + string ShortName = "") +{ + /// + /// Create a new instance of the command. + /// + /// Specifies the set of command line arguments to use when starting the tool. + public DotNetToolUpdate(params string[] args) + : this(args, [], []) + { + } + + /// + /// Create a new instance of the command. + /// + public DotNetToolUpdate() + : this([], [], []) + { + } + + /// + public IStartInfo GetStartInfo(IHost host) + { + if (host == null) throw new ArgumentNullException(nameof(host)); + return host.CreateCommandLine(ExecutablePath) + .WithShortName(ToString()) + .WithWorkingDirectory(WorkingDirectory) + .WithVars(Vars.ToArray()) + .AddArgs("tool") + .AddArgs("update") + .AddNotEmptyArgs(Package.ToArg()) + .AddArgs(Sources.ToArgs("--add-source", "")) + .AddArgs(ConfigFile.ToArgs("--configfile", "")) + .AddArgs(Framework.ToArgs("--framework", "")) + .AddArgs(ToolManifest.ToArgs("--tool-manifest", "")) + .AddArgs(ToolPath.ToArgs("--tool-path", "")) + .AddArgs(Verbosity.ToArgs("--verbosity", "")) + .AddArgs(Version.ToArgs("--version", "")) + .AddBooleanArgs( + ("--allow-downgrade", AllowDowngrade), + ("--disable-parallel", DisableParallel), + ("--global", Global), + ("--ignore-failed-sources", IgnoreFailedSources), + ("--local", Local), + ("--no-cache", NoCache), + ("--prerelease", Prerelease), + ("--diagnostics", Diagnostics) + ) + .AddArgs(Args.ToArray()); + } + + /// + public override string ToString() => (ExecutablePath == string.Empty ? "dotnet" : Path.GetFileNameWithoutExtension(ExecutablePath)).GetShortName("Updates the specified .NET tool on your machine.", ShortName, "tool", "update", Package.ToArg()); +} + +/// +/// Provides information about the available workload commands and installed workloads. +///

+/// This command provides commands for working with .NET workloads. +///

+///
.NET CLI command
+///
+/// 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. +/// Overrides the tool executable path. +/// Specifies the working directory for the tool to be started. +/// Displays the current workload set version. +/// Prints out detailed information about installed workloads, including their installation source, manifest version, manifest path, and install type. +/// Enables diagnostic output. +/// Specifies a short name for this operation. +[Target] +public partial record DotNetWorkload( + IEnumerable Args, + IEnumerable<(string name, string value)> Vars, + bool? Version = default, + bool? Info = default, + bool? Diagnostics = default, + string ExecutablePath = "", + string WorkingDirectory = "", + string ShortName = "") +{ + /// + /// Create a new instance of the command. + /// + /// Specifies the set of command line arguments to use when starting the tool. + public DotNetWorkload(params string[] args) + : this(args, []) + { + } + + /// + /// Create a new instance of the command. + /// + public DotNetWorkload() + : this([], []) + { + } + + /// + public IStartInfo GetStartInfo(IHost host) + { + if (host == null) throw new ArgumentNullException(nameof(host)); + return host.CreateCommandLine(ExecutablePath) + .WithShortName(ToString()) + .WithWorkingDirectory(WorkingDirectory) + .WithVars(Vars.ToArray()) + .AddArgs("workload") + .AddBooleanArgs( + ("--version", Version), + ("--info", Info), + ("--diagnostics", Diagnostics) + ) + .AddArgs(Args.ToArray()); + } + + /// + public override string ToString() => (ExecutablePath == string.Empty ? "dotnet" : Path.GetFileNameWithoutExtension(ExecutablePath)).GetShortName("Provides information about the available workload commands and installed workloads.", ShortName, "workload"); +} + +/// +/// Enables or disables workload-set update mode. +///
.NET CLI command
+/// +/// +/// using HostApi; +/// +/// new DotNetWorkloadConfig() +/// .WithUpdateMode(DotNetWorkloadUpdateMode.WorkloadSet) +/// .Run().EnsureSuccess(); +/// +/// +///
+/// 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. +/// Overrides the tool executable path. +/// Specifies the working directory for the tool to be started. +/// Controls whether updates look for workload set versions or individual manifest versions. To display the current mode, specify this option without an argument. +/// Enables diagnostic output. +/// Specifies a short name for this operation. +[Target] +public partial record DotNetWorkloadConfig( + IEnumerable Args, + IEnumerable<(string name, string value)> Vars, + DotNetWorkloadUpdateMode? UpdateMode = default, + bool? Diagnostics = default, + string ExecutablePath = "", + string WorkingDirectory = "", + string ShortName = "") +{ + /// + /// Create a new instance of the command. + /// + /// Specifies the set of command line arguments to use when starting the tool. + public DotNetWorkloadConfig(params string[] args) + : this(args, []) + { + } + + /// + /// Create a new instance of the command. + /// + public DotNetWorkloadConfig() + : this([], []) + { + } + + /// + public IStartInfo GetStartInfo(IHost host) + { + if (host == null) throw new ArgumentNullException(nameof(host)); + return host.CreateCommandLine(ExecutablePath) + .WithShortName(ToString()) + .WithWorkingDirectory(WorkingDirectory) + .WithVars(Vars.ToArray()) + .AddArgs("workload") + .AddArgs("config") + .AddArgs(UpdateMode.ToArgs("--update-mode", "")) + .AddBooleanArgs( + ("--diagnostics", Diagnostics) + ) + .AddArgs(Args.ToArray()); + } + + /// + public override string ToString() => (ExecutablePath == string.Empty ? "dotnet" : Path.GetFileNameWithoutExtension(ExecutablePath)).GetShortName("Enables or disables workload-set update mode.", ShortName, "workload", "config"); +} + +/// +/// Installs optional workloads. +///

+/// This command installs one or more optional workloads. Optional workloads can be installed on top of the .NET SDK to provide support for various application types, such as .NET MAUI and Blazor WebAssembly AOT. +///

+///
.NET CLI command
+/// +/// +/// using HostApi; +/// +/// new DotNetWorkloadInstall() +/// .AddWorkloads("aspire") +/// .Run().EnsureSuccess(); +/// +/// +///
+/// 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. +/// The workload ID or multiple IDs to install. Use dotnet workload search to learn what workloads are available. +/// The URI of the NuGet package source to use during this operation. +/// Overrides the tool executable path. +/// Specifies the working directory for the tool to be started. +/// 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. +/// Disables restoring multiple projects in parallel. +/// Treat package source failures as warnings. +/// Allows prerelease workload manifests. +/// Specifies to not cache HTTP requests. +/// Skip updating the workload manifests. The workload manifests define what assets and versions need to be installed for each workload. +/// Specify the temporary directory used to download and extract NuGet packages (must be secure). +/// Sets the verbosity level of the command. Allowed values are , , , , and . The default is . For more information, see . +/// The workload set version to install or update to. If you specify the workload-set version in global.json, you can't use the --version option to specify the workload-set version. To make it possible to use the --version option in that case, run the command outside of the path containing the global.json file. Available since 8.0.400 SDK. +/// Enables diagnostic output. +/// Specifies a short name for this operation. +[Target] +public partial record DotNetWorkloadInstall( + IEnumerable Args, + IEnumerable<(string name, string value)> Vars, + IEnumerable Workloads, + IEnumerable Sources, + string ConfigFile = "", + bool? DisableParallel = default, + bool? IgnoreFailedSources = default, + bool? IncludePreviews = default, + bool? NoCache = default, + bool? SkipManifestUpdate = default, + string TempDir = "", + DotNetVerbosity? Verbosity = default, + bool? Version = default, + bool? Diagnostics = default, + string ExecutablePath = "", + string WorkingDirectory = "", + string ShortName = "") +{ + /// + /// Create a new instance of the command. + /// + /// Specifies the set of command line arguments to use when starting the tool. + public DotNetWorkloadInstall(params string[] args) + : this(args, [], [], []) + { + } + + /// + /// Create a new instance of the command. + /// + public DotNetWorkloadInstall() + : this([], [], [], []) + { + } + + /// + public IStartInfo GetStartInfo(IHost host) + { + if (host == null) throw new ArgumentNullException(nameof(host)); + return host.CreateCommandLine(ExecutablePath) + .WithShortName(ToString()) + .WithWorkingDirectory(WorkingDirectory) + .WithVars(Vars.ToArray()) + .AddArgs("workload") + .AddArgs("install") + .AddNotEmptyArgs(Workloads.ToArray()) + .AddArgs(Sources.ToArgs("--source", "")) + .AddArgs(ConfigFile.ToArgs("--configfile", "")) + .AddArgs(TempDir.ToArgs("--temp-dir", "")) + .AddArgs(Verbosity.ToArgs("--verbosity", "")) + .AddBooleanArgs( + ("--disable-parallel", DisableParallel), + ("--ignore-failed-sources", IgnoreFailedSources), + ("--include-previews", IncludePreviews), + ("--no-cache", NoCache), + ("--skip-manifest-update", SkipManifestUpdate), + ("--version", Version), + ("--diagnostics", Diagnostics) + ) + .AddArgs(Args.ToArray()); + } + + /// + public override string ToString() => (ExecutablePath == string.Empty ? "dotnet" : Path.GetFileNameWithoutExtension(ExecutablePath)).GetShortName("Installs optional workloads.", ShortName, new [] {"workload", "install"}.Concat(Workloads).ToArray()); +} + +/// +/// Lists installed workloads. +///

+/// This command lists all installed workloads. +///

+///
.NET CLI command
+/// +/// +/// using HostApi; +/// +/// new DotNetWorkloadList() +/// .Run().EnsureSuccess(); +/// +/// +///
+/// 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. +/// Overrides the tool executable path. +/// Specifies the working directory for the tool to be started. +/// Sets the verbosity level of the command. Allowed values are , , , , and . The default is . For more information, see . +/// Enables diagnostic output. +/// Specifies a short name for this operation. +[Target] +public partial record DotNetWorkloadList( + IEnumerable Args, + IEnumerable<(string name, string value)> Vars, + DotNetVerbosity? Verbosity = default, + bool? Diagnostics = default, + string ExecutablePath = "", + string WorkingDirectory = "", + string ShortName = "") +{ + /// + /// Create a new instance of the command. + /// + /// Specifies the set of command line arguments to use when starting the tool. + public DotNetWorkloadList(params string[] args) + : this(args, []) + { + } + + /// + /// Create a new instance of the command. + /// + public DotNetWorkloadList() + : this([], []) + { + } + + /// + public IStartInfo GetStartInfo(IHost host) + { + if (host == null) throw new ArgumentNullException(nameof(host)); + return host.CreateCommandLine(ExecutablePath) + .WithShortName(ToString()) + .WithWorkingDirectory(WorkingDirectory) + .WithVars(Vars.ToArray()) + .AddArgs("workload") + .AddArgs("list") + .AddArgs(Verbosity.ToArgs("--verbosity", "")) + .AddBooleanArgs( + ("--diagnostics", Diagnostics) + ) + .AddArgs(Args.ToArray()); + } + + /// + public override string ToString() => (ExecutablePath == string.Empty ? "dotnet" : Path.GetFileNameWithoutExtension(ExecutablePath)).GetShortName("Lists installed workloads.", ShortName, "workload", "list"); +} + +/// +/// Repairs workloads installations. +///

+/// This command reinstalls all installed workloads. Workloads are made up of multiple workload packs and it's possible to get into a state where some installed successfully but others didn't. +///

+///
.NET CLI command
+/// +/// +/// using HostApi; +/// +/// new DotNetWorkloadRepair() +/// .Run().EnsureSuccess(); +/// +/// +///
+/// 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. +/// The URI of the NuGet package source to use during this operation. +/// Overrides the tool executable path. +/// Specifies the working directory for the tool to be started. +/// 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. +/// Disables restoring multiple projects in parallel. +/// Treat package source failures as warnings. +/// Allows prerelease workload manifests. +/// Specifies to not cache HTTP requests. +/// Specify the temporary directory used to download and extract NuGet packages (must be secure). +/// Sets the verbosity level of the command. Allowed values are , , , , and . The default is . For more information, see . +/// Enables diagnostic output. +/// Specifies a short name for this operation. +[Target] +public partial record DotNetWorkloadRepair( + IEnumerable Args, + IEnumerable<(string name, string value)> Vars, + IEnumerable Sources, + string ConfigFile = "", + bool? DisableParallel = default, + bool? IgnoreFailedSources = default, + bool? IncludePreviews = default, + bool? NoCache = default, + string TempDir = "", + DotNetVerbosity? Verbosity = default, + bool? Diagnostics = default, + string ExecutablePath = "", + string WorkingDirectory = "", + string ShortName = "") +{ + /// + /// Create a new instance of the command. + /// + /// Specifies the set of command line arguments to use when starting the tool. + public DotNetWorkloadRepair(params string[] args) + : this(args, [], []) + { + } + + /// + /// Create a new instance of the command. + /// + public DotNetWorkloadRepair() + : this([], [], []) + { + } + + /// + public IStartInfo GetStartInfo(IHost host) + { + if (host == null) throw new ArgumentNullException(nameof(host)); + return host.CreateCommandLine(ExecutablePath) + .WithShortName(ToString()) + .WithWorkingDirectory(WorkingDirectory) + .WithVars(Vars.ToArray()) + .AddArgs("workload") + .AddArgs("repair") + .AddArgs(Sources.ToArgs("--source", "")) + .AddArgs(ConfigFile.ToArgs("--configfile", "")) + .AddArgs(TempDir.ToArgs("--temp-dir", "")) + .AddArgs(Verbosity.ToArgs("--verbosity", "")) + .AddBooleanArgs( + ("--disable-parallel", DisableParallel), + ("--ignore-failed-sources", IgnoreFailedSources), + ("--include-previews", IncludePreviews), + ("--no-cache", NoCache), + ("--diagnostics", Diagnostics) + ) + .AddArgs(Args.ToArray()); + } + + /// + public override string ToString() => (ExecutablePath == string.Empty ? "dotnet" : Path.GetFileNameWithoutExtension(ExecutablePath)).GetShortName("Repairs workloads installations.", ShortName, "workload", "repair"); +} + +/// +/// Installs workloads needed for a project or a solution. +///

+/// This command analyzes a project or solution to determine which workloads it needs, then installs any workloads that are missing. +///

+///
.NET CLI command
+/// +/// +/// using HostApi; +/// +/// new DotNetWorkloadRestore() +/// .WithProject(Path.Combine("MyLib", "MyLib.csproj")) +/// .Run().EnsureSuccess(); +/// +/// +///
+/// 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. +/// The URI of the NuGet package source to use during this operation. +/// Overrides the tool executable path. +/// Specifies the working directory for the tool to be started. +/// The project or solution file to install workloads for. If a file is not specified, the command searches the current directory for one. +/// 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. +/// Disables restoring multiple projects in parallel. +/// Treat package source failures as warnings. +/// Allows prerelease workload manifests. +/// Specifies to not cache HTTP requests. +/// Skip updating the workload manifests. The workload manifests define what assets and versions need to be installed for each workload. +/// Specify the temporary directory used to download and extract NuGet packages (must be secure). +/// Sets the verbosity level of the command. Allowed values are , , , , and . The default is . For more information, see . +/// The workload set version to install or update to. If you specify the workload-set version in global.json, you can't use the --version option to specify the workload-set version. To make it possible to use the --version option in that case, run the command outside of the path containing the global.json file. Available since 8.0.400 SDK. +/// Enables diagnostic output. +/// Specifies a short name for this operation. +[Target] +public partial record DotNetWorkloadRestore( + IEnumerable Args, + IEnumerable<(string name, string value)> Vars, + IEnumerable Sources, + string Project = "", + string ConfigFile = "", + bool? DisableParallel = default, + bool? IgnoreFailedSources = default, + bool? IncludePreviews = default, + bool? NoCache = default, + bool? SkipManifestUpdate = default, + string TempDir = "", + DotNetVerbosity? Verbosity = default, + bool? Version = default, + bool? Diagnostics = default, + string ExecutablePath = "", + string WorkingDirectory = "", + string ShortName = "") +{ + /// + /// Create a new instance of the command. + /// + /// Specifies the set of command line arguments to use when starting the tool. + public DotNetWorkloadRestore(params string[] args) + : this(args, [], []) + { + } + + /// + /// Create a new instance of the command. + /// + public DotNetWorkloadRestore() + : this([], [], []) + { + } + + /// + public IStartInfo GetStartInfo(IHost host) + { + if (host == null) throw new ArgumentNullException(nameof(host)); + return host.CreateCommandLine(ExecutablePath) + .WithShortName(ToString()) + .WithWorkingDirectory(WorkingDirectory) + .WithVars(Vars.ToArray()) + .AddArgs("workload") + .AddArgs("restore") + .AddNotEmptyArgs(Project.ToArg()) + .AddArgs(Sources.ToArgs("--source", "")) + .AddArgs(ConfigFile.ToArgs("--configfile", "")) + .AddArgs(TempDir.ToArgs("--temp-dir", "")) + .AddArgs(Verbosity.ToArgs("--verbosity", "")) + .AddBooleanArgs( + ("--disable-parallel", DisableParallel), + ("--ignore-failed-sources", IgnoreFailedSources), + ("--include-previews", IncludePreviews), + ("--no-cache", NoCache), + ("--skip-manifest-update", SkipManifestUpdate), + ("--version", Version), + ("--diagnostics", Diagnostics) + ) + .AddArgs(Args.ToArray()); + } + + /// + public override string ToString() => (ExecutablePath == string.Empty ? "dotnet" : Path.GetFileNameWithoutExtension(ExecutablePath)).GetShortName("Installs workloads needed for a project or a solution.", ShortName, "workload", "restore", Project.ToArg()); +} + +/// +/// Searches for optional workloads. +///

+/// This command lists available workloads. You can filter the list by specifying all or part of the workload ID you're looking for. +///

+///
.NET CLI command
+/// +/// +/// using HostApi; +/// +/// new DotNetWorkloadSearch() +/// .WithSearchString("maui") +/// .Run().EnsureSuccess(); +/// +/// +///
+/// 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. +/// Overrides the tool executable path. +/// Specifies the working directory for the tool to be started. +/// The workload ID to search for, or part of it. For example, if you specify maui, the command lists all of the workload IDs that have maui in their workload ID. +/// Sets the verbosity level of the command. Allowed values are , , , , and . The default is . For more information, see . +/// Enables diagnostic output. +/// Specifies a short name for this operation. +[Target] +public partial record DotNetWorkloadSearch( + IEnumerable Args, + IEnumerable<(string name, string value)> Vars, + string SearchString = "", + DotNetVerbosity? Verbosity = default, + bool? Diagnostics = default, + string ExecutablePath = "", + string WorkingDirectory = "", + string ShortName = "") +{ + /// + /// Create a new instance of the command. + /// + /// Specifies the set of command line arguments to use when starting the tool. + public DotNetWorkloadSearch(params string[] args) + : this(args, []) + { + } + + /// + /// Create a new instance of the command. + /// + public DotNetWorkloadSearch() + : this([], []) + { + } + + /// + public IStartInfo GetStartInfo(IHost host) + { + if (host == null) throw new ArgumentNullException(nameof(host)); + return host.CreateCommandLine(ExecutablePath) + .WithShortName(ToString()) + .WithWorkingDirectory(WorkingDirectory) + .WithVars(Vars.ToArray()) + .AddArgs("workload") + .AddArgs("search") + .AddNotEmptyArgs(SearchString.ToArg()) + .AddArgs(Verbosity.ToArgs("--verbosity", "")) + .AddBooleanArgs( + ("--diagnostics", Diagnostics) + ) + .AddArgs(Args.ToArray()); + } + + /// + public override string ToString() => (ExecutablePath == string.Empty ? "dotnet" : Path.GetFileNameWithoutExtension(ExecutablePath)).GetShortName("Searches for optional workloads.", ShortName, "workload", "search", SearchString.ToArg()); +} + +/// +/// Uninstalls a specified workload. +///

+/// This command uninstalls one or more workloads. +///

+///
.NET CLI command
+/// +/// +/// using HostApi; +/// +/// new DotNetWorkloadUninstall() +/// .AddWorkloads("aspire") +/// .Run().EnsureSuccess(); +/// +/// +///
+/// 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. +/// The workload ID or multiple IDs to uninstall. +/// Overrides the tool executable path. +/// Specifies the working directory for the tool to be started. +/// Enables diagnostic output. +/// Specifies a short name for this operation. +[Target] +public partial record DotNetWorkloadUninstall( + IEnumerable Args, + IEnumerable<(string name, string value)> Vars, + IEnumerable Workloads, + bool? Diagnostics = default, + string ExecutablePath = "", + string WorkingDirectory = "", + string ShortName = "") +{ + /// + /// Create a new instance of the command. + /// + /// Specifies the set of command line arguments to use when starting the tool. + public DotNetWorkloadUninstall(params string[] args) + : this(args, [], []) + { + } + + /// + /// Create a new instance of the command. + /// + public DotNetWorkloadUninstall() + : this([], [], []) + { + } + + /// + public IStartInfo GetStartInfo(IHost host) + { + if (host == null) throw new ArgumentNullException(nameof(host)); + return host.CreateCommandLine(ExecutablePath) + .WithShortName(ToString()) + .WithWorkingDirectory(WorkingDirectory) + .WithVars(Vars.ToArray()) + .AddArgs("workload") + .AddArgs("uninstall") + .AddNotEmptyArgs(Workloads.ToArray()) + .AddBooleanArgs( + ("--diagnostics", Diagnostics) + ) + .AddArgs(Args.ToArray()); + } + + /// + public override string ToString() => (ExecutablePath == string.Empty ? "dotnet" : Path.GetFileNameWithoutExtension(ExecutablePath)).GetShortName("Uninstalls a specified workload.", ShortName, new [] {"workload", "uninstall"}.Concat(Workloads).ToArray()); +} + +/// +/// Updates installed workloads. +///

+/// This command updates all installed workloads to the newest available versions. It queries Nuget.org for updated workload manifests. It then updates local manifests, downloads new versions of the installed workloads, and removes all old versions of each workload. When the command is in workload-set update mode, workloads are updated according to the workload-set version, not the latest version of each individual workload. +///

+///
.NET CLI command
+/// +/// +/// using HostApi; +/// +/// new DotNetWorkloadUpdate() +/// .Run().EnsureSuccess(); +/// +/// +///
+/// 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. +/// The URI of the NuGet package source to use during this operation. +/// Overrides the tool executable path. +/// Specifies the working directory for the tool to be started. +/// Downloads advertising manifests but doesn't update any workloads. +/// 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. +/// Disables restoring multiple projects in parallel. +/// Include workloads installed with previous SDK versions in the update. +/// Treat package source failures as warnings. +/// Allows prerelease workload manifests. +/// Specifies to not cache HTTP requests. +/// Specify the temporary directory used to download and extract NuGet packages (must be secure). +/// Sets the verbosity level of the command. Allowed values are , , , , and . The default is . For more information, see . +/// The workload set version to install or update to. If you specify the workload-set version in global.json, you can't use the --version option to specify the workload-set version. To make it possible to use the --version option in that case, run the command outside of the path containing the global.json file. Available since 8.0.400 SDK. +/// Enables diagnostic output. +/// Specifies a short name for this operation. +[Target] +public partial record DotNetWorkloadUpdate( + IEnumerable Args, + IEnumerable<(string name, string value)> Vars, + IEnumerable Sources, + bool? AdvertisingManifestsOnly = default, + string ConfigFile = "", + bool? DisableParallel = default, + bool? FromPreviousSdk = default, + bool? IgnoreFailedSources = default, + bool? IncludePreviews = default, + bool? NoCache = default, + string TempDir = "", + DotNetVerbosity? Verbosity = default, + bool? Version = default, + bool? Diagnostics = default, + string ExecutablePath = "", + string WorkingDirectory = "", + string ShortName = "") +{ + /// + /// Create a new instance of the command. + /// + /// Specifies the set of command line arguments to use when starting the tool. + public DotNetWorkloadUpdate(params string[] args) + : this(args, [], []) + { + } + + /// + /// Create a new instance of the command. + /// + public DotNetWorkloadUpdate() + : this([], [], []) + { + } + + /// + public IStartInfo GetStartInfo(IHost host) + { + if (host == null) throw new ArgumentNullException(nameof(host)); + return host.CreateCommandLine(ExecutablePath) + .WithShortName(ToString()) + .WithWorkingDirectory(WorkingDirectory) + .WithVars(Vars.ToArray()) + .AddArgs("workload") + .AddArgs("update") + .AddArgs(Sources.ToArgs("--source", "")) + .AddArgs(ConfigFile.ToArgs("--configfile", "")) + .AddArgs(TempDir.ToArgs("--temp-dir", "")) + .AddArgs(Verbosity.ToArgs("--verbosity", "")) + .AddBooleanArgs( + ("--advertising-manifests-only", AdvertisingManifestsOnly), + ("--disable-parallel", DisableParallel), + ("--from-previous-sdk", FromPreviousSdk), + ("--ignore-failed-sources", IgnoreFailedSources), + ("--include-previews", IncludePreviews), + ("--no-cache", NoCache), + ("--version", Version), + ("--diagnostics", Diagnostics) + ) + .AddArgs(Args.ToArray()); + } + + /// + public override string ToString() => (ExecutablePath == string.Empty ? "dotnet" : Path.GetFileNameWithoutExtension(ExecutablePath)).GetShortName("Updates installed workloads.", ShortName, "workload", "update"); +} + +/// +/// Runs a C# script. +///
C# interactive
+/// +/// +/// using HostApi; +/// +/// var script = Path.GetTempFileName(); +/// File.WriteAllText(script, "Console.WriteLine($\"Hello, {Args[0]}!\");"); +/// +/// var stdOut = new List<string>(); +/// new DotNetCsi() +/// .WithScript(script) +/// .AddArgs("World") +/// .Run(output => stdOut.Add(output.Line)) +/// .EnsureSuccess(); +/// +/// // Checks stdOut +/// stdOut.Contains("Hello, World!").ShouldBeTrue(); +/// +/// +///
+/// 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. +/// MSBuild options for setting properties. +/// The URI of the NuGet package source to use during this operation. +/// Overrides the tool executable path. +/// Specifies the working directory for the tool to be started. +/// Script to execute. +/// Prints out the version. +/// Enables diagnostic output. +/// Specifies a short name for this operation. +[Target] +public partial record DotNetCsi( + IEnumerable Args, + IEnumerable<(string name, string value)> Vars, + IEnumerable<(string name, string value)> Props, + IEnumerable Sources, + string Script = "", + bool? Version = default, + bool? Diagnostics = default, + string ExecutablePath = "", + string WorkingDirectory = "", + string ShortName = "") +{ + /// + /// Create a new instance of the command. + /// + /// Specifies the set of command line arguments to use when starting the tool. + public DotNetCsi(params string[] args) + : this(args, [], [], []) + { + } + + /// + /// Create a new instance of the command. + /// + public DotNetCsi() + : this([], [], [], []) + { + } + + /// + public IStartInfo GetStartInfo(IHost host) + { + if (host == null) throw new ArgumentNullException(nameof(host)); + return host.CreateCommandLine(ExecutablePath) + .WithShortName(ToString()) + .WithWorkingDirectory(WorkingDirectory) + .WithVars(Vars.ToArray()) + .AddArgs("csi") + .AddNotEmptyArgs(Script.ToArg()) + .AddArgs(Sources.ToArgs("--source", "")) + .AddBooleanArgs( + ("--version", Version), + ("--diagnostics", Diagnostics) + ) + .AddProps("--property", Props.ToArray()) + .AddArgs(Args.ToArray()); + } + + /// + public override string ToString() => (ExecutablePath == string.Empty ? "dotnet" : Path.GetFileNameWithoutExtension(ExecutablePath)).GetShortName("Runs a C# script.", ShortName, "csi", Script.ToArg()); +} diff --git a/CSharpInteractive.HostApi/DotNetCommands.tt b/CSharpInteractive.HostApi/DotNetCommands.tt new file mode 100644 index 00000000..57d8371b --- /dev/null +++ b/CSharpInteractive.HostApi/DotNetCommands.tt @@ -0,0 +1,1920 @@ +<#@ import namespace="System.Linq" #> +<#@ import namespace="System.Collections.Generic" #> +<#@ import namespace="System.IO" #> +<#@ import namespace="System.Xml" #> +// ReSharper disable UnusedMember.Global +// ReSharper disable InconsistentNaming +namespace HostApi; +using Internal.DotNet; +using Internal; +<# + const string paraStart = "

"; + const string paraFinish = "

"; + const string exampleStart = ""; + const string exampleFinish = ""; + const string codeStart = ""; + const string codeFinish = ""; + + 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 solutionArg = new Arg("Solution", "", "string", "The solution file to use. If this argument is omitted, the command searches the current directory for one. If it finds no solution file or multiple solution files, the command fails.") { 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 diagnosticsArg = new Arg("Diagnostics", "--diagnostics", "bool?", "Enables diagnostic output."); + 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 this command."); + var noRestoreArg = new Arg("NoRestore", "--no-restore", "bool?", "Doesn't execute an implicit restore when running the command."); + 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 configFileArg = 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."); + var sourcesArg = new Arg("Sources", "--source", "IEnumerable", "The URI of the NuGet package source to use during this operation.") { IsCollection = true }; + var manifestArg = new Arg("Manifests", "--manifest", "IEnumerable", "Specifies one or several target manifests to use to trim the set of packages published with the app. The manifest file is part of the output of the dotnet store command.") { IsCollection = true }; + var disableParallelArg = new Arg("DisableParallel", "--disable-parallel", "bool?", "Disables restoring multiple projects in parallel."); + var ignoreFailedSourcesArg = new Arg("IgnoreFailedSources", "--ignore-failed-sources", "bool?", "Treat package source failures as warnings."); + var noCacheArg = new Arg("NoCache", "--no-cache", "bool?", "Specifies to not cache HTTP requests."); + var includePreviewsArg = new Arg("IncludePreviews", "--include-previews", "bool?", "Allows prerelease workload manifests."); + var skipManifestUpdateArg = new Arg("SkipManifestUpdate", "--skip-manifest-update", "bool?", "Skip updating the workload manifests. The workload manifests define what assets and versions need to be installed for each workload."); + var tempDirArg = new Arg("TempDir", "--temp-dir", "string", "Specify the temporary directory used to download and extract NuGet packages (must be secure)."); + var includesArg = new Arg("Includes", "--include", "IEnumerable", "A list of relative file or folder paths to include in formatting. The default is all files in the solution or project.") {IsCollection = true, CollectionSeparator = " "}; + var excludesArg = new Arg("Excludes", "--exclude", "IEnumerable", "A space-separated list of relative file or folder paths to exclude from formatting. The default is none.") {IsCollection = true, CollectionSeparator = " "}; + var dotNetFormatSeverityArg = new Arg("Severity", "--severity", "DotNetFormatSeverity?", "The minimum severity of diagnostics to fix. Allowed values are Information, Warning, and Error. The default value is Warning."); + var verifyNoChangesArg = new Arg("VerifyNoChanges", "--verify-no-changes", "bool?", "Verifies that no formatting changes would be performed. Terminates with a non zero exit code if any files would have been formatted."); + var includeGeneratedArg = new Arg("IncludeGenerated", "--include-generated", "bool?", "Formats files generated by the SDK."); + var binaryLogArg = new Arg("BinaryLog", "--binarylog", "string", "Logs all project or solution load information to a binary log file."); + var reportArg = new Arg("Report", "--report", "string", "Produces a JSON report in the specified directory."); + var formatDiagnosticsArg = new Arg("Diagnostics", "--diagnostics", "IEnumerable", "A list of diagnostic IDs to use as a filter when fixing code style or third-party issues. Default value is whichever IDs are listed in the .editorconfig file. For a list of built-in analyzer rule IDs that you can specify, see the list of IDs for code-analysis style rules.") {IsCollection = true, CollectionSeparator = " "}; + + var commands = new Command[] + { + new( + "DotNet", + "Runs a dotnet application.", + [ + paraStart, + "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.", + paraFinish, + CreateCliRef("dotnet") + ], + ["$PathToApplication"], + [ + additionalProbingPathsArg, + pathToApplicationArg, + additionalDepsArg, + fxVersionArg, + rollForwardArg, + diagnosticsArg, + new Arg("Info", "--info", "bool?", "Prints out detailed information about a .NET installation and the machine environment, such as the current operating system, and commit SHA of the .NET version."), + new Arg("Version", "--version", "bool?", "Prints out the version of the .NET SDK used by dotnet commands, which may be affected by a global.json file."), + new Arg("ListRuntimes", "--list-runtimes", "bool?", "Prints out a list of the installed .NET runtimes. An x86 version of the SDK lists only x86 runtimes, and an x64 version of the SDK lists only x64 runtimes."), + new Arg("ListSdks", "--list-sdks", "bool?", "Prints out a list of the installed .NET SDKs.") + ] + ), + new( + "DotNetExec", + "Executes a dotnet application.", + [ + paraStart, + "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.", + paraFinish, + CreateCliRef("dotnet") + ], + ["exec", "$PathToApplication"], + [ + 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."), + diagnosticsArg + ] + ), + new( + "DotNetAddPackage", + "Adds or updates a package reference in a project file.", + [ + paraStart, + "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.", + paraFinish, + CreateCliRef("dotnet-add-package") + ], + ["add", "$Project", "package", "$Package"], + [ + sourcesArg, + projectArg, + new Arg("Package", "", "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"), + diagnosticsArg + ] + ), + new( + "DotNetListPackage", + "Lists the package references for a project or solution.", + [ + paraStart, + "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.", + paraFinish, + CreateCliRef("dotnet-list-package") + ], + ["list", "$Project", "package"], + [ + new Arg("Frameworks", "--framework", "IEnumerable", "Displays only the packages applicable for the specified target framework.") { IsCollection = true }, + sourcesArg, + 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, + diagnosticsArg + ] + ), + new( + "DotNetRemovePackage", + "Removes package reference from a project file.", + [ + paraStart, + "This command provides a convenient option to remove a NuGet package reference from a project.", + paraFinish, + CreateCliRef("dotnet-remove-package") + ], + ["remove", "$Project", "package", "$Package"], + [ + projectArg, + new Arg("Package", "", "string", "The package reference to add."), + diagnosticsArg + ] + ), + new( + "DotNetAddReference", + "Adds project-to-project (P2P) references.", + [ + paraStart, + "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.", + paraFinish, + CreateCliRef("dotnet-add-reference") + ], + ["add", "$Project", "reference", "$References"], + [ + new Arg("References", "", "IEnumerable", "Project-to-project (P2P) references to add. Specify one or more projects. Glob patterns are supported on Unix/Linux-based systems.") { IsProject = true, IsCollection = true }, + projectArg, + frameworkArg with { Comments = "Adds project references only when targeting a specific framework using the TFM format." }, + diagnosticsArg + ] + ), + new( + "DotNetListReference", + "Lists project-to-project references.", + [ + paraStart, + "This command provides a convenient option to list project references for a given project.", + paraFinish, + CreateCliRef("dotnet-list-reference") + ], + ["list", "$Project", "reference"], + [ + projectArg, + diagnosticsArg + ] + ), + new( + "DotNetRemoveReference", + "Removes project-to-project (P2P) references.", + [ + paraStart, + "This command provides a convenient option to remove project references from a project.", + paraFinish, + CreateCliRef("dotnet-remove-reference") + ], + ["remove", "$Project", "reference", "$References"], + [ + new Arg("References", "", "IEnumerable", "Project-to-project (P2P) references to remove. You can specify one or multiple projects. Glob patterns are supported on Unix/Linux based terminals.") { IsProject = true, IsCollection = true }, + projectArg, + frameworkArg with { Comments = "Removes the reference only when targeting a specific framework using the TFM format." }, + diagnosticsArg + ] + ), + new( + "DotNetBuild", + "Builds a project and all of its dependencies.", + [ + paraStart, + "This command builds the project and its dependencies into a set of binaries. The binaries include the project's code in Intermediate Language (IL) files with a .dll extension. For executable projects targeting versions earlier than .NET Core 3.0, library dependencies from NuGet are typically NOT copied to the output folder. They're resolved from the NuGet global packages folder at run time. With that in mind, the product of dotnet build isn't ready to be transferred to another machine to run. To create a version of the application that can be deployed, you need to publish it (for example, with the dotnet publish command).", + paraFinish, + paraStart, + "For executable projects targeting .NET Core 3.0 and later, library dependencies are copied to the output folder. This means that if there isn't any other publish-specific logic (such as Web projects have), the build output should be deployable.", + paraFinish, + CreateCliRef("dotnet-build") + ], + ["build", "$Project"], + [ + propsArg, + sourcesArg, + projectArg, + archArg, + artifactsPathArg, + configurationArg, + disableBuildServersArg, + frameworkArg, + forceArg, + noDependenciesArg, + noIncrementalArg, + noRestoreArg, + noLogoArg, + noSelfContainedArg, + outputArg, + osArg, + runtimeArg, + selfContainedArg, + terminalLoggerArg, + verbosityArg, + useCurrentRuntimeArg, + versionSuffixArg, + diagnosticsArg + ], + CommandTypes.Build + ), + new( + "DotNetBuildServerShutdown", + "Shuts down build servers that are started from dotnet.", + [ + paraStart, + "By default, all servers are shut down.", + paraFinish, + CreateCliRef("dotnet-build-server") + ], + ["build-server", "shutdown"], + [ + new Arg("Servers", "", "IEnumerable", "Shuts down build servers that are started from dotnet. By default, all servers are shut down.") { IsCollection = true }, + diagnosticsArg + ] + ), + new( + "DotNetClean", + "Cleans the output of a project.", + [ + paraStart, + "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.", + paraFinish, + CreateCliRef("dotnet-clean") + ], + ["clean", "$Project"], + [ + propsArg, + projectArg, + artifactsPathArg, + configurationArg, + frameworkArg, + noLogoArg, + outputArg, + runtimeArg, + terminalLoggerArg, + verbosityArg, + diagnosticsArg + ], + CommandTypes.Build + ), + new( + "DotNetDevCertsHttps", + "Generates a self-signed certificate to enable HTTPS use in development.", + [ + paraStart, + "This command manages a self-signed certificate to enable HTTPS use in local web app development. Its main functions are:", + "
- Generating a certificate for use with HTTPS endpoints during development.", + "
- Trusting the generated certificate on the local machine.", + "
- Removing the generated certificate from the local machine.", + "
- 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.", + paraFinish, + CreateCliRef("dotnet-dev-certs") + ], + ["dev-certs", "https"], + [ + 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", "DotNetCertificateFormat?", "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", "bool?", "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", "string", "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."), + diagnosticsArg + ] + ), + new( + "DotNetFormat", + "Formats code to match editorconfig settings.", + [ + paraStart, + "This command formats a code that applies style preferences and static analysis recommendations to a project or solution. Preferences will be read from an .editorconfig file, if present, otherwise a default set of preferences will be used. For more information, see the EditorConfig documentation.", + paraFinish, + CreateCliRef("dotnet-format") + ], + ["format", "$Project"], + [ + formatDiagnosticsArg, + includesArg, + excludesArg, + projectArg with { Comments = "The MSBuild project or solution to run code formatting on. If a project or solution file is not specified, MSBuild searches the current working directory for a file that has a file extension that ends in proj or sln, and uses that file." }, + dotNetFormatSeverityArg, + noRestoreArg, + verifyNoChangesArg, + includeGeneratedArg, + verbosityArg, + binaryLogArg, + reportArg, + ] + ), + new( + "DotNetFormatStyle", + "Formats code to match EditorConfig settings for code style.", + [ + paraStart, + "This command only runs formatting rules associated with code style formatting. For a complete list of formatting options that you can specify in your editorconfig file.", + paraFinish, + CreateCliRef("dotnet-format#whitespace") + ], + ["format", "style", "$Project"], + [ + formatDiagnosticsArg with { Comments = "A list of diagnostic IDs to use as a filter when fixing code style issues. Default value is whichever IDs are listed in the .editorconfig file. For a list of built-in code style analyzer rule IDs that you can specify, see the list of IDs for code-analysis style rules." }, + includesArg, + excludesArg, + projectArg with { Comments = "The MSBuild project or solution to run code formatting on. If a project or solution file is not specified, MSBuild searches the current working directory for a file that has a file extension that ends in proj or sln, and uses that file." }, + new Arg("Folder", "--folder", "bool?", "Treat the Project argument as a path to a simple folder of code files."), + dotNetFormatSeverityArg, + noRestoreArg, + verifyNoChangesArg, + includeGeneratedArg, + verbosityArg, + binaryLogArg, + reportArg, + ] + ), + new( + "DotNetFormatAnalyzers", + "Formats code to match editorconfig settings for analyzers (excluding code style rules).", + [ + paraStart, + "This command only runs formatting rules associated with analyzers. For a list of analyzer rules that you can specify in your editorconfig file, see Quality rules.", + paraFinish, + CreateCliRef("dotnet-format#analyzers") + ], + ["format", "analyzers", "$Project"], + [ + formatDiagnosticsArg with { Comments = "A list of diagnostic IDs to use as a filter when fixing non code style issues. Default value is whichever IDs are listed in the .editorconfig file. For a list of built-in analyzer rule IDs that you can specify, see the list of IDs for quality rules. For third-party analyzers refer to their documentation." }, + includesArg, + excludesArg, + projectArg with { Comments = "The MSBuild project or solution to run code formatting on. If a project or solution file is not specified, MSBuild searches the current working directory for a file that has a file extension that ends in proj or sln, and uses that file." }, + dotNetFormatSeverityArg, + noRestoreArg, + verifyNoChangesArg, + includeGeneratedArg, + verbosityArg, + binaryLogArg, + reportArg, + ] + ), + new( + "DotNetNew", + "Creates a new project, configuration file, or solution based on the specified template.", + [ + paraStart, + "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.", + paraFinish, + CreateCliRef("dotnet-new") + ], + ["new", "$TemplateName"], + [ + 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." }, + noRestoreArg, + 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, + diagnosticsArg + ] + ), + new( + "DotNetNewList", + "Lists available templates to be run using dotnet new.", + [ + paraStart, + "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.", + paraFinish, + CreateCliRef("dotnet-new-list") + ], + ["new", "list", "$TemplateName"], + [ + 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, + diagnosticsArg + ] + ), + new( + "DotNetNewSearch", + "Searches for the templates supported by dotnet new on NuGet.org.", + [ + paraStart, + "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.", + paraFinish, + CreateCliRef("dotnet-new-search") + ], + ["new", "search", "$TemplateName"], + [ + 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, + diagnosticsArg + ] + ), + new( + "DotNetNewDetails", + "Displays template package metadata.", + [ + paraStart, + "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.", + paraFinish, + CreateCliRef("dotnet-new-details") + ], + ["new", "details", "$TemplateName"], + [ + sourcesArg with { ArgName = "--add-source" }, + 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, + diagnosticsArg + ] + ), + new( + "DotNetNewInstall", + "Installs a template package.", + [ + paraStart, + "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.", + paraFinish, + CreateCliRef("dotnet-new-install") + ], + ["new", "install", "$Package"], + [ + sourcesArg with { ArgName = "--add-source" }, + 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, + diagnosticsArg + ] + ), + new( + "DotNetNewUninstall", + "Uninstalls a template package.", + [ + paraStart, + "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.", + paraFinish, + CreateCliRef("dotnet-new-uninstall") + ], + ["new", "uninstall", "$Package"], + [ + 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, + diagnosticsArg + ] + ), + new( + "DotNetNewUpdate", + "Updates installed template packages.", + [ + paraStart, + "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.", + paraFinish, + CreateCliRef("dotnet-new-update") + ], + ["new", "update"], + [ + sourcesArg with { ArgName = "--add-source" }, + 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, + diagnosticsArg + ] + ), + new( + "DotNetNuGetDelete", + "Deletes or unlists a package from the server.", + [ + paraStart, + "This command deletes or unlists a package from the server. For nuget.org, the action is to unlist the package.", + paraFinish, + CreateCliRef("dotnet-nuget-delete") + ], + ["nuget", "delete", "$Package", "$PackageVersion"], + [ + new Arg("Package", "", "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."), + diagnosticsArg + ], + CommandTypes.Default, + "--non-interactive" + ), + new( + "DotNetNuGetLocalsClear", + "Clears local NuGet resources.", + [ + paraStart, + "This command clears local NuGet resources in the http-request cache, temporary cache, or machine-wide global packages folder.", + paraFinish, + CreateCliRef("dotnet-nuget-locals") + ], + ["nuget", "locals", "$CacheLocation"], + [ + 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."), + diagnosticsArg + ], + CommandTypes.Default, + "--clear" + ), + new( + "DotNetNuGetLocalsList", + "Displays the location of the specified cache type.", + [ + CreateCliRef("dotnet-nuget-locals") + ], + ["nuget", "locals", "$CacheLocation"], + [ + 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."), + diagnosticsArg + ], + CommandTypes.Default, + "--list" + ), + new( + "DotNetNuGetPush", + "Pushes a package to the server and publishes it.", + [ + paraStart, + @"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.", + paraFinish, + CreateCliRef("dotnet-nuget-push") + ], + ["nuget", "push", "$Package"], + [ + 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, + diagnosticsArg + ] + ), + new( + "DotNetNuGetAddSource", + "Add a NuGet source.", + [ + paraStart, + "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.", + paraFinish, + CreateCliRef("dotnet-nuget-add-source") + ], + ["nuget", "add", "source", "$Source"], + [ + 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("Source", "", "string", "Path to the package source.") { IsProject = true }, + configFileArg, + 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."), + diagnosticsArg + ] + ), + new( + "DotNetNuGetDisableSource", + "Disable a NuGet source.", + [ + paraStart, + "This command disables an existing source in your NuGet configuration files.", + paraFinish, + CreateCliRef("dotnet-nuget-disable-source") + ], + ["nuget", "disable", "source", "$Name"], + [ + new Arg("Name", "--name", "string", "Name of the source.") { IsProject = true }, + configFileArg, + diagnosticsArg + ] + ), + new( + "DotNetNuGetEnableSource", + "Enable a NuGet source.", + [ + paraStart, + "This command enables an existing source in your NuGet configuration files.", + paraFinish, + CreateCliRef("dotnet-nuget-enable-source") + ], + ["nuget", "enable", "source", "$Name"], + [ + new Arg("Name", "--name", "string", "Name of the source.") { IsProject = true }, + configFileArg, + diagnosticsArg + ] + ), + new( + "DotNetNuGetListSource", + "Lists all configured NuGet sources.", + [ + paraStart, + "This command lists all existing sources from your NuGet configuration files.", + paraFinish, + CreateCliRef("dotnet-nuget-list-source") + ], + ["nuget", "list", "source"], + [ + configFileArg, + new Arg("Format", "--format", "NuGetListFormat?", "The format of the list command output: Detailed (the default) and Short."), + diagnosticsArg + ] + ), + new( + "DotNetNuGetRemoveSource", + "Remove a NuGet source.", + [ + paraStart, + "This command removes an existing source from your NuGet configuration files.", + paraFinish, + CreateCliRef("dotnet-nuget-remove-source") + ], + ["nuget", "remove", "source", "$Name"], + [ + new Arg("Name", "--name", "string", "Name of the source.") { IsProject = true }, + configFileArg, + diagnosticsArg + ] + ), + new( + "DotNetNuGetUpdateSource", + "Update a NuGet source.", + [ + paraStart, + "This command updates an existing source in your NuGet configuration files.", + paraFinish, + CreateCliRef("dotnet-nuget-update-source") + ], + ["nuget", "update", "source", "$Name"], + [ + 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 }, + configFileArg, + 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."), + diagnosticsArg + ] + ), + new( + "DotNetNuGetVerify", + "Verifies a signed NuGet package.", + [ + paraStart, + "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.", + paraFinish, + CreateCliRef("dotnet-nuget-verify") + ], + ["nuget", "verify", "$Packages"], + [ + 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."), + configFileArg, + verbosityArg, + diagnosticsArg + ] + ), + new( + "DotNetNuGetTrustList", + "Lists all the trusted signers in the configuration.", + [ + paraStart, + "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.", + paraFinish, + CreateCliRef("dotnet-nuget-trust#list") + ], + ["nuget", "trust", "list"], + [ + configFileArg, + verbosityArg, + diagnosticsArg + ] + ), + new( + "DotNetNuGetTrustSync", + "Deletes the current list of certificates and replaces them with an up-to-date list from the repository.", + [ + CreateCliRef("dotnet-nuget-trust#sync") + ], + ["nuget", "trust", "sync", "$Name"], + [ + new Arg("Name", "", "string", "The name of the existing trusted signer to sync.") { IsProject = true }, + configFileArg, + verbosityArg, + diagnosticsArg + ] + ), + new( + "DotNetNuGetTrustRemove", + "Removes any trusted signers that match the given name.", + [ + CreateCliRef("dotnet-nuget-trust#sync") + ], + ["nuget", "trust", "remove", "$Name"], + [ + new Arg("Name", "", "string", "The name of the existing trusted signer to remove.") { IsProject = true }, + configFileArg, + verbosityArg, + diagnosticsArg + ] + ), + new( + "DotNetNuGetTrustAuthor", + "Adds a trusted signer with the given name, based on the author signature of the package.", + [ + CreateCliRef("dotnet-nuget-trust#author") + ], + ["nuget", "trust", "author", "$Name", "$Package"], + [ + 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, + configFileArg, + verbosityArg, + diagnosticsArg + ] + ), + new( + "DotNetNuGetTrustRepository", + "Adds a trusted signer with the given name, based on the repository signature or countersignature of a signed package.", + [ + CreateCliRef("dotnet-nuget-trust#repository") + ], + ["nuget", "trust", "repository", "$Name", "$Package"], + [ + 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, + configFileArg, + verbosityArg, + diagnosticsArg + ] + ), + new( + "DotNetNuGetTrustCertificate", + "Adds a trusted signer with the given name, based on a certificate fingerprint.", + [ + CreateCliRef("dotnet-nuget-trust#certificate") + ], + ["nuget", "trust", "certificate", "$Name", "$Fingerprint"], + [ + 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, + configFileArg, + verbosityArg, + diagnosticsArg + ] + ), + new( + "DotNetNuGetTrustSource", + "Adds a trusted signer based on a given package source.", + [ + CreateCliRef("dotnet-nuget-trust#source") + ], + ["nuget", "trust", "source", "$Name" ], + [ + 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 }, + configFileArg, + 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, + diagnosticsArg + ] + ), + new( + "DotNetNuGetSign", + "Signs the NuGet packages with a certificate.", + [ + paraStart, + "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.", + paraFinish, + CreateCliRef("dotnet-nuget-sign") + ], + ["nuget", "sign", "$Packages"], + [ + 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, + diagnosticsArg + ] + ), + new( + "DotNetNuGetWhy", + "Shows the dependency graph for a particular package.", + [ + paraStart, + @"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.", + paraFinish, + CreateCliRef("dotnet-nuget-why") + ], + ["nuget", "why", "$Project", "$Package"], + [ + 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 }, + diagnosticsArg + ] + ), + new( + "DotNetNuGetConfigGet", + "Gets the NuGet configuration settings that will be applied.", + [ + paraStart, + "This command gets the NuGet configuration settings that will be applied from the config section.", + paraFinish, + CreateCliRef("dotnet-nuget-config-get") + ], + ["nuget", "config", "get", "$ConfigKey"], + [ + new Arg("ConfigKey", "", "string", "ALL is default value, 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, DefaultValue = "\"ALL\"" }, + 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."), + diagnosticsArg + ] + ), + new( + "DotNetNuGetConfigSet", + "Set the value of a specified NuGet configuration setting.", + [ + paraStart, + "This command sets the values for NuGet configuration settings that will be applied from the config section.", + paraFinish, + CreateCliRef("dotnet-nuget-config-set") + ], + ["nuget", "config", "set", "$ConfigKey", "$ConfigValue"], + [ + new Arg("ConfigKey", "", "string", "The key of the settings that are to be set.") { IsProject = true }, + new Arg("ConfigValue", "", "string", "The value of the settings that are to be set.") { IsProject = true }, + configFileArg, + diagnosticsArg + ] + ), + new( + "DotNetNuGetConfigUnset", + "Removes the key-value pair from a specified NuGet configuration setting.", + [ + paraStart, + "This command unsets the values for NuGet configuration settings that will be applied from the config section.", + paraFinish, + CreateCliRef("dotnet-nuget-config-unset") + ], + ["nuget", "config", "unset", "$ConfigKey"], + [ + new Arg("ConfigKey", "", "string", "The key of the settings that are to be removed.") { IsProject = true }, + configFileArg, + diagnosticsArg + ] + ), + new( + "DotNetNuGetConfigPaths", + "Lists nuget configuration files currently being applied to a directory.", + [ + paraStart, + "This command lists the paths to all NuGet configuration files that will be applied when invoking NuGet commands in a specific directory.", + paraFinish, + CreateCliRef("dotnet-nuget-config-paths") + ], + ["nuget", "config", "paths"], + [ + new Arg("Directory", "--working-directory", "string", "Specifies the directory to start from when listing configuration files. If not specified, the current directory is used."), + diagnosticsArg + ] + ), + new( + "DotNetPack", + "Packs the code into a NuGet package.", + [ + paraStart, + "The dotnet pack command builds the project and creates NuGet packages. The result of this command is a NuGet package (that is, a .nupkg file).", + paraFinish, + paraStart, + "NuGet dependencies of the packed project are added to the .nuspec file, so they're properly resolved when the package is installed. If the packed project has references to other projects, the other projects aren't included in the package. Currently, you must have a package per project if you have project-to-project dependencies.", + paraFinish, + paraStart, + "By default, dotnet pack builds the project first. If you wish to avoid this behavior, pass the --no-build option. This option is often useful in Continuous Integration (CI) build scenarios where you know the code was previously built.", + paraFinish, + CreateCliRef("dotnet-pack") + ], + ["pack", "$Project"], + [ + propsArg, + sourcesArg, + projectArg with {Comments = "The project or solution to pack. It's either a path to a csproj, vbproj, or fsproj file, or to a solution file or directory. If not specified, the command searches the current directory for a project or solution file." }, + artifactsPathArg, + configurationArg, + forceArg, + new Arg("IncludeSource", "--include-source", "string", "Includes the debug symbols NuGet packages in addition to the regular NuGet packages in the output directory. The sources files are included in the src folder within the symbols package."), + new Arg("IncludeSymbols", "--include-symbols", "string", "Includes the debug symbols NuGet packages in addition to the regular NuGet packages in the output directory."), + noBuildArg with { Comments = "Doesn't build the project before packing. It also implicitly sets the --no-restore flag." }, + noDependenciesArg, + noIncrementalArg, + noRestoreArg, + noLogoArg, + noSelfContainedArg, + outputArg, + osArg, + runtimeArg, + selfContainedArg, + terminalLoggerArg, + verbosityArg, + useCurrentRuntimeArg, + versionSuffixArg, + diagnosticsArg + ], + CommandTypes.Build + ), + new( + "DotNetPackageSearch", + "Searches for a NuGet package.", + [ + paraStart, + "This command searches for a NuGet package.", + paraFinish, + CreateCliRef("dotnet-package-search") + ], + ["package", "search", "$SearchTerm"], + [ + sourcesArg, + new Arg("SearchTerm", "", "string", "Specifies the search term to filter results. Use this argument to search for packages matching the provided query.") { IsProject = true }, + configFileArg, + new Arg("ExactMatch", "--exact-match", "bool?", "This option narrows the search to only include packages whose IDs exactly match the specified search term, effectively filtering out any partial matches. It provides a concise list of all available versions for the identified package. Causes --take and --skip options to be ignored. Utilize this option to display all available versions of a specified package."), + new Arg("Format", "--format", "DotNetPackageSearchResultFormat?", "The format options are table and json. The default is table."), + new Arg("Prerelease", "--prerelease", "bool?", "Allow prerelease packages to be shown."), + new Arg("Skip", "--skip", "int?", "The number of results to skip, for pagination. The default value is 0."), + new Arg("Take", "--take", "int?", "The number of results to return. The default value is 20."), + verbosityArg, + diagnosticsArg + ] + ), + new( + "DotNetPublish", + "Publishes the application and its dependencies to a folder for deployment to a hosting system.", + [ + paraStart, + "This command compiles the application, reads through its dependencies specified in the project file, and publishes the resulting set of files to a directory.", + paraFinish, + CreateCliRef("dotnet-publish") + ], + ["publish", "$Project"], + [ + propsArg, + sourcesArg, + manifestArg with { Comments = "Specifies one or several target manifests to use to trim the set of packages published with the app. The manifest file is part of the output of the dotnet store command." }, + projectArg, + archArg, + artifactsPathArg, + configurationArg, + disableBuildServersArg, + frameworkArg, + forceArg, + noBuildArg with { Comments = "Doesn't build the project before publishing. It also implicitly sets the --no-restore flag." }, + noDependenciesArg, + noLogoArg, + noRestoreArg, + outputArg with { Comments = "Specifies the path for the output directory. If not specified, it defaults to [project_file_folder]/bin/[configuration]/[framework]/publish/ for a framework-dependent executable and cross-platform binaries. It defaults to [project_file_folder]/bin/[configuration]/[framework]/[runtime]/publish/ for a self-contained executable. In a web project, if the output folder is in the project folder, successive dotnet publish commands result in nested output folders. For example, if the project folder is myproject, and the publish output folder is myproject/publish, and you run dotnet publish twice, the second run puts content files such as .config and .json files in myproject/publish/publish. To avoid nesting publish folders, specify a publish folder that isn't directly under the project folder, or exclude the publish folder from the project."}, + osArg, + selfContainedArg with { Comments = "Publishes the .NET runtime with your application so the runtime doesn't need to be installed on the target machine. Default is true if a runtime identifier is specified and the project is an executable project (not a library project)." }, + noSelfContainedArg, + runtimeArg with { Comments = "Publishes the application for a given runtime. For a list of Runtime Identifiers (RIDs), see the RID catalog." }, + terminalLoggerArg, + useCurrentRuntimeArg, + verbosityArg, + versionSuffixArg, + diagnosticsArg + ], + CommandTypes.Build + ), + new( + "DotNetRestore", + "Restores the dependencies and tools of a project.", + [ + paraStart, + "A .NET project typically references external libraries in NuGet packages that provide additional functionality. These external dependencies are referenced in the project file (.csproj or .vbproj). When you run the dotnet restore command, the .NET CLI uses NuGet to look for these dependencies and download them if necessary. It also ensures that all the dependencies required by the project are compatible with each other and that there are no conflicts between them. Once the command is completed, all the dependencies required by the project are available in a local cache and can be used by the .NET CLI to build and run the application.", + paraFinish, + paraStart, + "Sometimes, it might be inconvenient to run the implicit NuGet restore with these commands. For example, some automated systems, such as build systems, need to call dotnet restore explicitly to control when the restore occurs so that they can control network usage. To prevent the implicit NuGet restore, you can use the --no-restore flag with any of these commands.", + paraFinish, + CreateCliRef("dotnet-restore") + ], + ["restore", "$Project"], + [ + propsArg, + sourcesArg, + projectArg, + archArg, + configFileArg, + disableBuildServersArg, + disableParallelArg, + forceArg, + new Arg("ForceEvaluate", "--force-evaluate", "bool?", "Forces restore to reevaluate all dependencies even if a lock file already exists."), + ignoreFailedSourcesArg with { Comments = "Only warn about failed sources if there are packages meeting the version requirement." }, + new Arg("LockFilePath", "--lock-file-path", "string", "Output location where project lock file is written. By default, this is PROJECT_ROOT\\packages.lock.json."), + new Arg("LockedMode", "--locked-mode", "bool?", "Don't allow updating project lock file."), + noCacheArg, + noDependenciesArg, + new Arg("Packages", "--packages", "string", "Specifies the directory for restored packages."), + runtimeArg, + terminalLoggerArg, + useCurrentRuntimeArg, + new Arg("UseLockFile", "--use-lock-file", "bool?", "Enables project lock file to be generated and used with restore."), + verbosityArg, + diagnosticsArg + ], + CommandTypes.Build + ), + new( + "DotNetRun", + "Runs source code without any explicit compile or launch commands.", + [ + paraStart, + "This command provides a convenient option to run your application from the source code with one command. It's useful for fast iterative development from the command line. The command depends on the dotnet build command to build the code. Any requirements for the build apply to dotnet run as well.", + paraFinish, + paraStart, + "To run the application, the dotnet run command resolves the dependencies of the application that are outside of the shared runtime from the NuGet cache. Because it uses cached dependencies, it's not recommended to use dotnet run to run applications in production. Instead, create a deployment using the dotnet publish command and deploy the published output.", + paraFinish, + CreateCliRef("dotnet-run") + ], + ["run"], + [ + propsArg, + 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, + new Arg("Project", "--project", "string", "Specifies the path of the project file to run (folder name or full path). If not specified, it defaults to the current directory."), + runtimeArg, + terminalLoggerArg, + verbosityArg, + diagnosticsArg + ] + ), + new( + "DotNetSdkCheck", + "Lists the latest available version of the .NET SDK and .NET Runtime, for each feature band.", + [ + paraStart, + "This command makes it easier to track when new versions of the SDK and Runtimes are available.", + paraFinish, + CreateCliRef("dotnet-sdk-check") + ], + ["sdk", "check"], + [ + diagnosticsArg + ] + ), + new( + "DotNetSlnList", + "Lists all projects in a solution file.", + [ + CreateCliRef("dotnet-sln#list") + ], + ["sln", "$Solution", "list"], + [ + solutionArg, + diagnosticsArg + ] + ), + new( + "DotNetSlnAdd", + "Adds one or more projects to the solution file.", + [ + CreateCliRef("dotnet-sln#add") + ], + ["sln", "$Solution", "add", "$Projects"], + [ + new Arg("Projects", "", "IEnumerable", "The path to the project or projects to add to the solution. Unix/Linux shell globbing pattern expansions are processed correctly by the dotnet sln command.") { IsProject = true, IsCollection = true }, + solutionArg, + new Arg("InRoot", "--in-root", "bool?", "Places the projects in the root of the solution, rather than creating a solution folder. Can't be used with -s|--solution-folder."), + new Arg("SolutionFolder", "--solution-folder", "string", "The destination solution folder path to add the projects to. Can't be used with --in-root."), + diagnosticsArg + ] + ), + new( + "DotNetSlnRemove", + "Removes a project or multiple projects from the solution file.", + [ + CreateCliRef("dotnet-sln#remove") + ], + ["sln", "$Solution", "remove", "$Projects"], + [ + new Arg("Projects", "", "IEnumerable", "The path to the project or projects to add to the solution. Unix/Linux shell globbing pattern expansions are processed correctly by the dotnet sln command.") { IsProject = true, IsCollection = true }, + solutionArg, + diagnosticsArg + ] + ), + new( + "DotNetStore", + "Stores the specified assemblies in the runtime package store.", + [ + paraStart, + "This command stores the specified assemblies in the runtime package store. By default, assemblies are optimized for the target runtime and framework.", + paraFinish, + CreateCliRef("dotnet-store") + ], + ["store"], + [ + manifestArg with { Comments = "The package store manifest file is an XML file that contains the list of packages to store. The format of the manifest file is compatible with the SDK-style project format. So, a project file that references the desired packages can be used with the -m|--manifest option to store assemblies in the runtime package store." }, + frameworkArg with { Comments = "Specifies the .NET SDK version. This option enables you to select a specific framework version beyond the framework specified by the -f|--framework option." }, + runtimeArg, + new Arg("FrameworkVersion", "--framework-version", "string", "Specifies the .NET SDK version. This option enables you to select a specific framework version beyond the framework specified by the -f|--framework option."), + outputArg with { Comments = "Specifies the path to the runtime package store. If not specified, it defaults to the store subdirectory of the user profile .NET installation directory." }, + new Arg("SkipOptimization", "--skip-optimization", "bool?", "Skips the optimization phase."), + new Arg("SkipSymbols", "--skip-symbols", "bool?", "Skips symbol generation. Currently, you can only generate symbols on Windows and Linux."), + verbosityArg, + new Arg("Directory", "--working-dir", "string", "The working directory used by the command. If not specified, it uses the obj subdirectory of the current directory."), + diagnosticsArg + ] + ), + new( + "DotNetTest", + ".NET test driver used to execute unit tests.", + [ + paraStart, + "This command is used to execute unit tests in a given solution. The dotnet test command builds the solution and runs a test host application for each test project in the solution using VSTest. The test host executes tests in the given project using a test framework, for example: MSTest, NUnit, or xUnit, and reports the success or failure of each test. If all tests are successful, the test runner returns 0 as an exit code; otherwise if any test fails, it returns 1.", + paraFinish, + paraStart, + "For multi-targeted projects, tests are run for each targeted framework. The test host and the unit test framework are packaged as NuGet packages and are restored as ordinary dependencies for the project. Starting with the .NET 9 SDK, these tests are run in parallel by default. To disable parallel execution, set the TestTfmsInParallel MSBuild property to false.", + paraFinish, + CreateCliRef("dotnet-test") + ], + ["test", "$Project"], + [ + propsArg, + new Arg("Environments", "--environment", "IEnumerable<(string name, string value)>", "Sets the value of an environment variable. Creates the variable if it does not exist, overrides if it does exist. Use of this option will force the tests to be run in an isolated process.") { IsCollection = true, CollectionSeparator = "="}, + new Arg("Loggers", "--logger ", "IEnumerable", "Specifies a logger for test results and optionally switches for the logger.") { IsCollection = true }, + projectArg with { Comments = "Path to the test project.
Or path to the solution.
Or path to a directory that contains a project or a solution.
Or path to a test project .dll file.
Or path to a test project .exe file.
If not specified, the effect is the same as using the DIRECTORY argument to specify the current directory." }, + new Arg("TestAdapterPath", "--test-adapter-path", "string", "Path to a directory to be searched for additional test adapters. Only .dll files with suffix .TestAdapter.dll are inspected. If not specified, the directory of the test .dll is searched.") { AddArgOverride = ".AddArgs(\"--test-adapter-path\", $\"{string.Join(\";\", new[] {TestAdapterPath, virtualContext.Resolve(settings.DotNetVSTestLoggerDirectory)}.Where(i => !string.IsNullOrWhiteSpace(i)))}\")" } , + archArg, + artifactsPathArg, + new Arg("Blame", "--blame", "bool?", "Runs the tests in blame mode. This option is helpful in isolating problematic tests that cause the test host to crash. When a crash is detected, it creates a sequence file in TestResults/<Guid>/<Guid>_Sequence.xml that captures the order of tests that were run before the crash.<br/>This option does not create a memory dump and is not helpful when the test is hanging."), + new Arg("BlameCrash", "--blame-crash", "bool?", "Runs the tests in blame mode and collects a crash dump when the test host exits unexpectedly. This option depends on the version of .NET used, the type of error, and the operating system.
For exceptions in managed code, a dump will be automatically collected on .NET 5.0 and later versions. It will generate a dump for testhost or any child process that also ran on .NET 5.0 and crashed. Crashes in native code will not generate a dump. This option works on Windows, macOS, and Linux."), + new Arg("BlameCrashDumpType", "--blame-crash-dump-type", "DotNetBlameDumpType?", "The type of crash dump to be collected. Supported dump types are full (default), and mini."), + new Arg("BlameCrashCollectAlways", "--blame-crash-collect-always", "bool?", "Collects a crash dump on expected as well as unexpected test host exit."), + new Arg("BlameHang", "--blame-hang", "bool?", "Run the tests in blame mode and collects a hang dump when a test exceeds the given timeout."), + new Arg("BlameHangDumpType", "--blame-hang-dump-type", "DotNetBlameDumpType?", "The type of crash dump to be collected. It should be full, mini, or none. When none is specified, test host is terminated on timeout, but no dump is collected."), + new Arg("BlameHangTimeout", "--blame-hang-timeout", "TimeSpan?", "Per-test timeout, after which a hang dump is triggered and the test host process and all of its child processes are dumped and terminated."), + configurationArg, + new Arg("Collect", "--collect", "string", "Enables data collector for the test run."), + new Arg("Diag", "--diag", "string", "Enables diagnostic mode for the test platform and writes diagnostic messages to the specified file and to files next to it. The process that is logging the messages determines which files are created, such as *.host_&lt;date&gt;.txt for test host log, and *.datacollector_&lt;date&gt;.txt for data collector log."), + frameworkArg, + new Arg("Filter", "--filter", "string", "Filters tests in the current project using the given expression. Only tests that match the filter expression are run."), + noBuildArg, + noLogoArg, + noRestoreArg, + outputArg, + osArg, + new Arg("ResultsDirectory", "--results-directory", "string", "The directory where the test results are going to be placed. If the specified directory doesn't exist, it's created. The default is TestResults in the directory that contains the project file."), + runtimeArg with { Comments = "The target runtime to test for." }, + new Arg("Settings", "--settings", "string", "The .runsettings file to use for running the tests. The TargetPlatform element (x86|x64) has no effect for dotnet test. To run tests that target x86, install the x86 version of .NET Core. The bitness of the dotnet.exe that is on the path is what will be used for running tests."), + new Arg("ListTests", "--list-tests", "bool?", "List the discovered tests instead of running the tests."), + verbosityArg, + diagnosticsArg + ], + CommandTypes.Build | CommandTypes.Test | CommandTypes.RequiresSettings + ), + new( + "DotNetToolInstall", + "Installs the specified .NET tool on your machine.", + [ + paraStart, + "This command provides a way for you to install .NET tools on your machine.", + paraFinish, + CreateCliRef("dotnet-tool-install") + ], + ["tool", "install", "$Package"], + [ + sourcesArg with { ArgName = "--add-source", Comments = "Adds an additional NuGet package source to use during installation. Feeds are accessed in parallel, not sequentially in some order of precedence. If the same package and version is in multiple feeds, the fastest feed wins." }, + new Arg("Package", "", "string", "Name/ID of the NuGet package that contains the .NET tool to install.") { IsProject = true }, + new Arg("AllowDowngrade", "--allow-downgrade", "bool?", "Allow package downgrade when installing or updating a .NET tool package. Suppresses the warning, \"The requested version x.x.x is lower than existing version x.x.x.\""), + archArg, + configFileArg, + new Arg("CreateManifestIfNeeded", "--create-manifest-if-needed", "bool?", "Applies to local tools. Available starting with .NET 8 SDK. To find a manifest, the search algorithm searches up the directory tree for dotnet-tools.json or a .config folder that contains a dotnet-tools.json file. If a tool-manifest can't be found and the --create-manifest-if-needed option is set to false, the CannotFindAManifestFile error occurs. If a tool-manifest can't be found and the --create-manifest-if-needed option is set to true, the tool creates a manifest automatically."), + disableParallelArg, + frameworkArg with { Comments = "Specifies the target framework to install the tool for. By default, the .NET SDK tries to choose the most appropriate target framework." }, + new Arg("Global", "--global", "bool?", "Specifies that the installation is user wide. Can't be combined with the --tool-path option. Omitting both --global and --tool-path specifies a local tool installation."), + ignoreFailedSourcesArg, + new Arg("Local", "--local", "bool?", "Update the tool and the local tool manifest. Can't be combined with the --global option or the --tool-path option."), + noCacheArg, + new Arg("Prerelease", "--prerelease", "bool?", "Include prerelease packages."), + new Arg("ToolManifest", "--tool-manifest", "string", "Path to the manifest file."), + new Arg("ToolPath", "--tool-path", "string", "Specifies the location where to install the Global Tool. PATH can be absolute or relative. If PATH doesn't exist, the command tries to create it. Omitting both --global and --tool-path specifies a local tool installation."), + verbosityArg, + new Arg("Version", "--version", "string", "The version of the tool to install. By default, the latest stable package version is installed. Use this option to install preview or older versions of the tool.
Starting with .NET 8.0, --version Major.Minor.Patch refers to a specific major/minor/patch version, including unlisted versions. To get the latest version of a certain major/minor version instead, use --version Major.Minor.*."), + diagnosticsArg + ] + ), + new( + "DotNetToolList", + "Lists all .NET tools of the specified type currently installed on your machine.", + [ + paraStart, + "This command provides a way for you to list .NET global, tool-path, or local tools installed on your machine. The command lists the package name, version installed, and the tool command.", + paraFinish, + CreateCliRef("dotnet-tool-list") + ], + ["tool", "list", "$Package"], + [ + new Arg("Package", "", "string", "Lists the tool that has the supplied package ID if the tool is installed. Can be used in conjunction with options. Provides a way to check if a specific tool was installed. If no tool with the specified package ID is found, the command lists headings with no detail rows.") { IsProject = true }, + new Arg("Global", "--global", "bool?", "Lists user-wide global tools. Can't be combined with the --tool-path option. Omitting both --global and --tool-path lists local tools."), + new Arg("Local", "--local", "bool?", "Lists local tools for the current directory. Can't be combined with the --global or --tool-path options. Omitting both --global and --tool-path lists local tools even if --local is not specified."), + new Arg("ToolPath", "--tool-path", "string", "Specifies a custom location where to find global tools. PATH can be absolute or relative. Can't be combined with the --global option. Omitting both --global and --tool-path lists local tools."), + diagnosticsArg + ] + ), + new( + "DotNetToolRestore", + "Installs the .NET local tools that are in scope for the current directory.", + [ + paraStart, + "This command finds the tool manifest file that is in scope for the current directory and installs the tools that are listed in it. For information about manifest files, see Install a local tool and Invoke a local tool.", + paraFinish, + CreateCliRef("dotnet-tool-restore") + ], + ["tool", "restore"], + [ + sourcesArg with { ArgName = "--add-source", Comments = "Adds an additional NuGet package source to use during installation. Feeds are accessed in parallel, not sequentially in some order of precedence. If the same package and version is in multiple feeds, the fastest feed wins." }, + configFileArg, + new Arg("ToolManifest", "--tool-manifest", "string", "Path to the manifest file."), + disableParallelArg, + ignoreFailedSourcesArg, + noCacheArg, + verbosityArg, + diagnosticsArg + ] + ), + new( + "DotNetToolRun", + "Invokes a local tool.", + [ + paraStart, + "This command searches tool manifest files that are in scope for the current directory. When it finds a reference to the specified tool, it runs the tool.", + paraFinish, + CreateCliRef("dotnet-tool-run") + ], + ["tool", "run", "$CommandName"], + [ + new Arg("CommandName", "", "string", "The command name of the tool to run.") { IsProject = true }, + diagnosticsArg + ] + ), + new( + "DotNetToolSearch", + "Searches all .NET tools that are published to NuGet.", + [ + paraStart, + "This command provides a way for you to search NuGet for tools that can be used as .NET global, tool-path, or local tools. The command searches the tool names and metadata such as titles, descriptions, and tags.", + paraFinish, + CreateCliRef("dotnet-tool-search") + ], + ["tool", "search", "$Package"], + [ + new Arg("Package", "", "string", "Name/description of the NuGet package.") { IsProject = true }, + new Arg("Detail", "--detail", "bool?", "Shows detailed results from the query."), + new Arg("Prerelease", "--prerelease", "bool?", "Includes pre-release packages."), + new Arg("Skip", "--skip", "int?", "Specifies the number of query results to skip. Used for pagination."), + new Arg("Take", "--take", "int?", "Specifies the number of query results to show. Used for pagination."), + diagnosticsArg + ] + ), + new( + "DotNetToolUninstall", + "Uninstalls the specified .NET tool from your machine.", + [ + paraStart, + "This command provides a way for you to uninstall .NET tools from your machine.", + paraFinish, + CreateCliRef("dotnet-tool-uninstall") + ], + ["tool", "uninstall", "$Package"], + [ + new Arg("Package", "", "string", "Name/ID of the NuGet package that contains the .NET tool to uninstall. You can find the package name using the dotnet tool list command.") { IsProject = true }, + new Arg("Global", "--global", "bool?", "Specifies that the tool to be removed is from a user-wide installation. Can't be combined with the --tool-path option. Omitting both --global and --tool-path specifies that the tool to be removed is a local tool."), + new Arg("ToolPath", "--tool-path", "string", "Specifies the location where to uninstall the tool. PATH can be absolute or relative. Can't be combined with the --global option. Omitting both --global and --tool-path specifies that the tool to be removed is a local tool."), + new Arg("ToolManifest", "--tool-manifest", "string", "Specifies the manifest file that the tool is to be removed from. PATH can be absolute or relative. Can't be combined with the --global option."), + diagnosticsArg + ] + ), + new( + "DotNetToolUpdate", + "Updates the specified .NET tool on your machine.", + [ + paraStart, + "This command provides a way for you to update .NET tools on your machine to the latest stable version of the package. The command uninstalls and reinstalls a tool, effectively updating it. ", + paraFinish, + CreateCliRef("dotnet-tool-update") + ], + ["tool", "update", "$Package"], + [ + sourcesArg with { ArgName = "--add-source", Comments = "Adds an additional NuGet package source to use during installation. Feeds are accessed in parallel, not sequentially in some order of precedence. If the same package and version is in multiple feeds, the fastest feed wins." }, + new Arg("Package", "", "string", "Name/ID of the NuGet package that contains the .NET global tool to update. You can find the package name using the dotnet tool list command.") { IsProject = true }, + new Arg("AllowDowngrade", "--allow-downgrade", "bool?", "Allow package downgrade when installing or updating a .NET tool package. Suppresses the warning, \"The requested version x.x.x is lower than existing version x.x.x.\""), + configFileArg, + disableParallelArg, + frameworkArg with { Comments = "Specifies the target framework to update the tool for." }, + new Arg("Global", "--global", "bool?", "Specifies that the update is for a user-wide tool. Can't be combined with the --tool-path option. Omitting both --global and --tool-path specifies that the tool to be updated is a local tool."), + ignoreFailedSourcesArg, + new Arg("Local", "--local", "bool?", "Update the tool and the local tool manifest. Can't be combined with the --global option or the --tool-path option."), + noCacheArg, + new Arg("Prerelease", "--prerelease", "bool?", "Include prerelease packages."), + new Arg("ToolManifest", "--tool-manifest", "string", "Path to the manifest file."), + new Arg("ToolPath", "--tool-path", "string", "Specifies the location where the global tool is installed. PATH can be absolute or relative. Can't be combined with the --global option. Omitting both --global and --tool-path specifies that the tool to be updated is a local tool."), + verbosityArg, + new Arg("Version", "--version", "string", "The version range of the tool package to update to. This cannot be used to downgrade versions, you must uninstall newer versions first.
Starting in .NET 8.0, --version Major.Minor.Patch refers to a specific major.minor.patch version, including unlisted versions. To get the latest version of a certain major.minor version instead, use --version Major.Minor.*."), + diagnosticsArg + ] + ), + new( + "DotNetWorkload", + "Provides information about the available workload commands and installed workloads.", + [ + paraStart, + "This command provides commands for working with .NET workloads.", + paraFinish, + CreateCliRef("dotnet-workload") + ], + ["workload"], + [ + new Arg("Version", "--version", "bool?", "Displays the current workload set version."), + new Arg("Info", "--info", "bool?", "Prints out detailed information about installed workloads, including their installation source, manifest version, manifest path, and install type."), + diagnosticsArg + ] + ), + new( + "DotNetWorkloadConfig", + "Enables or disables workload-set update mode.", + [ + CreateCliRef("dotnet-workload-config") + ], + ["workload", "config"], + [ + new Arg("UpdateMode", "--update-mode", "DotNetWorkloadUpdateMode?", "Controls whether updates look for workload set versions or individual manifest versions. To display the current mode, specify this option without an argument."), + diagnosticsArg + ] + ), + new( + "DotNetWorkloadInstall", + "Installs optional workloads.", + [ + paraStart, + "This command installs one or more optional workloads. Optional workloads can be installed on top of the .NET SDK to provide support for various application types, such as .NET MAUI and Blazor WebAssembly AOT.", + paraFinish, + CreateCliRef("dotnet-workload-install") + ], + ["workload", "install", "$Workloads"], + [ + new Arg("Workloads", "", "IEnumerable", "The workload ID or multiple IDs to install. Use dotnet workload search to learn what workloads are available.") { IsProject = true, IsCollection = true }, + sourcesArg, + configFileArg, + disableParallelArg, + ignoreFailedSourcesArg, + includePreviewsArg, + noCacheArg, + skipManifestUpdateArg, + tempDirArg, + verbosityArg, + new Arg("Version", "--version", "bool?", "The workload set version to install or update to. If you specify the workload-set version in global.json, you can't use the --version option to specify the workload-set version. To make it possible to use the --version option in that case, run the command outside of the path containing the global.json file. Available since 8.0.400 SDK."), + diagnosticsArg + ] + ), + new( + "DotNetWorkloadList", + "Lists installed workloads.", + [ + paraStart, + "This command lists all installed workloads.", + paraFinish, + CreateCliRef("dotnet-workload-list") + ], + ["workload", "list"], + [ + verbosityArg, + diagnosticsArg + ] + ), + new( + "DotNetWorkloadRepair", + "Repairs workloads installations.", + [ + paraStart, + "This command reinstalls all installed workloads. Workloads are made up of multiple workload packs and it's possible to get into a state where some installed successfully but others didn't.", + paraFinish, + CreateCliRef("dotnet-workload-repair") + ], + ["workload", "repair"], + [ + sourcesArg, + configFileArg, + disableParallelArg, + ignoreFailedSourcesArg, + includePreviewsArg, + noCacheArg, + tempDirArg, + verbosityArg, + diagnosticsArg + ] + ), + new( + "DotNetWorkloadRestore", + "Installs workloads needed for a project or a solution.", + [ + paraStart, + "This command analyzes a project or solution to determine which workloads it needs, then installs any workloads that are missing.", + paraFinish, + CreateCliRef("dotnet-workload-restore") + ], + ["workload", "restore", "$Project"], + [ + sourcesArg, + projectArg with { Comments = "The project or solution file to install workloads for. If a file is not specified, the command searches the current directory for one." }, + configFileArg, + disableParallelArg, + ignoreFailedSourcesArg, + includePreviewsArg, + noCacheArg, + skipManifestUpdateArg, + tempDirArg, + verbosityArg, + new Arg("Version", "--version", "bool?", "The workload set version to install or update to. If you specify the workload-set version in global.json, you can't use the --version option to specify the workload-set version. To make it possible to use the --version option in that case, run the command outside of the path containing the global.json file. Available since 8.0.400 SDK."), + diagnosticsArg + ] + ), + new( + "DotNetWorkloadSearch", + "Searches for optional workloads.", + [ + paraStart, + "This command lists available workloads. You can filter the list by specifying all or part of the workload ID you're looking for.", + paraFinish, + CreateCliRef("dotnet-workload-search") + ], + ["workload", "search", "$SearchString"], + [ + new Arg("SearchString", "", "string", "The workload ID to search for, or part of it. For example, if you specify maui, the command lists all of the workload IDs that have maui in their workload ID.") { IsProject = true }, + verbosityArg, + diagnosticsArg + ] + ), + new( + "DotNetWorkloadUninstall", + "Uninstalls a specified workload.", + [ + paraStart, + "This command uninstalls one or more workloads.", + paraFinish, + CreateCliRef("dotnet-workload-uninstall") + ], + ["workload", "uninstall", "$Workloads"], + [ + new Arg("Workloads", "", "IEnumerable", "The workload ID or multiple IDs to uninstall.") { IsProject = true, IsCollection = true }, + diagnosticsArg + ] + ), + new( + "DotNetWorkloadUpdate", + "Updates installed workloads.", + [ + paraStart, + "This command updates all installed workloads to the newest available versions. It queries Nuget.org for updated workload manifests. It then updates local manifests, downloads new versions of the installed workloads, and removes all old versions of each workload. When the command is in workload-set update mode, workloads are updated according to the workload-set version, not the latest version of each individual workload.", + paraFinish, + CreateCliRef("dotnet-workload-update") + ], + ["workload", "update"], + [ + sourcesArg, + new Arg("AdvertisingManifestsOnly", "--advertising-manifests-only", "bool?", "Downloads advertising manifests but doesn't update any workloads."), + configFileArg, + disableParallelArg, + new Arg("FromPreviousSdk", "--from-previous-sdk", "bool?", "Include workloads installed with previous SDK versions in the update."), + ignoreFailedSourcesArg, + includePreviewsArg, + noCacheArg, + tempDirArg, + verbosityArg, + new Arg("Version", "--version", "bool?", "The workload set version to install or update to. If you specify the workload-set version in global.json, you can't use the --version option to specify the workload-set version. To make it possible to use the --version option in that case, run the command outside of the path containing the global.json file. Available since 8.0.400 SDK."), + diagnosticsArg + ] + ), + new( + "DotNetCsi", + "Runs a C# script.", + [ + "
C# interactive
" + ], + ["csi", "$Script"], + [ + propsArg, + sourcesArg, + new Arg("Script", "", "string", "Script to execute."), + new Arg("Version", "--version", "bool?", "Prints out the version."), + diagnosticsArg + ] + ) + }; + + foreach (var command in commands) + { + var name = command.Name; + var commandArgs = new List(); + foreach (var arg in command.CommandArgs) + { + if (arg.StartsWith("$")) + { + var curArg = arg.Substring(1); + 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(); + commandArgs.Add(compositeArg); + } + else + { + commandArgs.Add($"{curArg}.ToArg()"); + } + } + else + { + commandArgs.Add($"\"{arg}\""); + } + } +#> + +/// +/// <#= command.Description #> +<# + foreach (var comment in command.Comments) + { +#> +/// <#= comment #> +<# + } + + var exampleFile = Path.Combine("..", "CSharpInteractive.Tests", "UsageScenarios", "Comments", $"{command.Name}Scenario.txt"); + if (File.Exists(exampleFile)) + { + var exampleLines = File.ReadAllLines(exampleFile); + if (exampleLines.Length > 0) + { +#> +/// <#= exampleStart #> +///<#= codeStart #> +<# + var doc = new XmlDocument(); + foreach (var exampleLine in exampleLines.Select(i => i.TrimEnd())) + { + var node = doc.CreateElement("root"); + node.InnerText = exampleLine; + var line = node.InnerXml; +#> +/// <#= line #> +<# + } +#> +///<#= codeFinish #> +/// <#= exampleFinish #> +<# + } + } +#> +/// +/// 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 => 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 => !i.IsCollection)) + { +#> +/// <#= arg.Comments #> +<# + } +#> +/// Specifies a short name for this operation. +[Target] +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 => i.IsCollection)))); + var fullInitializer = string.Join(", ", new[] {"[]", "[]"}.Concat(Enumerable.Repeat("[]", command.Args.Count(i => i.IsCollection)))); + foreach (var arg in command.Args) + { + var type = arg.Type; + var defaultValue = ""; + if (!string.IsNullOrWhiteSpace(arg.DefaultValue)) + { + defaultValue = $" = {arg.DefaultValue}"; + } + else + { + if (type == "string") + { + defaultValue = " = \"\""; + } + else + { + if (!arg.IsCollection) + { + defaultValue = " = default"; + } + } + } +#> + <#= type #> <#= arg.PropertyName #><#= defaultValue #>, +<# + } +#> + string ExecutablePath = "", + string WorkingDirectory = "", + string ShortName = "") +{ + /// + /// Create a new instance of the command. + /// + /// Specifies the set of command line arguments to use when starting the tool. + public <#= name #>(params string[] args) + : this(<#= initializer #>) + { + } + + /// + /// Create a new instance of the command. + /// + public <#= name #>() + : this(<#= fullInitializer #>) + { + } + + /// + public IStartInfo GetStartInfo(IHost host) + { + if (host == null) throw new ArgumentNullException(nameof(host)); +<# + if ((command.CommandTypes & CommandTypes.RequiresSettings) == CommandTypes.RequiresSettings) + { +#> + var components = host.GetService(); + var virtualContext = components.VirtualContext; + var settings = components.DotNetSettings; +<# + } +#> + return host.CreateCommandLine(ExecutablePath) + .WithShortName(ToString()) + .WithWorkingDirectory(WorkingDirectory) + .WithVars(Vars.ToArray()) +<# + foreach (var arg in command.CommandArgs) + { + if (arg.StartsWith("$")) + { + 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()"; + } + else + { + notEmptyArg = $"{notEmptyArg}.ToArg()"; + } +#> + .AddNotEmptyArgs(<#= notEmptyArg #>) +<# + } + else + { +#> + .AddArgs("<#= arg #>") +<# + } + } +#> +<# + if ((command.CommandTypes & CommandTypes.Build) == CommandTypes.Build) + { +#> + .AddMSBuildLoggers(host, Verbosity) +<# + } + + if ((command.CommandTypes & CommandTypes.Test) == CommandTypes.Test) + { +#> + .AddTestLoggers(host, Loggers) +<# + } + + foreach (var additionalArg in command.AdditionalArgs) + { +#> + .AddArgs("<#= additionalArg #>") +<# + } + + foreach (var arg in command.Args.Where(i => !i.IsProject).Where(i => i.IsCollection && i.ArgName != "--property")) + { +#> + .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") && !i.IsCollection)) + { + if (string.IsNullOrWhiteSpace(arg.AddArgOverride)) + { +#> + .AddArgs(<#= arg.PropertyName #>.ToArgs("<#= arg.ArgName #>", "<#= arg.CollectionSeparator #>")) +<# + } + else + { +#> + <#= arg.AddArgOverride #> +<# + } + } + + var boolArgs = command.Args.Where(i => !string.IsNullOrWhiteSpace(i.ArgName) && i.Type.StartsWith("bool")).ToArray(); +#><#= boolArgs.Length > 0 ? " .AddBooleanArgs(\n": ""#><# + for (var i = 0; i < boolArgs.Length; i++) + { + var arg = boolArgs[i]; +#> + ("<#= arg.ArgName #>", <#= arg.PropertyName #>)<#= i < boolArgs.Length - 1 ? "," : "" #> +<# + } +#><#= boolArgs.Length > 0 ? " )\n": ""#><# + 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()); + } + + /// + public override string ToString() => (ExecutablePath == string.Empty ? "dotnet" : Path.GetFileNameWithoutExtension(ExecutablePath)).GetShortName("<#= command.Description #>", ShortName, <#= string.Join(", ", commandArgs) #>); +} +<# + } +#> +<#+ + public record Arg( + string PropertyName, + string ArgName, + string Type, + string Comments) + { + public string PropertyName { get; } = PropertyName; + public string ArgName { get; set; } = 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; } = ""; + public string DefaultValue { get; set; } + public string AddArgOverride { get; set; } + } + + [Flags] + public enum CommandTypes + { + Default = 0, + Build = 1, + Test = 2, + RequiresSettings = 4 + } + + public record Command( + string Name, + string Description, + string[] Comments, + string[] CommandArgs, + Arg[] Args, + CommandTypes CommandTypes = CommandTypes.Default, + params string[] AdditionalArgs) + { + public string Name { get; } = Name; + public string Description { get; } = Description; + 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/DotNetCustom.cs b/CSharpInteractive.HostApi/DotNetCustom.cs index 212cd3ce..5c728054 100644 --- a/CSharpInteractive.HostApi/DotNetCustom.cs +++ b/CSharpInteractive.HostApi/DotNetCustom.cs @@ -7,7 +7,7 @@ namespace HostApi; using Internal.DotNet; /// -/// The dotnet custom command is used to execute any dotnet commands with any arguments. +/// Executes a custom dotnet command. /// /// /// NuGetVersion? version = default; @@ -21,11 +21,17 @@ namespace HostApi; /// Specifies the set of environment variables that apply to this process and its child processes. /// Overrides the tool executable path. /// Specifies the working directory for the tool to be started. +/// Specifies to use of a build logger. +/// Specifies to use of a tests logger. +/// Sets the verbosity level of the command. Allowed values are , , , , and . The default is . For more information, see . /// Specifies whether the ability to use build loggers is supported. The default is set to true. [Target] public partial record DotNetCustom( IEnumerable Args, IEnumerable<(string name, string value)> Vars, + bool? Build = default, + bool? Tests = default, + DotNetVerbosity? Verbosity = default, string ExecutablePath = "", string WorkingDirectory = "", string ShortName = "") @@ -42,7 +48,18 @@ public DotNetCustom(params string[] args) public IStartInfo GetStartInfo(IHost host) { if (host == null) throw new ArgumentNullException(nameof(host)); - return host.CreateCommandLine(ExecutablePath) + var cmd = host.CreateCommandLine(ExecutablePath); + if (Build == true) + { + cmd = cmd.AddMSBuildLoggers(host, Verbosity); + } + + if (Tests == true) + { + cmd = cmd.AddTestLoggers(host, Array.Empty()); + } + + return cmd .WithShortName(ToString()) .WithWorkingDirectory(WorkingDirectory) .WithVars(Vars.ToArray()) @@ -51,7 +68,5 @@ public IStartInfo GetStartInfo(IHost host) /// public override string ToString() => - (ExecutablePath == string.Empty - ? "dotnet" - : Path.GetFileNameWithoutExtension(ExecutablePath)).GetShortName(ShortName, Args.FirstOrDefault() ?? string.Empty); + (ExecutablePath == string.Empty ? "dotnet" : Path.GetFileNameWithoutExtension(ExecutablePath)).GetShortName("Executes a custom dotnet command.", ShortName, Args.ToArray()); } \ No newline at end of file diff --git a/CSharpInteractive.HostApi/DotNetFormatSeverity.cs b/CSharpInteractive.HostApi/DotNetFormatSeverity.cs new file mode 100644 index 00000000..d3cef58f --- /dev/null +++ b/CSharpInteractive.HostApi/DotNetFormatSeverity.cs @@ -0,0 +1,35 @@ +namespace HostApi; + +/// +/// The severity of diagnostics. +/// +public enum DotNetFormatSeverity +{ + /// + /// Info + /// + Information, + + /// + /// Warn + /// + Warning, + + /// + /// Error + /// + Error +} + +internal static class DotNetFormatSeverityExtensions +{ + // ReSharper disable once UnusedParameter.Global + public static string[] ToArgs(this DotNetFormatSeverity? severity, string name, string collectionSeparator) => + severity switch + { + DotNetFormatSeverity.Information => [name, "info"], + DotNetFormatSeverity.Warning => [name, "warn"], + DotNetFormatSeverity.Error => [name, "error"], + _ => [] + }; +} \ No newline at end of file diff --git a/CSharpInteractive.HostApi/DotNetLanguage.cs b/CSharpInteractive.HostApi/DotNetLanguage.cs new file mode 100644 index 00000000..9cae78a5 --- /dev/null +++ b/CSharpInteractive.HostApi/DotNetLanguage.cs @@ -0,0 +1,53 @@ +namespace HostApi; + +/// +/// The .NET language. +/// +public enum DotNetLanguage +{ + /// + /// C# + /// + CSharp, + + /// + /// F# + /// + FSharp, + + /// + /// Visual Basic + /// + VisualBasic, + + /// + /// SQL + /// + Sql, + + /// + /// JSON + /// + Json, + + /// + /// TypeScript + /// + TypeScript +} + +internal static class DotNetLanguageExtensions +{ + // 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.TypeScript => [name, "TypeScript"], + _ => [] + }; +} \ No newline at end of file diff --git a/CSharpInteractive.HostApi/DotNetNew.cs b/CSharpInteractive.HostApi/DotNetNew.cs deleted file mode 100644 index b7b5e88e..00000000 --- a/CSharpInteractive.HostApi/DotNetNew.cs +++ /dev/null @@ -1,57 +0,0 @@ -// ReSharper disable UnusedMember.Global -// ReSharper disable MemberCanBePrivate.Global -// ReSharper disable UnusedType.Global - -namespace HostApi; - -using Internal.DotNet; - -/// -/// The dotnet new command creates a .NET project based on a template. -/// -/// -/// var result = new DotNetNew("classlib", "-n", "MyLib", "--force") -/// .Build().EnsureSuccess(); -/// -/// -/// -/// 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. -/// Specifies a short template name, for example 'console'. -/// Overrides the tool executable path. -/// Specifies the working directory for the tool to be started. -/// Specifies a short name for this operation. -[Target] -public partial record DotNetNew( - IEnumerable Args, - IEnumerable<(string name, string value)> Vars, - string TemplateName, - string ExecutablePath = "", - string WorkingDirectory = "", - string ShortName = "") -{ - /// - /// Create a new instance of the command. - /// - /// Specifies a short template name, for example 'console'. - /// Specifies the set of command line arguments to use when starting the tool. - public DotNetNew(string templateName, params string[] args) - : this(args, [], templateName) - { } - - /// - public IStartInfo GetStartInfo(IHost host) - { - if (host == null) throw new ArgumentNullException(nameof(host)); - return host.CreateCommandLine(ExecutablePath) - .WithShortName(ToString()) - .WithWorkingDirectory(WorkingDirectory) - .WithVars(Vars.ToArray()) - .WithArgs("new", TemplateName) - .AddArgs(Args.ToArray()); - } - - /// - public override string ToString() => - (ExecutablePath == string.Empty ? "dotnet new" : Path.GetFileNameWithoutExtension(ExecutablePath)).GetShortName(ShortName, TemplateName); -} \ No newline at end of file diff --git a/CSharpInteractive.HostApi/DotNetNewListColumn.cs b/CSharpInteractive.HostApi/DotNetNewListColumn.cs new file mode 100644 index 00000000..016d01ff --- /dev/null +++ b/CSharpInteractive.HostApi/DotNetNewListColumn.cs @@ -0,0 +1,38 @@ +// ReSharper disable UnusedMember.Global +namespace HostApi; + +/// +/// +/// +public enum DotNetNewListColumn +{ + /// + /// A comma-separated list of languages supported by the template. + /// + Language, + + /// + /// The list of template tags. + /// + Tags, + + /// + /// The template author. + /// + Author, + + /// + /// The template type: project or item. + /// + Type +} + +internal static class DotNetNewListColumnExtensions +{ + // 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]; + } +} \ No newline at end of file diff --git a/CSharpInteractive.HostApi/DotNetNuGetPush.cs b/CSharpInteractive.HostApi/DotNetNuGetPush.cs deleted file mode 100644 index ffbd083d..00000000 --- a/CSharpInteractive.HostApi/DotNetNuGetPush.cs +++ /dev/null @@ -1,91 +0,0 @@ -// ReSharper disable UnusedType.Global -// ReSharper disable UnusedMember.Global - -namespace HostApi; - -using Internal.DotNet; - -/// -/// The dotnet push command pushes a package to the server and publishes it. -/// -/// -/// var apiKey = Props.Get("apiKey", ""); -/// -/// -/// new DotNetNuGetPush().WithApiKey(apiKey); -/// -/// -/// -/// 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. -/// Specifies the server URL. NuGet identifies a UNC or local folder source and simply copies the file there instead of pushing it using HTTP. -/// Specifies the symbol server URL. -/// Specifies the file path to the package to be pushed. -/// Overrides the tool executable path. -/// Specifies the working directory for the tool to be started. -/// Forces the application to run using an invariant, English-based culture. -/// Specifies the timeout for pushing to a server in seconds. Defaults to 300 seconds (5 minutes). Specifying 0 applies the default value. -/// The API key for the server. -/// The API key for the symbol server. -/// Disables buffering when pushing to an HTTP(S) server to reduce memory usage. -/// Doesn't push symbols (even if present). -/// Doesn't append "api/v2/package" to the source URL. -/// When pushing multiple packages to an HTTP(S) server, treats any 409 Conflict response as a warning so that the push can continue. -/// Specifies a short name for this operation. -[Target] -public partial record DotNetNuGetPush( - IEnumerable Args, - IEnumerable<(string name, string value)> Vars, - IEnumerable Sources, - IEnumerable SymbolSources, - string Package = "", - string ExecutablePath = "", - string WorkingDirectory = "", - bool? ForceEnglishOutput = default, - int? Timeout = default, - string ApiKey = "", - string SymbolApiKey = "", - bool? DisableBuffering = default, - bool? NoSymbols = default, - bool? NoServiceEndpoint = default, - bool? SkipDuplicate = default, - string ShortName = "") -{ - /// - /// Create a new instance of the command. - /// - /// Specifies the set of command line arguments to use when starting the tool. - public DotNetNuGetPush(params string[] args) - : this(args, [], [], []) - { } - - /// - public IStartInfo GetStartInfo(IHost host) - { - if (host == null) throw new ArgumentNullException(nameof(host)); - return host.CreateCommandLine(ExecutablePath) - .WithShortName(ToString()) - .WithArgs("nuget", "push") - .AddNotEmptyArgs(Package) - .WithWorkingDirectory(WorkingDirectory) - .WithVars(Vars.ToArray()) - .AddArgs(Sources.Select(i => ("--source", (string?)i)).ToArray()) - .AddArgs(SymbolSources.Select(i => ("--symbol-source", (string?)i)).ToArray()) - .AddArgs( - ("--timeout", Timeout?.ToString()), - ("--api-key", ApiKey), - ("--symbol-api-key", SymbolApiKey) - ) - .AddBooleanArgs( - ("--force-english-output", ForceEnglishOutput), - ("--disable-buffering", DisableBuffering), - ("--no-symbols", NoSymbols), - ("--no-service-endpoint", NoServiceEndpoint), - ("--skip-duplicate", SkipDuplicate) - ) - .AddArgs(Args.ToArray()); - } - - /// - public override string ToString() => "dotnet nuget push".GetShortName(ShortName, Package); -} \ No newline at end of file diff --git a/CSharpInteractive.HostApi/DotNetPack.cs b/CSharpInteractive.HostApi/DotNetPack.cs deleted file mode 100644 index 841fa386..00000000 --- a/CSharpInteractive.HostApi/DotNetPack.cs +++ /dev/null @@ -1,106 +0,0 @@ -// ReSharper disable UnusedType.Global -// ReSharper disable UnusedMember.Global - -namespace HostApi; - -using Internal.DotNet; - -/// -/// The dotnet pack command builds the project and creates NuGet packages. The result of this command is a NuGet package (that is, a .nupkg file). -/// -/// -/// new DotNetPack() -/// .Build() -/// .EnsureSuccess(); -/// -/// -/// -/// MSBuild options for setting properties. -/// 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. -/// Overrides the tool executable path. -/// Specifies the working directory for the tool to be started. -/// The project or solution file to pack. If a project or solution file isn't specified, MSBuild searches the current working directory for a file that has a file extension that ends in either proj or sln and uses that file. -/// Places the built packages in the directory specified. -/// Specifies the target runtime to restore packages for. For a list of Runtime Identifiers (RIDs), see the RID catalog. -/// Doesn't build the project before packing. It also implicitly sets the --no-restore flag. -/// Ignores project-to-project references and only restores the root project. -/// Includes the debug symbols NuGet packages in addition to the regular NuGet packages in the output directory. -/// Includes the debug symbols NuGet packages in addition to the regular NuGet packages in the output directory. The sources files are included in the src folder within the symbols package. -/// Sets the serviceable flag in the package. For more information, see .NET Blog: .NET Framework 4.5.1 Supports Microsoft Security Updates for .NET NuGet Libraries. -/// Doesn't display the startup banner or the copyright message. Available since .NET Core 3.0 SDK. -/// Doesn't execute an implicit restore when running the command. -/// Defines the value for the VersionSuffix MSBuild property. The effect of this property on the package version depends on the values of the Version and VersionPrefix properties. -/// Defines the build configuration. The default for most projects is Debug, but you can override the build configuration settings in your project. -/// 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. -/// 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. -/// Sets the verbosity level of the command. Allowed values are Quiet, Minimal, Normal, Detailed, and Diagnostic. The default is Minimal. For more information, see LoggerVerbosity. -/// Specifies a short name for this operation. -/// -[Target] -public partial record DotNetPack( - IEnumerable<(string name, string value)> Props, - IEnumerable Args, - IEnumerable<(string name, string value)> Vars, - string ExecutablePath = "", - string WorkingDirectory = "", - string Project = "", - string Output = "", - string Runtime = "", - bool? NoBuild = default, - bool? NoDependencies = default, - bool? IncludeSymbols = default, - bool? IncludeSource = default, - bool? Serviceable = default, - bool? NoLogo = default, - bool? NoRestore = default, - string VersionSuffix = "", - string Configuration = "", - bool? UseCurrentRuntime = default, - bool? Force = default, - DotNetVerbosity? Verbosity = default, - string ShortName = "") -{ - /// - /// Create a new instance of the command. - /// - /// Specifies the set of command line arguments to use when starting the tool. - public DotNetPack(params string[] args) - : this([], args, []) - { } - - /// - public IStartInfo GetStartInfo(IHost host) - { - if (host == null) throw new ArgumentNullException(nameof(host)); - return host.CreateCommandLine(ExecutablePath) - .WithShortName(ToString()) - .WithArgs("pack") - .AddNotEmptyArgs(Project) - .WithWorkingDirectory(WorkingDirectory) - .WithVars(Vars.ToArray()) - .AddMSBuildLoggers(host, Verbosity) - .AddArgs( - ("--output", Output), - ("--version-suffix", VersionSuffix), - ("--configuration", Configuration), - ("--runtime", Runtime) - ) - .AddBooleanArgs( - ("--no-build", NoBuild), - ("--no-dependencies", NoDependencies), - ("--include-symbols", IncludeSymbols), - ("--include-source", IncludeSource), - ("--serviceable", Serviceable), - ("--nologo", NoLogo), - ("--no-restore", NoRestore), - ("--use-current-runtime", UseCurrentRuntime), - ("--force", Force) - ) - .AddProps("-p", Props.ToArray()) - .AddArgs(Args.ToArray()); - } - - /// - public override string ToString() => "dotnet pack".GetShortName(ShortName, Project); -} \ No newline at end of file diff --git a/CSharpInteractive.HostApi/DotNetPackageSearchResultFormat.cs b/CSharpInteractive.HostApi/DotNetPackageSearchResultFormat.cs new file mode 100644 index 00000000..08fd9667 --- /dev/null +++ b/CSharpInteractive.HostApi/DotNetPackageSearchResultFormat.cs @@ -0,0 +1,17 @@ +namespace HostApi; + +/// +/// Search result format. +/// +public enum DotNetPackageSearchResultFormat +{ + /// + /// Table + /// + Table, + + /// + /// Json + /// + Json +} \ No newline at end of file diff --git a/CSharpInteractive.HostApi/DotNetPublish.cs b/CSharpInteractive.HostApi/DotNetPublish.cs deleted file mode 100644 index 13f413d4..00000000 --- a/CSharpInteractive.HostApi/DotNetPublish.cs +++ /dev/null @@ -1,117 +0,0 @@ -// ReSharper disable UnusedType.Global -// ReSharper disable InconsistentNaming -// ReSharper disable UnusedMember.Global - -namespace HostApi; - -using Internal.DotNet; - -/// -/// The dotnet publish command compiles the application, reads through its dependencies specified in the project file, and publishes the resulting set of files to a directory. -/// -/// -/// new DotNetPublish().AddProps(("PublishDir", ".publish")) -/// .Build().EnsureSuccess(); -/// -/// -/// -/// MSBuild options for setting properties. -/// 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. -/// The URI of the NuGet package source to use during the restore operation. -/// Overrides the tool executable path. -/// Specifies the working directory for the tool to be started. -/// The project or solution to publish. -/// 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. -/// Specifies the path for the output directory. If not specified, it defaults to [project_file_folder]/bin/[configuration]/[framework]/publish/ for a framework-dependent executable and cross-platform binaries. It defaults to [project_file_folder]/bin/[configuration]/[framework]/[runtime]/publish/ for a self-contained executable.In a web project, if the output folder is in the project folder, successive dotnet publish commands result in nested output folders. -/// Specifies one or several target manifests to use to trim the set of packages published with the app. The manifest file is part of the output of the dotnet store command. To specify multiple manifests, add a --manifest option for each manifest. -/// Doesn't build the project before publishing. It also implicitly sets the --no-restore flag. -/// Ignores project-to-project references and only restores the root project. -/// Publishes the .NET runtime with your application so the runtime doesn't need to be installed on the target machine. Default is true if a runtime identifier is specified and the project is an executable project (not a library project). For more information, see .NET application publishing and Publish .NET apps with the .NET CLI. If this option is used without specifying true or false, the default is true. In that case, don't put the solution or project argument immediately after --self-contained, because true or false is expected in that position. -/// Equivalent to --self-contained false. Available since .NET Core 3.0 SDK. -/// Doesn't display the startup banner or the copyright message. Available since .NET Core 3.0 SDK. -/// 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. -/// Publishes the application for the specified target framework. You must specify the target framework in the project file. -/// Publishes the application for a given runtime. For a list of Runtime Identifiers (RIDs), see the RID catalog. For more information, see .NET application publishing and Publish .NET apps with the .NET CLI. If you use this option, use --self-contained or --no-self-contained also. -/// Defines the build configuration. The default for most projects is Debug, but you can override the build configuration settings in your project. -/// Defines the version suffix to replace the asterisk (*) in the version field of the project file. -/// Doesn't execute an implicit restore when running the command. -/// 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&apos;t use the -r|--runtime option. Available since .NET 6 Preview 7. -/// 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. -/// Sets the verbosity level of the command. Allowed values are Quiet, Minimal, Normal, Detailed, and Diagnostic. The default is Minimal. For more information, see LoggerVerbosity. -/// Specifies a short name for this operation. -[Target] -public partial record DotNetPublish( - IEnumerable<(string name, string value)> Props, - IEnumerable Args, - IEnumerable<(string name, string value)> Vars, - IEnumerable Sources, - string ExecutablePath = "", - string WorkingDirectory = "", - string Project = "", - bool? UseCurrentRuntime = default, - string Output = "", - string Manifest = "", - bool? NoBuild = default, - bool? NoDependencies = default, - bool? SelfContained = default, - bool? NoSelfContained = default, - bool? NoLogo = default, - bool? Force = default, - string Framework = "", - string Runtime = "", - string Configuration = "", - string VersionSuffix = "", - bool? NoRestore = default, - string Arch = "", - string OS = "", - DotNetVerbosity? Verbosity = default, - string ShortName = "") -{ - /// - /// Create a new instance of the command. - /// - /// Specifies the set of command line arguments to use when starting the tool. - public DotNetPublish(params string[] args) - : this([], args, [], []) - { } - - /// - public IStartInfo GetStartInfo(IHost host) - { - if (host == null) throw new ArgumentNullException(nameof(host)); - return host.CreateCommandLine(ExecutablePath) - .WithShortName(ToString()) - .WithArgs("publish") - .AddNotEmptyArgs(Project) - .WithWorkingDirectory(WorkingDirectory) - .WithVars(Vars.ToArray()) - .AddMSBuildLoggers(host, Verbosity) - .AddArgs(Sources.Select(i => ("--source", (string?)i)).ToArray()) - .AddArgs( - ("--output", Output), - ("--manifest", Manifest), - ("--framework", Framework), - ("--runtime", Runtime), - ("--configuration", Configuration), - ("--version-suffix", VersionSuffix), - ("--arch", Arch), - ("--os", OS) - ) - .AddBooleanArgs( - ("--use-current-runtime", UseCurrentRuntime), - ("--no-build", NoBuild), - ("--no-dependencies", NoDependencies), - ("--self-contained", SelfContained), - ("--no-self-contained", NoSelfContained), - ("--nologo", NoLogo), - ("--no-restore", NoRestore), - ("--force", Force) - ) - .AddProps("-p", Props.ToArray()) - .AddArgs(Args.ToArray()); - } - - /// - public override string ToString() => "dotnet publish".GetShortName(ShortName, Project); -} \ No newline at end of file diff --git a/CSharpInteractive.HostApi/DotNetRestore.cs b/CSharpInteractive.HostApi/DotNetRestore.cs deleted file mode 100644 index 7cd77990..00000000 --- a/CSharpInteractive.HostApi/DotNetRestore.cs +++ /dev/null @@ -1,107 +0,0 @@ -// ReSharper disable UnusedType.Global -// ReSharper disable UnusedMember.Global - -namespace HostApi; - -using Internal.DotNet; - -/// -/// The dotnet restore command uses NuGet to restore dependencies as well as project-specific tools that are specified in the project file. In most cases, you don't need to explicitly use the dotnet restore command. -/// -/// -/// new DotNetRestore() -/// .Build().EnsureSuccess(); -/// -/// -/// -/// MSBuild options for setting properties. -/// 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. -/// Specifies the URI of the NuGet package source to use during the restore operation. This setting overrides all the sources specified in the nuget.config files. -/// Overrides the tool executable path. -/// Specifies the working directory for the tool to be started. -/// Optional path to the project file to restore. -/// Specifies the directory for restored packages. -/// Use current runtime as the target runtime. -/// Disables restoring multiple projects in parallel. -/// 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. -/// Specifies to not cache HTTP requests. -/// Only warn about failed sources if there are packages meeting the version requirement. -/// 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. -/// Specifies a runtime for the package restore. This is used to restore packages for runtimes not explicitly listed in the <RuntimeIdentifiers> tag in the .csproj file. For a list of Runtime Identifiers (RIDs), see the RID catalog. Provide multiple RIDs by specifying this option multiple times. -/// When restoring a project with project-to-project (P2P) references, restores the root project and not the references. -/// Enables project lock file to be generated and used with restore. -/// Don't allow updating project lock file. -/// Output location where project lock file is written. By default, this is PROJECT_ROOT\packages.lock.json. -/// Forces restore to reevaluate all dependencies even if a lock file already exists. -/// Sets the verbosity level of the command. Allowed values are Quiet, Minimal, Normal, Detailed, and Diagnostic. The default is Minimal. For more information, see LoggerVerbosity. -/// Specifies a short name for this operation. -[Target] -public partial record DotNetRestore( - IEnumerable<(string name, string value)> Props, - IEnumerable Args, - IEnumerable<(string name, string value)> Vars, - IEnumerable Sources, - string ExecutablePath = "", - string WorkingDirectory = "", - string Project = "", - string Packages = "", - bool? UseCurrentRuntime = default, - bool? DisableParallel = default, - string ConfigFile = "", - bool? NoCache = default, - bool? IgnoreFailedSources = default, - bool? Force = default, - string Runtime = "", - bool? NoDependencies = default, - bool? UseLockFile = default, - bool? LockedMode = default, - string LockFilePath = "", - bool? ForceEvaluate = default, - DotNetVerbosity? Verbosity = default, - string ShortName = "") -{ - /// - /// Create a new instance of the command. - /// - /// Specifies the set of command line arguments to use when starting the tool. - public DotNetRestore(params string[] args) - : this([], args, [], []) - { } - - /// - public IStartInfo GetStartInfo(IHost host) - { - if (host == null) throw new ArgumentNullException(nameof(host)); - return host.CreateCommandLine(ExecutablePath) - .WithShortName(ToString()) - .WithArgs("restore") - .AddNotEmptyArgs(Project) - .WithWorkingDirectory(WorkingDirectory) - .WithVars(Vars.ToArray()) - .AddMSBuildLoggers(host, Verbosity) - .AddArgs(Sources.Select(i => ("--source", (string?)i)).ToArray()) - .AddArgs( - ("--packages", Packages), - ("--configfile", ConfigFile), - ("--runtime", Runtime), - ("--lock-file-path", LockFilePath) - ) - .AddBooleanArgs( - ("--use-current-runtime", UseCurrentRuntime), - ("--disable-parallel", DisableParallel), - ("--no-cache", NoCache), - ("--ignore-failed-sources", IgnoreFailedSources), - ("--force", Force), - ("--no-dependencies", NoDependencies), - ("--use-lock-file", UseLockFile), - ("--locked-mode", LockedMode), - ("--force-evaluate", ForceEvaluate) - ) - .AddProps("-p", Props.ToArray()) - .AddArgs(Args.ToArray()); - } - - /// - public override string ToString() => "dotnet restore".GetShortName(ShortName, Project); -} \ No newline at end of file diff --git a/CSharpInteractive.HostApi/DotNetRollForward.cs b/CSharpInteractive.HostApi/DotNetRollForward.cs new file mode 100644 index 00000000..705e22b1 --- /dev/null +++ b/CSharpInteractive.HostApi/DotNetRollForward.cs @@ -0,0 +1,38 @@ +// ReSharper disable UnusedMember.Global +namespace HostApi; + +/// +/// Controls how roll forward is applied to the app. +/// +public enum DotNetRollForward +{ + /// + /// Roll forward to the highest patch version. This disables minor version roll forward. + /// + LatestPatch, + + /// + /// Roll forward to the lowest higher minor version, if requested minor version is missing. If the requested minor version is present, then the LatestPatch policy is used. + /// + Minor, + + /// + /// Roll forward to lowest higher major version, and lowest minor version, if requested major version is missing. If the requested major version is present, then the Minor policy is used. + /// + Major, + + /// + /// Roll forward to highest minor version, even if requested minor version is present. Intended for component hosting scenarios. + /// + LatestMinor, + + /// + /// Roll forward to highest major and highest minor version, even if requested major is present. Intended for component hosting scenarios. + /// + LatestMajor, + + /// + /// Don't roll forward. Only bind to specified version. This policy isn't recommended for general use because it disables the ability to roll forward to the latest patches. This value is only recommended for testing. + /// + Disable +} \ No newline at end of file diff --git a/CSharpInteractive.HostApi/DotNetRun.cs b/CSharpInteractive.HostApi/DotNetRun.cs deleted file mode 100644 index 66d97a96..00000000 --- a/CSharpInteractive.HostApi/DotNetRun.cs +++ /dev/null @@ -1,104 +0,0 @@ -// ReSharper disable UnusedType.Global -// ReSharper disable UnusedMember.Global -// ReSharper disable InconsistentNaming - -namespace HostApi; - -using Internal.DotNet; - -/// -/// The dotnet run command provides a convenient option to run your application from the source code with one command. It's useful for fast iterative development from the command line. The command depends on the dotnet build command to build the code. Any requirements for the build, such as that the project must be restored first, apply to dotnet run as well. -/// -/// -/// var result = new DotNetNew("console", "-n", "MyApp", "--force") -/// .Build().EnsureSuccess(); -/// -/// -/// new DotNetRun().WithWorkingDirectory("MyApp") -/// .Build().EnsureSuccess(); -/// -/// -/// -/// MSBuild options for setting properties. -/// Specifies the set of command line arguments to use when starting the application. -/// Specifies the set of environment variables that apply to this process and its child processes. -/// Overrides the tool executable path. -/// Specifies the working directory for the tool to be started. -/// Builds and runs the app using the specified framework. The framework must be specified in the project file. -/// Defines the build configuration. The default for most projects is Debug, but you can override the build configuration settings in your project. -/// 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. -/// Specifies the path of the project file to run (folder name or full path). If not specified, it defaults to the current directory. -/// 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. For more information, see Working with multiple environments. -/// Doesn't try to use launchSettings.json to configure the application. -/// Doesn't build the project before running. It also implicit sets the --no-restore flag. -/// Doesn't execute an implicit restore when running the command. -/// When restoring a project with project-to-project (P2P) references, restores the root project and not the references. -/// 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. -/// 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. -/// 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. -/// Sets the verbosity level of the command. Allowed values are Quiet, Minimal, Normal, Detailed, and Diagnostic. The default is Minimal. For more information, see LoggerVerbosity. -/// Specifies a short name for this operation. -/// -[Target] -public partial record DotNetRun( - IEnumerable<(string name, string value)> Props, - IEnumerable Args, - IEnumerable<(string name, string value)> Vars, - string ExecutablePath = "", - string WorkingDirectory = "", - string Framework = "", - string Configuration = "", - string Runtime = "", - string Project = "", - string LaunchProfile = "", - bool? NoLaunchProfile = default, - bool? NoBuild = default, - bool? NoRestore = default, - bool? NoDependencies = default, - bool? Force = default, - string Arch = "", - string OS = "", - DotNetVerbosity? Verbosity = default, - string ShortName = "") -{ - /// - /// Create a new instance of the command. - /// - /// Specifies the set of command line arguments to use when starting the tool. - public DotNetRun(params string[] args) - : this([], args, []) - { } - - /// - public IStartInfo GetStartInfo(IHost host) - { - if (host == null) throw new ArgumentNullException(nameof(host)); - return host.CreateCommandLine(ExecutablePath) - .WithShortName(ToString()) - .WithArgs("run") - .WithWorkingDirectory(WorkingDirectory) - .WithVars(Vars.ToArray()) - .AddArgs( - ("--framework", Framework), - ("--configuration", Configuration), - ("--runtime", Runtime), - ("--project", Project), - ("--launch-profile", LaunchProfile), - ("--verbosity", Verbosity?.ToString().ToLowerInvariant()), - ("--arch", Arch), - ("--os", OS) - ) - .AddBooleanArgs( - ("--no-launch-profile", NoLaunchProfile), - ("--no-build", NoBuild), - ("--no-restore", NoRestore), - ("--no-dependencies", NoDependencies), - ("--force", Force) - ) - .AddProps("--property", Props.ToArray()) - .AddArgs(Args.ToArray()); - } - - /// - public override string ToString() => "dotnet run".GetShortName(ShortName, Project); -} \ No newline at end of file diff --git a/CSharpInteractive.HostApi/DotNetTemplateType.cs b/CSharpInteractive.HostApi/DotNetTemplateType.cs new file mode 100644 index 00000000..73b3ba68 --- /dev/null +++ b/CSharpInteractive.HostApi/DotNetTemplateType.cs @@ -0,0 +1,23 @@ +// ReSharper disable UnusedMember.Global +namespace HostApi; + +/// +/// Template type. +/// +public enum DotNetTemplateType +{ + /// + /// Project + /// + Project, + + /// + /// Item + /// + Item, + + /// + /// Solution + /// + Solution +} \ No newline at end of file diff --git a/CSharpInteractive.HostApi/DotNetTerminalLogger.cs b/CSharpInteractive.HostApi/DotNetTerminalLogger.cs new file mode 100644 index 00000000..44d1b9cf --- /dev/null +++ b/CSharpInteractive.HostApi/DotNetTerminalLogger.cs @@ -0,0 +1,23 @@ +// ReSharper disable UnusedMember.Global +namespace HostApi; + +/// +/// Terminal logger modes. +/// +public enum DotNetTerminalLogger +{ + /// + /// First verifies the environment before enabling terminal logging. + /// + Auto, + + /// + /// Skips the environment check and enables terminal logging. + /// + On, + + /// + /// Skips the environment check and uses the default console logger. + /// + Off +} \ No newline at end of file diff --git a/CSharpInteractive.HostApi/DotNetTest.cs b/CSharpInteractive.HostApi/DotNetTest.cs deleted file mode 100644 index b13c2bc5..00000000 --- a/CSharpInteractive.HostApi/DotNetTest.cs +++ /dev/null @@ -1,164 +0,0 @@ -// ReSharper disable UnusedType.Global -// ReSharper disable UnusedMember.Global -// ReSharper disable InconsistentNaming -// ReSharper disable CommentTypo - -namespace HostApi; - -using Internal; -using Internal.DotNet; - -/// -/// The dotnet test command is used to execute unit tests in a given solution. The dotnet test command builds the solution and runs a test host application for each test project in the solution. The test host executes tests in the given project using a test framework, for example: MSTest, NUnit, or xUnit, and reports the success or failure of each test. If all tests are successful, the test runner returns 0 as an exit code; otherwise if any test fails, it returns 1. -/// -/// -/// new DotNetNew("mstest", "-n", "MyTests", "--force") -/// .Build().EnsureSuccess(); -/// -/// -/// new DotNetTest().WithWorkingDirectory("MyTests") -/// .Build().EnsureSuccess(); -/// -/// -/// -/// MSBuild options for setting properties. -/// 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. -/// Specifies RunSettings passed to tests. -/// Specifies a logger for test results. Use "console;verbosity=detailed". Specify the parameter multiple times to enable multiple loggers. -/// Overrides the tool executable path. -/// Specifies the working directory for the tool to be started. -/// Path to the test project, to the solution, to a directory that contains a project or a solution or to a test project .dll file. -/// The .runsettings file to use for running the tests. The TargetPlatform element (x86|x64) has no effect for dotnet test. To run tests that target x86, install the x86 version of .NET Core. The bitness of the dotnet.exe that is on the path is what will be used for running tests. -/// List the discovered tests instead of running the tests. -/// Filters out tests in the current project using the given expression. For more information, see the Filter option details section. For more information and examples on how to use selective unit test filtering, see Running selective unit tests. -/// Path to a directory to be searched for additional test adapters. Only .dll files with suffix .TestAdapter.dll are inspected. If not specified, the directory of the test .dll is searched. -/// Defines the build configuration. The default for most projects is Debug, but you can override the build configuration settings in your project. -/// Forces the use of dotnet or .NET Framework test host for the test binaries. This option only determines which type of host to use. The actual framework version to be used is determined by the runtimeconfig.json of the test project. When not specified, the TargetFramework assembly attribute is used to determine the type of host. When that attribute is stripped from the .dll, the .NET Framework host is used. -/// The target runtime to test for. -/// Directory in which to find the binaries to run. 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. dotnet test always runs tests from the output directory. You can use AppDomain.BaseDirectory to consume test assets in the output directory. -/// Enables diagnostic mode for the test platform and writes diagnostic messages to the specified file and to files next to it. The process that is logging the messages determines which files are created, such as *.host_<date>.txt for test host log, and *.datacollector_<date>.txt for data collector log. -/// Doesn't build the test project before running it. It also implicitly sets the - --no-restore flag. -/// The directory where the test results are going to be placed. If the specified directory doesn't exist, it's created. The default is TestResults in the directory that contains the project file. -/// Enables data collector for the test run. For more information, see Monitor and analyze test run. -/// Runs the tests in blame mode. This option is helpful in isolating problematic tests that cause the test host to crash. When a crash is detected, it creates a sequence file in TestResults/<Guid>/<Guid>_Sequence.xml that captures the order of tests that were run before the crash. -/// Runs the tests in blame mode and collects a crash dump when the test host exits unexpectedly. This option depends on the version of .NET used, the type of error, and the operating system. -/// The type of crash dump to be collected. Implies BlameCrash. -/// Collects a crash dump on expected as well as unexpected test host exit. -/// Run the tests in blame mode and collects a hang dump when a test exceeds the given timeout. -/// The type of crash dump to be collected. It should be full, mini, or none. When none is specified, test host is terminated on timeout, but no dump is collected. Implies BlameHang. -/// Per-test timeout, after which a hang dump is triggered and the test host process and all of its child processes are dumped and terminated. -/// Run tests without displaying the Microsoft TestPlatform banner. Available since .NET Core 3.0 SDK. -/// Doesn't execute an implicit restore when running the command. -/// 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. -/// 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. -/// Sets the verbosity level of the command. Allowed values are Quiet, Minimal, Normal, Detailed, and Diagnostic. The default is Minimal. For more information, see LoggerVerbosity. -/// Specifies a short name for this operation. -[Target] -public partial record DotNetTest( - IEnumerable<(string name, string value)> Props, - IEnumerable Args, - IEnumerable<(string name, string value)> Vars, - IEnumerable<(string name, string value)> RunSettings, - IEnumerable Loggers, - string ExecutablePath = "", - string WorkingDirectory = "", - string Project = "", - string Settings = "", - bool? ListTests = default, - string Filter = "", - string TestAdapterPath = "", - string Configuration = "", - string Framework = "", - string Runtime = "", - string Output = "", - string Diag = "", - bool? NoBuild = default, - string ResultsDirectory = "", - string Collect = "", - bool? Blame = default, - bool? BlameCrash = default, - string BlameCrashDumpType = "", - bool? BlameCrashCollectAlways = default, - bool? BlameHang = default, - string BlameHangDumpType = "", - TimeSpan? BlameHangTimeout = default, - bool? NoLogo = default, - bool? NoRestore = default, - string Arch = "", - string OS = "", - DotNetVerbosity? Verbosity = default, - string ShortName = "") -{ - /// - /// Create a new instance of the command. - /// - /// Specifies the set of command line arguments to use when starting the tool. - public DotNetTest(params string[] args) - : this([], args, [], [], []) - { } - - /// - public IStartInfo GetStartInfo(IHost host) - { - if (host == null) throw new ArgumentNullException(nameof(host)); - var blameHangTimeout = BlameHangTimeout?.TotalMilliseconds; - // ReSharper disable once UseDeconstruction - var components = host.GetService(); - var virtualContext = components.VirtualContext; - var settings = components.DotNetSettings; - var cmd = host.CreateCommandLine(ExecutablePath) - .WithShortName(ToString()) - .WithArgs("test") - .AddNotEmptyArgs(Project) - .WithWorkingDirectory(WorkingDirectory) - .WithVars(Vars.ToArray()) - .AddTestLoggers(host, Loggers) - .AddArgs( - ("--settings", Settings), - ("--filter", Filter), - ("--test-adapter-path", $"{string.Join(";", new[] {TestAdapterPath, virtualContext.Resolve(settings.DotNetVSTestLoggerDirectory)}.Where(i => !string.IsNullOrWhiteSpace(i)))}"), - ("--configuration", Configuration), - ("--framework", Framework), - ("--runtime", Runtime), - ("--output", Output), - ("--diag", Diag), - ("--results-directory", ResultsDirectory), - ("--collect", Collect), - ("--verbosity", Verbosity?.ToString().ToLowerInvariant()), - ("--arch", Arch), - ("--os", OS), - ("--blame-crash-dump-type", BlameCrashDumpType), - ("--blame-hang-dump-type", BlameHangDumpType), - ("--blame-hang-timeout", blameHangTimeout.HasValue ? $"{(int)blameHangTimeout}milliseconds" : string.Empty) - ) - .AddBooleanArgs( - ("--list-tests", ListTests), - ("--no-build", NoBuild), - ("--blame", Blame), - ("--blame-crash", BlameCrash), - ("--blame-crash-collect-always", BlameCrashCollectAlways), - ("--blame-hang", BlameHang), - ("--nologo", NoLogo), - ("--no-restore", NoRestore) - ) - .AddProps("-p", Props.ToArray()) - .AddArgs(Args.ToArray()); - - if (string.IsNullOrWhiteSpace(Project) || Path.GetExtension(Project).ToLowerInvariant() != ".dll") - { - cmd = cmd.AddMSBuildLoggers(host, Verbosity); - } - - var runSettings = RunSettings.Select(i => $"{i.name}={i.value}").ToArray(); - if (runSettings.Any()) - { - cmd = cmd.AddArgs("--").AddArgs(runSettings); - } - - return cmd; - } - - /// - public override string ToString() => "dotnet test".GetShortName(ShortName, Project); -} \ No newline at end of file diff --git a/CSharpInteractive.HostApi/DotNetToolRestore.cs b/CSharpInteractive.HostApi/DotNetToolRestore.cs deleted file mode 100644 index 7d5fd4c6..00000000 --- a/CSharpInteractive.HostApi/DotNetToolRestore.cs +++ /dev/null @@ -1,77 +0,0 @@ -// ReSharper disable UnusedType.Global -// ReSharper disable UnusedMember.Global - -namespace HostApi; - -using Internal.DotNet; - -/// -/// The dotnet tool restore command finds the tool manifest file that is in scope for the current directory and installs the tools that are listed in it. -/// -/// -/// new DotNetToolRestore() -/// .Run().EnsureSuccess(); -/// -/// -/// -/// 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. -/// Adds an additional NuGet package source to use during installation. Feeds are accessed in parallel, not sequentially in some order of precedence. If the same package and version is in multiple feeds, the fastest feed wins. -/// Overrides the tool executable path. -/// Specifies the working directory for the tool to be started. -/// Prevent restoring multiple projects in parallel. -/// 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. -/// Path to the manifest file. -/// Do not cache packages and http requests. -/// Treat package source failures as warnings. -/// Sets the verbosity level of the command. Allowed values are Quiet, Minimal, Normal, Detailed, and Diagnostic. The default is Minimal. For more information, see LoggerVerbosity. -/// Specifies a short name for this operation. -[Target] -public partial record DotNetToolRestore( - IEnumerable Args, - IEnumerable<(string name, string value)> Vars, - IEnumerable AdditionalSources, - string ExecutablePath = "", - string WorkingDirectory = "", - bool? DisableParallel = default, - string ConfigFile = "", - string ToolManifest = "", - bool? NoCache = default, - bool? IgnoreFailedSources = default, - DotNetVerbosity? Verbosity = default, - string ShortName = "") -{ - /// - /// Create a new instance of the command. - /// - /// Specifies the set of command line arguments to use when starting the tool. - public DotNetToolRestore(params string[] args) - : this(args, [], []) - { } - - /// - public IStartInfo GetStartInfo(IHost host) - { - if (host == null) throw new ArgumentNullException(nameof(host)); - return host.CreateCommandLine(ExecutablePath) - .WithShortName(ToString()) - .WithArgs("tool", "restore") - .WithWorkingDirectory(WorkingDirectory) - .WithVars(Vars.ToArray()) - .AddMSBuildLoggers(host, Verbosity) - .AddArgs(AdditionalSources.Select(i => ("--add-source", (string?)i)).ToArray()) - .AddArgs( - ("--configfile", ConfigFile), - ("--tool-manifest", ToolManifest) - ) - .AddBooleanArgs( - ("--disable-parallel", DisableParallel), - ("--no-cache", NoCache), - ("--ignore-failed-sources", IgnoreFailedSources) - ) - .AddArgs(Args.ToArray()); - } - - /// - public override string ToString() => "dotnet tool restore".GetShortName(ShortName, ToolManifest); -} \ No newline at end of file diff --git a/CSharpInteractive.HostApi/DotNetWorkloadUpdateMode.cs b/CSharpInteractive.HostApi/DotNetWorkloadUpdateMode.cs new file mode 100644 index 00000000..8f24cd06 --- /dev/null +++ b/CSharpInteractive.HostApi/DotNetWorkloadUpdateMode.cs @@ -0,0 +1,29 @@ +namespace HostApi; + +/// +/// Workload-set update mode. +/// +public enum DotNetWorkloadUpdateMode +{ + /// + /// Workload-set update mode. + /// + WorkloadSet, + + /// + /// Manifests update mode. + /// + Manifests +} + +internal static class DotNetWorkloadUpdateModeExtensions +{ + // ReSharper disable once UnusedParameter.Global + public static string[] ToArgs(this DotNetWorkloadUpdateMode? updateMode, string name, string collectionSeparator) => + updateMode switch + { + DotNetWorkloadUpdateMode.WorkloadSet => [name, "workload-set"], + DotNetWorkloadUpdateMode.Manifests => [name, "manifests"], + _ => [] + }; +} \ No newline at end of file diff --git a/CSharpInteractive.HostApi/Internal/DotNet/DotNetCommandLineExtensions.cs b/CSharpInteractive.HostApi/Internal/DotNet/DotNetCommandLineExtensions.cs index 0728f711..d0643002 100644 --- a/CSharpInteractive.HostApi/Internal/DotNet/DotNetCommandLineExtensions.cs +++ b/CSharpInteractive.HostApi/Internal/DotNet/DotNetCommandLineExtensions.cs @@ -7,6 +7,8 @@ namespace HostApi.Internal.DotNet; using System.Diagnostics.Contracts; +using System.Globalization; +using System.Text; [ExcludeFromCodeCoverage] internal static class DotNetCommandLineExtensions @@ -31,20 +33,40 @@ private static string GetExecutablePath(this IHost host, string executablePath) } [Pure] - public static string GetShortName(this string baseName, string shortName, string path = "") + public static string GetShortName(this string baseName, string description, string shortName, params string[] paths) { if (!string.IsNullOrWhiteSpace(shortName)) { return shortName; } - // ReSharper disable once ConvertIfStatementToReturnStatement - if (string.IsNullOrWhiteSpace(path)) + var name = new StringBuilder(); + name.Append(baseName); + foreach (var path in paths) { - return baseName; + if (string.IsNullOrWhiteSpace(path)) + { + continue; + } + + if (name.Length > 0) + { + name.Append(' '); + } + + var fileName = Path.GetFileName(path); + if (string.IsNullOrWhiteSpace(fileName)) + { + name.Append(path); + continue; + } + + name.Append(fileName); } - - return $"{baseName} {Path.GetFileName(path)}"; + + name.Append(" - "); + name.Append(description); + return name.ToString(); } [Pure] @@ -118,4 +140,44 @@ where arg.value ?? false public static CommandLine AddProps(this CommandLine cmd, string propertyName, params (string name, string value)[] props) => cmd.AddArgs(props.Select(i => $"{propertyName}:{i.name}={i.value}") .ToArray()); + + // ReSharper disable once UnusedParameter.Global + public static string[] ToArgs(this T value, string name, string collectionSeparator) + { + if (!string.IsNullOrWhiteSpace(collectionSeparator)) + { + return [$"{name}{collectionSeparator}\"{value}\""]; + } + + var valueStr = value?.ToString(); + return string.IsNullOrWhiteSpace(valueStr) ? [] : [name, valueStr!]; + } + + public static string[] ToArgs(this IEnumerable values, string name, string collectionSeparator) + { + if (string.IsNullOrEmpty(collectionSeparator)) + { + return values.SelectMany(value => string.IsNullOrWhiteSpace(value) ? [] : new[] {name, value}).ToArray(); + } + + if (string.IsNullOrWhiteSpace(collectionSeparator)) + { + var result = Enumerable.Repeat(name, 1).Concat(values).ToArray(); + return result.Length > 1 ? result : []; + } + + var str = string.Join(collectionSeparator, values); + if (string.IsNullOrWhiteSpace(str)) + { + return []; + } + + return string.IsNullOrWhiteSpace(str) ? [] : [name, str]; + } + + // ReSharper disable once UnusedParameter.Global + public static string[] ToArgs(this TimeSpan? value, string name, string collectionSeparator) => + value.HasValue ? [name, value.Value.TotalMilliseconds.ToString(CultureInfo.InvariantCulture)] : []; + + public static string ToArg(this T value) => value?.ToString() ?? ""; } \ No newline at end of file diff --git a/CSharpInteractive.HostApi/MSBuild.cs b/CSharpInteractive.HostApi/MSBuild.cs index 4390a883..fdb10082 100644 --- a/CSharpInteractive.HostApi/MSBuild.cs +++ b/CSharpInteractive.HostApi/MSBuild.cs @@ -8,7 +8,10 @@ namespace HostApi; using Internal.DotNet; /// -/// Builds a project and all of its dependencies. It allows access to a fully functional MSBuild. The command has the exact same capabilities as the existing MSBuild command-line client for SDK-style projects only. The options are all the same. +/// Builds a project and all of its dependencies. +/// +/// The dotnet msbuild command allows access to a fully functional MSBuild. The command has the exact same capabilities as the existing MSBuild command-line client for SDK-style projects only. The options are all the same. +/// > /// /// /// var buildProps = new[] {("version", "1.0.3")}; @@ -46,7 +49,8 @@ namespace HostApi; /// Do not auto-include any MSBuild.rsp files. /// Do not display the startup banner and copyright message. /// Display version information only. -/// Sets the verbosity level of the command. Allowed values are Quiet, Minimal, Normal, Detailed, and Diagnostic. The default is Minimal. For more information, see LoggerVerbosity. +/// Sets the verbosity level of the command. Allowed values are , , , , and . The default is . For more information, see . +/// Enables diagnostic output. /// Specifies a short name for this operation. [Target] public partial record MSBuild( @@ -77,6 +81,7 @@ public partial record MSBuild( bool? NoLogo = default, bool? DisplayVersion = default, DotNetVerbosity? Verbosity = default, + bool? Diagnostics = default, string ShortName = "") { /// @@ -127,7 +132,8 @@ public IStartInfo GetStartInfo(IHost host) ("-detailedSummary", DetailedSummary), ("-noAutoResponse", NoAutoResponse), ("-noLogo", NoLogo), - ("-version", DisplayVersion) + ("-version", DisplayVersion), + ("--diagnostics", Diagnostics) ) .AddProps("-restoreProperty", RestoreProps.ToArray()) .AddProps("-p", Props.ToArray()) @@ -136,7 +142,7 @@ public IStartInfo GetStartInfo(IHost host) /// public override string ToString() => - (ExecutablePath == string.Empty ? "dotnet msbuild" : Path.GetFileNameWithoutExtension(ExecutablePath)).GetShortName(ShortName, Project); + (ExecutablePath == string.Empty ? "dotnet" : Path.GetFileNameWithoutExtension(ExecutablePath)).GetShortName("Builds a project and all of its dependencies.", ShortName, "msbuild", Project); private static string JoinWithSemicolons(IEnumerable arg) => string.Join(";", arg.Where(i => !string.IsNullOrWhiteSpace(i)).Select(i => i.Trim())); diff --git a/CSharpInteractive.HostApi/NuGetAuthenticationType.cs b/CSharpInteractive.HostApi/NuGetAuthenticationType.cs new file mode 100644 index 00000000..b1bf5e1f --- /dev/null +++ b/CSharpInteractive.HostApi/NuGetAuthenticationType.cs @@ -0,0 +1,43 @@ +// ReSharper disable UnusedMember.Global +namespace HostApi; + +/// +/// NuGet authentication types. +/// +public enum NuGetAuthenticationType +{ + /// + /// Basic + /// + Basic, + + /// + /// Negotiate + /// + Negotiate, + + /// + /// Kerberos + /// + Kerberos, + + /// + /// Ntlm + /// + Ntlm, + + /// + /// Digest + /// + Digest +} + +internal static class NuGetAuthenticationTypeExtensions +{ + // 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]; + } +} \ No newline at end of file diff --git a/CSharpInteractive.HostApi/NuGetCacheLocation.cs b/CSharpInteractive.HostApi/NuGetCacheLocation.cs new file mode 100644 index 00000000..7a745ac5 --- /dev/null +++ b/CSharpInteractive.HostApi/NuGetCacheLocation.cs @@ -0,0 +1,40 @@ +namespace HostApi; + +/// +/// The cache location to list or clear. +/// +public enum NuGetCacheLocation +{ + /// + /// Indicates that the specified operation is applied to all cache types: http-request cache, global packages cache, and the temporary cache. + /// + All, + + /// + /// Indicates that the specified operation is applied only to the http-request cache. The other cache locations aren't affected. + /// + HttpCache, + + /// + /// Indicates that the specified operation is applied only to the global packages cache. The other cache locations aren't affected. + /// + GlobalPackages, + + /// + /// Indicates that the specified operation is applied only to the temporary cache. The other cache locations aren't affected. + /// + Temp +} + +internal static class NuGetCacheLocationExtensions +{ + public static string ToArg(this NuGetCacheLocation? cacheLocation) => + cacheLocation switch + { + NuGetCacheLocation.All => "all", + NuGetCacheLocation.HttpCache => "http-cache", + NuGetCacheLocation.GlobalPackages => "global-packages", + NuGetCacheLocation.Temp => "temp", + _ => "" + }; +} \ No newline at end of file diff --git a/CSharpInteractive.HostApi/NuGetCertificateAlgorithm.cs b/CSharpInteractive.HostApi/NuGetCertificateAlgorithm.cs new file mode 100644 index 00000000..1a04c0e7 --- /dev/null +++ b/CSharpInteractive.HostApi/NuGetCertificateAlgorithm.cs @@ -0,0 +1,33 @@ +// ReSharper disable UnusedMember.Global +namespace HostApi; + +/// +/// NuGet certificate algorithm. +/// +public enum NuGetCertificateAlgorithm +{ + /// + /// Sha256 + /// + Sha256, + + /// + /// Sha384 + /// + Sha384, + + /// + /// Sha512 + /// + Sha512 +} + +internal static class NuGetCertificateAlgorithmExtensions +{ + // 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]; + } +} \ No newline at end of file diff --git a/CSharpInteractive.HostApi/NuGetListFormat.cs b/CSharpInteractive.HostApi/NuGetListFormat.cs new file mode 100644 index 00000000..f62b3dee --- /dev/null +++ b/CSharpInteractive.HostApi/NuGetListFormat.cs @@ -0,0 +1,18 @@ +// ReSharper disable UnusedMember.Global +namespace HostApi; + +/// +/// The format of the nuget list command output. +/// +public enum NuGetListFormat +{ + /// + /// Detailed. + /// + Detailed, + + /// + /// Short. + /// + Short +} \ No newline at end of file diff --git a/CSharpInteractive.HostApi/VSTest.cs b/CSharpInteractive.HostApi/VSTest.cs index 7109f6bd..58f34a5f 100644 --- a/CSharpInteractive.HostApi/VSTest.cs +++ b/CSharpInteractive.HostApi/VSTest.cs @@ -9,7 +9,10 @@ namespace HostApi; using Internal.DotNet; /// -/// The dotnet vstest command runs the VSTest.Console command-line application to run automated unit tests. +/// Runs tests from the specified assemblies. +/// +/// This command runs the VSTest.Console command-line application to run automated unit tests. +/// /// /// /// new DotNetPublish() @@ -46,7 +49,8 @@ namespace HostApi; /// Specifies the port for the socket connection and receiving the event messages. /// Enables data collector for the test run. /// Runs the tests in an isolated process. This makes vstest.console.exe process less likely to be stopped on an error in the tests, but tests may run slower. -/// Sets the verbosity level of the command. Allowed values are Quiet, Minimal, Normal, Detailed, and Diagnostic. The default is Minimal. For more information, see LoggerVerbosity. +/// Sets the verbosity level of the command. Allowed values are , , , , and . The default is . For more information, see . +/// Enables diagnostic output. /// Specifies a short name for this operation. /// [Target] @@ -74,6 +78,7 @@ public partial record VSTest( string Collect = "", bool? InIsolation = default, DotNetVerbosity? Verbosity = default, + bool? Diagnostics = default, string ShortName = "") { /// @@ -117,7 +122,8 @@ public IStartInfo GetStartInfo(IHost host) ("--ListTests", ListTests), ("--Parallel", Parallel), ("--Blame", Blame), - ("--InIsolation", InIsolation) + ("--InIsolation", InIsolation), + ("--diagnostics", Diagnostics) ) .AddArgs(Args.ToArray()); @@ -137,5 +143,5 @@ public IStartInfo GetStartInfo(IHost host) /// public override string ToString() => - (string.IsNullOrWhiteSpace(ShortName) ? "dotnet vstest" : ShortName).GetShortName(ShortName, string.Empty); + (ExecutablePath == string.Empty ? "dotnet" : Path.GetFileNameWithoutExtension(ExecutablePath)).GetShortName("Runs tests from the specified assemblies.", ShortName, new [] {"vstest" }.Concat(TestFileNames).ToArg()); } \ No newline at end of file diff --git a/CSharpInteractive.HostApi/VSTestPlatform.cs b/CSharpInteractive.HostApi/VSTestPlatform.cs index 2a1f1c02..ae9c01d9 100644 --- a/CSharpInteractive.HostApi/VSTestPlatform.cs +++ b/CSharpInteractive.HostApi/VSTestPlatform.cs @@ -10,17 +10,17 @@ namespace HostApi; public enum VSTestPlatform { /// - /// + /// x86 /// x86, /// - /// + /// x64 /// x64, /// - /// + /// ARM /// ARM } \ No newline at end of file diff --git a/CSharpInteractive.Tests/AddNuGetReferenceCommandFactoryTests.cs b/CSharpInteractive.Tests/AddNuGetReferenceCommandFactoryTests.cs index d26fcc3e..239becb9 100644 --- a/CSharpInteractive.Tests/AddNuGetReferenceCommandFactoryTests.cs +++ b/CSharpInteractive.Tests/AddNuGetReferenceCommandFactoryTests.cs @@ -1,7 +1,6 @@ namespace CSharpInteractive.Tests; using System.Diagnostics.CodeAnalysis; -using Core; using NuGet.Versioning; [SuppressMessage("Usage", "xUnit1042:The member referenced by the MemberData attribute returns untyped data rows")] diff --git a/CSharpInteractive.Tests/AddNuGetReferenceCommandRunnerTests.cs b/CSharpInteractive.Tests/AddNuGetReferenceCommandRunnerTests.cs index 1c842141..3a0cabc7 100644 --- a/CSharpInteractive.Tests/AddNuGetReferenceCommandRunnerTests.cs +++ b/CSharpInteractive.Tests/AddNuGetReferenceCommandRunnerTests.cs @@ -1,6 +1,5 @@ namespace CSharpInteractive.Tests; -using Core; using NuGet.Versioning; public class AddNuGetReferenceCommandRunnerTests diff --git a/CSharpInteractive.Tests/AssembliesScriptOptionsProviderTests.cs b/CSharpInteractive.Tests/AssembliesScriptOptionsProviderTests.cs index 8c833032..4a983253 100644 --- a/CSharpInteractive.Tests/AssembliesScriptOptionsProviderTests.cs +++ b/CSharpInteractive.Tests/AssembliesScriptOptionsProviderTests.cs @@ -4,7 +4,6 @@ namespace CSharpInteractive.Tests; using System.Diagnostics.CodeAnalysis; using System.Reflection; -using Core; using Microsoft.CodeAnalysis.Scripting; using Microsoft.Extensions.DependencyInjection; diff --git a/CSharpInteractive.Tests/BuildContextTests.cs b/CSharpInteractive.Tests/BuildContextTests.cs index 75c94367..e5d3b298 100644 --- a/CSharpInteractive.Tests/BuildContextTests.cs +++ b/CSharpInteractive.Tests/BuildContextTests.cs @@ -1,7 +1,5 @@ namespace CSharpInteractive.Tests; -using Core; -using HostApi; using JetBrains.TeamCity.ServiceMessages.Write; public class BuildContextTests diff --git a/CSharpInteractive.Tests/BuildMessageLogWriterTests.cs b/CSharpInteractive.Tests/BuildMessageLogWriterTests.cs index a90a37b8..760cd270 100644 --- a/CSharpInteractive.Tests/BuildMessageLogWriterTests.cs +++ b/CSharpInteractive.Tests/BuildMessageLogWriterTests.cs @@ -1,8 +1,5 @@ namespace CSharpInteractive.Tests; -using Core; -using HostApi; - public class BuildMessageLogWriterTests { private static readonly ProcessInfo ProcessInfo = new(Mock.Of(), Mock.Of(), 1); diff --git a/CSharpInteractive.Tests/BuildOutputProcessorTests.cs b/CSharpInteractive.Tests/BuildOutputProcessorTests.cs index 1ab2b16f..090bc004 100644 --- a/CSharpInteractive.Tests/BuildOutputProcessorTests.cs +++ b/CSharpInteractive.Tests/BuildOutputProcessorTests.cs @@ -1,7 +1,5 @@ namespace CSharpInteractive.Tests; -using Core; -using HostApi; using JetBrains.TeamCity.ServiceMessages; using JetBrains.TeamCity.ServiceMessages.Read; diff --git a/CSharpInteractive.Tests/BuildResultTests.cs b/CSharpInteractive.Tests/BuildResultTests.cs index 50f6179e..edfc6343 100644 --- a/CSharpInteractive.Tests/BuildResultTests.cs +++ b/CSharpInteractive.Tests/BuildResultTests.cs @@ -1,8 +1,5 @@ namespace CSharpInteractive.Tests; -using Core; -using HostApi; - public class BuildResultTests { private static readonly Output Output = new(Mock.Of(), false, "", 99); diff --git a/CSharpInteractive.Tests/BuildRunnerTests.cs b/CSharpInteractive.Tests/BuildRunnerTests.cs index ab7da6ee..a6cf3a42 100644 --- a/CSharpInteractive.Tests/BuildRunnerTests.cs +++ b/CSharpInteractive.Tests/BuildRunnerTests.cs @@ -1,7 +1,5 @@ namespace CSharpInteractive.Tests; -using Core; -using HostApi; using BuildResult = Core.BuildResult; public class BuildRunnerTests diff --git a/CSharpInteractive.Tests/CISettingsTests.cs b/CSharpInteractive.Tests/CISettingsTests.cs index 0556eefa..466d41fa 100644 --- a/CSharpInteractive.Tests/CISettingsTests.cs +++ b/CSharpInteractive.Tests/CISettingsTests.cs @@ -2,8 +2,6 @@ namespace CSharpInteractive.Tests; -using Core; - public class CISettingsTests { private readonly Mock _hostEnvironment = new(); diff --git a/CSharpInteractive.Tests/CISpecificTests.cs b/CSharpInteractive.Tests/CISpecificTests.cs index 1c7f5a53..a7e6db18 100644 --- a/CSharpInteractive.Tests/CISpecificTests.cs +++ b/CSharpInteractive.Tests/CISpecificTests.cs @@ -2,8 +2,6 @@ namespace CSharpInteractive.Tests; -using Core; - public class CISpecificTests { private readonly Mock _settings = new(); diff --git a/CSharpInteractive.Tests/CSharpInteractive.Tests.csproj b/CSharpInteractive.Tests/CSharpInteractive.Tests.csproj index 21157de1..5b48fa2b 100644 --- a/CSharpInteractive.Tests/CSharpInteractive.Tests.csproj +++ b/CSharpInteractive.Tests/CSharpInteractive.Tests.csproj @@ -16,7 +16,7 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/CSharpInteractive.Tests/CSharpScriptCommandRunnerTests.cs b/CSharpInteractive.Tests/CSharpScriptCommandRunnerTests.cs index 9fa28b41..0a4360e9 100644 --- a/CSharpInteractive.Tests/CSharpScriptCommandRunnerTests.cs +++ b/CSharpInteractive.Tests/CSharpScriptCommandRunnerTests.cs @@ -1,7 +1,5 @@ namespace CSharpInteractive.Tests; -using Core; - public class CSharpScriptCommandRunnerTests { private readonly Mock _csharpScriptRunner = new(); diff --git a/CSharpInteractive.Tests/CleanerTests.cs b/CSharpInteractive.Tests/CleanerTests.cs index 13bda087..c4a16e75 100644 --- a/CSharpInteractive.Tests/CleanerTests.cs +++ b/CSharpInteractive.Tests/CleanerTests.cs @@ -1,7 +1,5 @@ namespace CSharpInteractive.Tests; -using Core; - public class CleanerTests { [Fact] diff --git a/CSharpInteractive.Tests/CodeSourceCommandFactoryTests.cs b/CSharpInteractive.Tests/CodeSourceCommandFactoryTests.cs index 8095a045..ffba44d7 100644 --- a/CSharpInteractive.Tests/CodeSourceCommandFactoryTests.cs +++ b/CSharpInteractive.Tests/CodeSourceCommandFactoryTests.cs @@ -2,7 +2,7 @@ namespace CSharpInteractive.Tests; using System.Diagnostics.CodeAnalysis; using Core; -using Environment = Environment; +using Environment = System.Environment; [SuppressMessage("Performance", "CA1861:Avoid constant arrays as arguments")] [SuppressMessage("ReSharper", "GenericEnumeratorNotDisposed")] diff --git a/CSharpInteractive.Tests/CommandLineParserTests.cs b/CSharpInteractive.Tests/CommandLineParserTests.cs index c6f579ea..81d047a8 100644 --- a/CSharpInteractive.Tests/CommandLineParserTests.cs +++ b/CSharpInteractive.Tests/CommandLineParserTests.cs @@ -1,7 +1,6 @@ namespace CSharpInteractive.Tests; using System.Diagnostics.CodeAnalysis; -using Core; [SuppressMessage("Performance", "CA1861:Avoid constant arrays as arguments")] [SuppressMessage("Usage", "xUnit1042:The member referenced by the MemberData attribute returns untyped data rows")] diff --git a/CSharpInteractive.Tests/CommandLineRunnerTests.cs b/CSharpInteractive.Tests/CommandLineRunnerTests.cs index 461b94ff..0081522c 100644 --- a/CSharpInteractive.Tests/CommandLineRunnerTests.cs +++ b/CSharpInteractive.Tests/CommandLineRunnerTests.cs @@ -1,8 +1,5 @@ namespace CSharpInteractive.Tests; -using Core; -using HostApi; - public class CommandLineRunnerTests { private readonly Mock _host = new(); diff --git a/CSharpInteractive.Tests/CommandSourceTests.cs b/CSharpInteractive.Tests/CommandSourceTests.cs index 70bf5e0d..979f1f5b 100644 --- a/CSharpInteractive.Tests/CommandSourceTests.cs +++ b/CSharpInteractive.Tests/CommandSourceTests.cs @@ -1,7 +1,5 @@ namespace CSharpInteractive.Tests; -using Core; - public class CommandSourceTests { [Fact] diff --git a/CSharpInteractive.Tests/CommandsRunnerTests.cs b/CSharpInteractive.Tests/CommandsRunnerTests.cs index 4a7455b0..96c071e8 100644 --- a/CSharpInteractive.Tests/CommandsRunnerTests.cs +++ b/CSharpInteractive.Tests/CommandsRunnerTests.cs @@ -1,7 +1,6 @@ namespace CSharpInteractive.Tests; using System.Diagnostics.CodeAnalysis; -using Core; [SuppressMessage("Usage", "xUnit1042:The member referenced by the MemberData attribute returns untyped data rows")] public class CommandsRunnerTests diff --git a/CSharpInteractive.Tests/ConfigurableScriptOptionsFactoryTests.cs b/CSharpInteractive.Tests/ConfigurableScriptOptionsFactoryTests.cs index cdf42b84..cefcce78 100644 --- a/CSharpInteractive.Tests/ConfigurableScriptOptionsFactoryTests.cs +++ b/CSharpInteractive.Tests/ConfigurableScriptOptionsFactoryTests.cs @@ -1,6 +1,5 @@ namespace CSharpInteractive.Tests; -using Core; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.Scripting; diff --git a/CSharpInteractive.Tests/CustomMessagesProcessorTests.cs b/CSharpInteractive.Tests/CustomMessagesProcessorTests.cs index 89b70cde..df6cb851 100644 --- a/CSharpInteractive.Tests/CustomMessagesProcessorTests.cs +++ b/CSharpInteractive.Tests/CustomMessagesProcessorTests.cs @@ -1,8 +1,5 @@ namespace CSharpInteractive.Tests; -using Core; -using HostApi; - public class CustomMessagesProcessorTests { private static readonly ProcessInfo ProcessInfo = new(Mock.Of(), Mock.Of(), 1); diff --git a/CSharpInteractive.Tests/DefaultBuildMessagesProcessorTests.cs b/CSharpInteractive.Tests/DefaultBuildMessagesProcessorTests.cs index 705ae063..e5d30189 100644 --- a/CSharpInteractive.Tests/DefaultBuildMessagesProcessorTests.cs +++ b/CSharpInteractive.Tests/DefaultBuildMessagesProcessorTests.cs @@ -1,7 +1,5 @@ namespace CSharpInteractive.Tests; -using Core; -using HostApi; using JetBrains.TeamCity.ServiceMessages; public class DefaultBuildMessagesProcessorTests diff --git a/CSharpInteractive.Tests/DockerEnvironmentTests.cs b/CSharpInteractive.Tests/DockerEnvironmentTests.cs index c4275ed8..ed4cfc0d 100644 --- a/CSharpInteractive.Tests/DockerEnvironmentTests.cs +++ b/CSharpInteractive.Tests/DockerEnvironmentTests.cs @@ -2,7 +2,6 @@ namespace CSharpInteractive.Tests; using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; -using Core; [SuppressMessage("Performance", "CA1861:Avoid constant arrays as arguments")] public class DockerEnvironmentTests diff --git a/CSharpInteractive.Tests/DockerSettingsTests.cs b/CSharpInteractive.Tests/DockerSettingsTests.cs index fe70fcc4..716603f9 100644 --- a/CSharpInteractive.Tests/DockerSettingsTests.cs +++ b/CSharpInteractive.Tests/DockerSettingsTests.cs @@ -1,7 +1,5 @@ namespace CSharpInteractive.Tests; -using Core; - public class DockerSettingsTests { private readonly Mock _dockerEnvironment = new(); diff --git a/CSharpInteractive.Tests/DotnetEnvironmentTests.cs b/CSharpInteractive.Tests/DotnetEnvironmentTests.cs index 4b0dc1b7..92af5f51 100644 --- a/CSharpInteractive.Tests/DotnetEnvironmentTests.cs +++ b/CSharpInteractive.Tests/DotnetEnvironmentTests.cs @@ -2,7 +2,6 @@ namespace CSharpInteractive.Tests; using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; -using Core; [SuppressMessage("Performance", "CA1861:Avoid constant arrays as arguments")] public class DotNetEnvironmentTests diff --git a/CSharpInteractive.Tests/ExitCodeParserTests.cs b/CSharpInteractive.Tests/ExitCodeParserTests.cs index 3c485038..20eecde2 100644 --- a/CSharpInteractive.Tests/ExitCodeParserTests.cs +++ b/CSharpInteractive.Tests/ExitCodeParserTests.cs @@ -1,7 +1,5 @@ namespace CSharpInteractive.Tests; -using Core; - public class ExitCodeParserTests { [Theory] diff --git a/CSharpInteractive.Tests/FileExplorerTests.cs b/CSharpInteractive.Tests/FileExplorerTests.cs index 2bdc0235..249672e6 100644 --- a/CSharpInteractive.Tests/FileExplorerTests.cs +++ b/CSharpInteractive.Tests/FileExplorerTests.cs @@ -2,7 +2,6 @@ namespace CSharpInteractive.Tests; using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; -using Core; [SuppressMessage("Performance", "CA1861:Avoid constant arrays as arguments")] [SuppressMessage("Usage", "xUnit1042:The member referenced by the MemberData attribute returns untyped data rows")] diff --git a/CSharpInteractive.Tests/FilePathResolverTests.cs b/CSharpInteractive.Tests/FilePathResolverTests.cs index 9dc8b2fb..51dda611 100644 --- a/CSharpInteractive.Tests/FilePathResolverTests.cs +++ b/CSharpInteractive.Tests/FilePathResolverTests.cs @@ -1,7 +1,5 @@ namespace CSharpInteractive.Tests; -using Core; - public class FilePathResolverTests { private readonly Mock> _log; diff --git a/CSharpInteractive.Tests/FlowIdGeneratorTests.cs b/CSharpInteractive.Tests/FlowIdGeneratorTests.cs index 2b5e9e63..8b7d1d12 100644 --- a/CSharpInteractive.Tests/FlowIdGeneratorTests.cs +++ b/CSharpInteractive.Tests/FlowIdGeneratorTests.cs @@ -1,7 +1,5 @@ namespace CSharpInteractive.Tests; -using Core; - public class FlowIdGeneratorTests { private readonly Mock _teamCitySettings = new(); diff --git a/CSharpInteractive.Tests/GlobalUsings.cs b/CSharpInteractive.Tests/GlobalUsings.cs index 7a9302be..ce605aff 100644 --- a/CSharpInteractive.Tests/GlobalUsings.cs +++ b/CSharpInteractive.Tests/GlobalUsings.cs @@ -7,6 +7,9 @@ global using System.Net.Http; global using System.Threading; global using System.Threading.Tasks; +global using CSharpInteractive.Core; +global using HostApi; global using Moq; global using Shouldly; -global using Xunit; \ No newline at end of file +global using Xunit; +global using Xunit.Abstractions; \ No newline at end of file diff --git a/CSharpInteractive.Tests/HelpCommandParserTests.cs b/CSharpInteractive.Tests/HelpCommandParserTests.cs index e994ade0..8cd54908 100644 --- a/CSharpInteractive.Tests/HelpCommandParserTests.cs +++ b/CSharpInteractive.Tests/HelpCommandParserTests.cs @@ -1,7 +1,6 @@ namespace CSharpInteractive.Tests; using System.Diagnostics.CodeAnalysis; -using Core; [SuppressMessage("Usage", "xUnit1042:The member referenced by the MemberData attribute returns untyped data rows")] public class HelpCommandParserTests diff --git a/CSharpInteractive.Tests/HelpCommandRunnerTests.cs b/CSharpInteractive.Tests/HelpCommandRunnerTests.cs index 70399d5b..030c9256 100644 --- a/CSharpInteractive.Tests/HelpCommandRunnerTests.cs +++ b/CSharpInteractive.Tests/HelpCommandRunnerTests.cs @@ -1,7 +1,5 @@ namespace CSharpInteractive.Tests; -using Core; - public class HelpCommandRunnerTests { [Fact] diff --git a/CSharpInteractive.Tests/HostServiceTests.cs b/CSharpInteractive.Tests/HostServiceTests.cs index b87fad9d..192731d0 100644 --- a/CSharpInteractive.Tests/HostServiceTests.cs +++ b/CSharpInteractive.Tests/HostServiceTests.cs @@ -1,8 +1,6 @@ namespace CSharpInteractive.Tests; -using Core; using CSharpInteractive; -using HostApi; public class HostServiceTests { diff --git a/CSharpInteractive.Tests/ImportsOptionsFactoryTests.cs b/CSharpInteractive.Tests/ImportsOptionsFactoryTests.cs index c099d74a..4b9b21cb 100644 --- a/CSharpInteractive.Tests/ImportsOptionsFactoryTests.cs +++ b/CSharpInteractive.Tests/ImportsOptionsFactoryTests.cs @@ -1,6 +1,5 @@ namespace CSharpInteractive.Tests; -using Core; using Microsoft.CodeAnalysis.Scripting; public class ImportsOptionsFactoryTests diff --git a/CSharpInteractive.Tests/Integration/BuildTests.cs b/CSharpInteractive.Tests/Integration/BuildTests.cs index d59272d5..b70b445e 100644 --- a/CSharpInteractive.Tests/Integration/BuildTests.cs +++ b/CSharpInteractive.Tests/Integration/BuildTests.cs @@ -1,7 +1,7 @@ namespace CSharpInteractive.Tests.Integration; [CollectionDefinition("Integration", DisableParallelization = true)] -[Trait("Integration", "true")] +[Trait("Integration", "True")] public class BuildTests { [Fact] diff --git a/CSharpInteractive.Tests/Integration/CSharpScriptRunnerTests.cs b/CSharpInteractive.Tests/Integration/CSharpScriptRunnerTests.cs index aee25726..72760491 100644 --- a/CSharpInteractive.Tests/Integration/CSharpScriptRunnerTests.cs +++ b/CSharpInteractive.Tests/Integration/CSharpScriptRunnerTests.cs @@ -1,13 +1,12 @@ namespace CSharpInteractive.Tests.Integration; using System.Diagnostics.CodeAnalysis; -using CSharpInteractive.Core; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Scripting; -using Environment = Environment; +using Environment = System.Environment; [CollectionDefinition("Integration", DisableParallelization = true)] -[Trait("Integration", "true")] +[Trait("Integration", "True")] [SuppressMessage("Usage", "xUnit1042:The member referenced by the MemberData attribute returns untyped data rows")] public class CSharpScriptRunnerTests { diff --git a/CSharpInteractive.Tests/Integration/CommandLineTests.cs b/CSharpInteractive.Tests/Integration/CommandLineTests.cs index ff25837c..5a17adad 100644 --- a/CSharpInteractive.Tests/Integration/CommandLineTests.cs +++ b/CSharpInteractive.Tests/Integration/CommandLineTests.cs @@ -4,11 +4,10 @@ namespace CSharpInteractive.Tests.Integration; using System.Diagnostics; using Core; -using HostApi; using Microsoft.Extensions.DependencyInjection; [CollectionDefinition("Integration", DisableParallelization = true)] -[Trait("Integration", "true")] +[Trait("Integration", "True")] public class CommandLineTests { [Fact] diff --git a/CSharpInteractive.Tests/Integration/Core/DotNetScript.cs b/CSharpInteractive.Tests/Integration/Core/DotNetScript.cs index a9ed1554..b32a659d 100644 --- a/CSharpInteractive.Tests/Integration/Core/DotNetScript.cs +++ b/CSharpInteractive.Tests/Integration/Core/DotNetScript.cs @@ -1,13 +1,11 @@ namespace CSharpInteractive.Tests.Integration.Core; using CSharpInteractive; -using CSharpInteractive.Core; -using HostApi; internal static class DotNetScript { public static CommandLine Create(IEnumerable args, params string[] lines) => - Create("script.csx", default, args, lines); + CreateForScript("script.csx", default, args, lines); public static CommandLine Create(params string[] lines) => Create([], lines); @@ -17,7 +15,7 @@ public static CommandLine Create() => Composition.Shared.Root.DotNetEnvironment.Path, Path.Combine(Path.GetDirectoryName(typeof(DotNetScript).Assembly.Location)!, "dotnet-csi.dll")); - public static CommandLine Create(string scriptName, string? workingDirectory, IEnumerable args, params string[] lines) + public static CommandLine CreateForScript(string scriptName, string? workingDirectory, IEnumerable args, params string[] lines) { workingDirectory ??= GetWorkingDirectory(); var scriptFile = Path.Combine(workingDirectory, scriptName); diff --git a/CSharpInteractive.Tests/Integration/ExitCodeTests.cs b/CSharpInteractive.Tests/Integration/ExitCodeTests.cs index efbb544c..6c88b048 100644 --- a/CSharpInteractive.Tests/Integration/ExitCodeTests.cs +++ b/CSharpInteractive.Tests/Integration/ExitCodeTests.cs @@ -4,7 +4,7 @@ namespace CSharpInteractive.Tests.Integration; [CollectionDefinition("Integration", DisableParallelization = true)] -[Trait("Integration", "true")] +[Trait("Integration", "True")] public class ExitCodeTests { [Fact] diff --git a/CSharpInteractive.Tests/Integration/HelpTests.cs b/CSharpInteractive.Tests/Integration/HelpTests.cs index 0c1893cb..c16db3e4 100644 --- a/CSharpInteractive.Tests/Integration/HelpTests.cs +++ b/CSharpInteractive.Tests/Integration/HelpTests.cs @@ -3,10 +3,9 @@ namespace CSharpInteractive.Tests.Integration; using Core; -using HostApi; [CollectionDefinition("Integration", DisableParallelization = true)] -[Trait("Integration", "true")] +[Trait("Integration", "True")] public class HelpTests { [Theory] diff --git a/CSharpInteractive.Tests/Integration/MsDITests.cs b/CSharpInteractive.Tests/Integration/MsDITests.cs index edc13c3f..10310333 100644 --- a/CSharpInteractive.Tests/Integration/MsDITests.cs +++ b/CSharpInteractive.Tests/Integration/MsDITests.cs @@ -4,7 +4,7 @@ namespace CSharpInteractive.Tests.Integration; [CollectionDefinition("Integration", DisableParallelization = true)] -[Trait("Integration", "true")] +[Trait("Integration", "True")] public class MsDITests { [Fact] diff --git a/CSharpInteractive.Tests/Integration/NuGetTests.cs b/CSharpInteractive.Tests/Integration/NuGetTests.cs index 7777aa8e..282e7c7c 100644 --- a/CSharpInteractive.Tests/Integration/NuGetTests.cs +++ b/CSharpInteractive.Tests/Integration/NuGetTests.cs @@ -4,11 +4,10 @@ namespace CSharpInteractive.Tests.Integration; using CSharpInteractive; -using HostApi; using NuGet.Versioning; [CollectionDefinition("Integration", DisableParallelization = true)] -[Trait("Integration", "true")] +[Trait("Integration", "True")] public class NuGetTests { [Fact] diff --git a/CSharpInteractive.Tests/Integration/ScriptRunTests.cs b/CSharpInteractive.Tests/Integration/ScriptRunTests.cs index 1cd63c0c..42acdba2 100644 --- a/CSharpInteractive.Tests/Integration/ScriptRunTests.cs +++ b/CSharpInteractive.Tests/Integration/ScriptRunTests.cs @@ -5,10 +5,9 @@ namespace CSharpInteractive.Tests.Integration; using System.Diagnostics.CodeAnalysis; using Core; -using HostApi; [CollectionDefinition("Integration", DisableParallelization = true)] -[Trait("Integration", "true")] +[Trait("Integration", "True")] [SuppressMessage("Performance", "CA1861:Avoid constant arrays as arguments")] public class ScriptRunTests { @@ -242,8 +241,8 @@ public void ShouldSupportLoadWhenRelativePath() // Given var workingDirectory = DotNetScript.GetWorkingDirectory(); // ReSharper disable once UnusedVariable - var scriptAbc = DotNetScript.Create("abc.csx", workingDirectory, [], "Console.WriteLine(\"Hello\");"); - var script = DotNetScript.Create("script.csx", workingDirectory, [], "#load \"abc.csx\"").WithVars(TestTool.DefaultVars); + var scriptAbc = DotNetScript.CreateForScript("abc.csx", workingDirectory, [], "Console.WriteLine(\"Hello\");"); + var script = DotNetScript.CreateForScript("script.csx", workingDirectory, [], "#load \"abc.csx\"").WithVars(TestTool.DefaultVars); // When var result = TestTool.Run(script); @@ -261,10 +260,10 @@ public void ShouldSupportLoadMultiple() // Given var workingDirectory = DotNetScript.GetWorkingDirectory(); // ReSharper disable once UnusedVariable - var scriptClass1 = DotNetScript.Create("class1.csx", workingDirectory, [], "class Class1 { public Class1(Class2 val) {}};"); + var scriptClass1 = DotNetScript.CreateForScript("class1.csx", workingDirectory, [], "class Class1 { public Class1(Class2 val) {}};"); // ReSharper disable once UnusedVariable - var scriptClass2 = DotNetScript.Create("class2.csx", workingDirectory, [], "class Class2 {};"); - var script = DotNetScript.Create("script.csx", workingDirectory, [], "#load \"class2.csx\"", "#load \"class1.csx\"").WithVars(TestTool.DefaultVars); + var scriptClass2 = DotNetScript.CreateForScript("class2.csx", workingDirectory, [], "class Class2 {};"); + var script = DotNetScript.CreateForScript("script.csx", workingDirectory, [], "#load \"class2.csx\"", "#load \"class1.csx\"").WithVars(TestTool.DefaultVars); // When var result = TestTool.Run(script); @@ -280,10 +279,10 @@ public void ShouldSupportLoadMultiple2() // Given var workingDirectory = DotNetScript.GetWorkingDirectory(); // ReSharper disable once UnusedVariable - var scriptClass1 = DotNetScript.Create("class1.csx", workingDirectory, [], "class Class1 { public Class1(Class2 val) {}};"); + var scriptClass1 = DotNetScript.CreateForScript("class1.csx", workingDirectory, [], "class Class1 { public Class1(Class2 val) {}};"); // ReSharper disable once UnusedVariable - var scriptClass2 = DotNetScript.Create("class2.csx", workingDirectory, [], "class Class2 {};"); - var script = DotNetScript.Create("script.csx", workingDirectory, [], "// #load \"class1.csx\"", "#load \"class2.csx\"").WithVars(TestTool.DefaultVars); + var scriptClass2 = DotNetScript.CreateForScript("class2.csx", workingDirectory, [], "class Class2 {};"); + var script = DotNetScript.CreateForScript("script.csx", workingDirectory, [], "// #load \"class1.csx\"", "#load \"class2.csx\"").WithVars(TestTool.DefaultVars); // When var result = TestTool.Run(script); @@ -448,8 +447,8 @@ public void ShouldSupportCallerFilePathWhenLoad() // Given var workingDirectory = DotNetScript.GetWorkingDirectory(); // ReSharper disable once UnusedVariable - var scriptAbc = DotNetScript.Create("abc.csx", workingDirectory, [], "Console.WriteLine(GetCurrentFileName());", "string GetCurrentFileName([System.Runtime.CompilerServices.CallerFilePath] string fileName = null) => fileName;"); - var script = DotNetScript.Create("script.csx", workingDirectory, [], "#load \"abc.csx\"", "Console.WriteLine(GetCurrentFileName());").WithVars(TestTool.DefaultVars); + var scriptAbc = DotNetScript.CreateForScript("abc.csx", workingDirectory, [], "Console.WriteLine(GetCurrentFileName());", "string GetCurrentFileName([System.Runtime.CompilerServices.CallerFilePath] string fileName = null) => fileName;"); + var script = DotNetScript.CreateForScript("script.csx", workingDirectory, [], "#load \"abc.csx\"", "Console.WriteLine(GetCurrentFileName());").WithVars(TestTool.DefaultVars); // When var result = TestTool.Run(script); diff --git a/CSharpInteractive.Tests/Integration/SummaryTests.cs b/CSharpInteractive.Tests/Integration/SummaryTests.cs index 1b6455ae..5bb668d4 100644 --- a/CSharpInteractive.Tests/Integration/SummaryTests.cs +++ b/CSharpInteractive.Tests/Integration/SummaryTests.cs @@ -4,7 +4,7 @@ namespace CSharpInteractive.Tests.Integration; [CollectionDefinition("Integration", DisableParallelization = true)] -[Trait("Integration", "true")] +[Trait("Integration", "True")] public class SummaryTests { [Fact] diff --git a/CSharpInteractive.Tests/Integration/TeamCityScriptRunTests.cs b/CSharpInteractive.Tests/Integration/TeamCityScriptRunTests.cs index a1d2c519..e1db85c8 100644 --- a/CSharpInteractive.Tests/Integration/TeamCityScriptRunTests.cs +++ b/CSharpInteractive.Tests/Integration/TeamCityScriptRunTests.cs @@ -1,7 +1,7 @@ namespace CSharpInteractive.Tests.Integration; [CollectionDefinition("Integration", DisableParallelization = true)] -[Trait("Integration", "true")] +[Trait("Integration", "True")] public class ScriptRunTeamCityScriptRunTests { private const int InitialMessagesCount = 3; diff --git a/CSharpInteractive.Tests/Integration/TestTool.cs b/CSharpInteractive.Tests/Integration/TestTool.cs index c2de1f90..def9a64e 100644 --- a/CSharpInteractive.Tests/Integration/TestTool.cs +++ b/CSharpInteractive.Tests/Integration/TestTool.cs @@ -2,7 +2,6 @@ namespace CSharpInteractive.Tests.Integration; using System.Text; using Core; -using HostApi; using JetBrains.TeamCity.ServiceMessages; internal static class TestTool diff --git a/CSharpInteractive.Tests/LineCodeSourceTests.cs b/CSharpInteractive.Tests/LineCodeSourceTests.cs index 709e0177..eda8b8e3 100644 --- a/CSharpInteractive.Tests/LineCodeSourceTests.cs +++ b/CSharpInteractive.Tests/LineCodeSourceTests.cs @@ -1,7 +1,5 @@ namespace CSharpInteractive.Tests; -using Core; - public class LineCodeSourceTests { [Fact] diff --git a/CSharpInteractive.Tests/LoadFileCodeSourceTests.cs b/CSharpInteractive.Tests/LoadFileCodeSourceTests.cs index 272571a1..f6993cfa 100644 --- a/CSharpInteractive.Tests/LoadFileCodeSourceTests.cs +++ b/CSharpInteractive.Tests/LoadFileCodeSourceTests.cs @@ -1,7 +1,5 @@ namespace CSharpInteractive.Tests; -using Core; - public class LoadFileCodeSourceTests { private readonly Mock _filePathResolver = new(); diff --git a/CSharpInteractive.Tests/MSBuildArgumentsToolTests.cs b/CSharpInteractive.Tests/MSBuildArgumentsToolTests.cs index 23aceba4..3f1f9fa4 100644 --- a/CSharpInteractive.Tests/MSBuildArgumentsToolTests.cs +++ b/CSharpInteractive.Tests/MSBuildArgumentsToolTests.cs @@ -2,8 +2,6 @@ namespace CSharpInteractive.Tests; -using Core; - public class MSBuildArgumentsToolTests { [Theory] diff --git a/CSharpInteractive.Tests/MessagesReaderTests.cs b/CSharpInteractive.Tests/MessagesReaderTests.cs index 0b9fb9c5..051cebbb 100644 --- a/CSharpInteractive.Tests/MessagesReaderTests.cs +++ b/CSharpInteractive.Tests/MessagesReaderTests.cs @@ -2,7 +2,6 @@ namespace CSharpInteractive.Tests; using System.Buffers; using System.Diagnostics.CodeAnalysis; -using Core; using JetBrains.TeamCity.ServiceMessages.Read; using JetBrains.TeamCity.ServiceMessages.Write; diff --git a/CSharpInteractive.Tests/MetadataResolverOptionsFactoryTests.cs b/CSharpInteractive.Tests/MetadataResolverOptionsFactoryTests.cs index b5ca4feb..e9f6d0b5 100644 --- a/CSharpInteractive.Tests/MetadataResolverOptionsFactoryTests.cs +++ b/CSharpInteractive.Tests/MetadataResolverOptionsFactoryTests.cs @@ -1,6 +1,5 @@ namespace CSharpInteractive.Tests; -using Core; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Scripting; diff --git a/CSharpInteractive.Tests/MetadataResolverTests.cs b/CSharpInteractive.Tests/MetadataResolverTests.cs index 19ee5956..46ef09ca 100644 --- a/CSharpInteractive.Tests/MetadataResolverTests.cs +++ b/CSharpInteractive.Tests/MetadataResolverTests.cs @@ -1,7 +1,6 @@ namespace CSharpInteractive.Tests; using System.Collections.Immutable; -using Core; using Microsoft.CodeAnalysis; public class MetadataResolverTests diff --git a/CSharpInteractive.Tests/NuGetReferenceResolverTests.cs b/CSharpInteractive.Tests/NuGetReferenceResolverTests.cs index a130d1a3..c5e94a95 100644 --- a/CSharpInteractive.Tests/NuGetReferenceResolverTests.cs +++ b/CSharpInteractive.Tests/NuGetReferenceResolverTests.cs @@ -1,7 +1,5 @@ namespace CSharpInteractive.Tests; -using Core; -using HostApi; using NuGet.Versioning; public class NuGetReferenceResolverTests diff --git a/CSharpInteractive.Tests/NuGetServiceTests.cs b/CSharpInteractive.Tests/NuGetServiceTests.cs index 3ea11ef5..0dc170fa 100644 --- a/CSharpInteractive.Tests/NuGetServiceTests.cs +++ b/CSharpInteractive.Tests/NuGetServiceTests.cs @@ -1,8 +1,6 @@ namespace CSharpInteractive.Tests; using System.Diagnostics.CodeAnalysis; -using Core; -using HostApi; using NuGet.Versioning; [SuppressMessage("Usage", "xUnit1042:The member referenced by the MemberData attribute returns untyped data rows")] diff --git a/CSharpInteractive.Tests/PathResolverContextTests.cs b/CSharpInteractive.Tests/PathResolverContextTests.cs index 238862e0..f2a57eed 100644 --- a/CSharpInteractive.Tests/PathResolverContextTests.cs +++ b/CSharpInteractive.Tests/PathResolverContextTests.cs @@ -1,7 +1,5 @@ namespace CSharpInteractive.Tests; -using Core; -using HostApi; using HostApi.Internal.Cmd; public class PathResolverContextTests diff --git a/CSharpInteractive.Tests/ProcessInFlowRunnerTests.cs b/CSharpInteractive.Tests/ProcessInFlowRunnerTests.cs index fa00b12d..f59bcee4 100644 --- a/CSharpInteractive.Tests/ProcessInFlowRunnerTests.cs +++ b/CSharpInteractive.Tests/ProcessInFlowRunnerTests.cs @@ -1,7 +1,5 @@ namespace CSharpInteractive.Tests; -using Core; -using HostApi; using JetBrains.TeamCity.ServiceMessages.Write.Special; public class ProcessInFlowRunnerTests diff --git a/CSharpInteractive.Tests/ProcessMonitorTests.cs b/CSharpInteractive.Tests/ProcessMonitorTests.cs index 560d5368..1cfd5a7b 100644 --- a/CSharpInteractive.Tests/ProcessMonitorTests.cs +++ b/CSharpInteractive.Tests/ProcessMonitorTests.cs @@ -1,8 +1,6 @@ namespace CSharpInteractive.Tests; using System.Diagnostics.CodeAnalysis; -using Core; -using HostApi; [SuppressMessage("Performance", "CA1861:Avoid constant arrays as arguments")] public class ProcessMonitorTests diff --git a/CSharpInteractive.Tests/ProcessOutputWriterTests.cs b/CSharpInteractive.Tests/ProcessOutputWriterTests.cs index 68241f9c..58871cac 100644 --- a/CSharpInteractive.Tests/ProcessOutputWriterTests.cs +++ b/CSharpInteractive.Tests/ProcessOutputWriterTests.cs @@ -2,8 +2,7 @@ namespace CSharpInteractive.Tests; using System; using Core; -using HostApi; -using Environment = Environment; +using Environment = System.Environment; public class ProcessOutputWriterTests { diff --git a/CSharpInteractive.Tests/ProcessResultHandlerTests.cs b/CSharpInteractive.Tests/ProcessResultHandlerTests.cs index 4d4c0ad6..f5eb33a9 100644 --- a/CSharpInteractive.Tests/ProcessResultHandlerTests.cs +++ b/CSharpInteractive.Tests/ProcessResultHandlerTests.cs @@ -1,8 +1,5 @@ namespace CSharpInteractive.Tests; -using Core; -using HostApi; - public class ProcessResultHandlerTests { private readonly Mock> _log = new(); diff --git a/CSharpInteractive.Tests/ProcessRunnerTests.cs b/CSharpInteractive.Tests/ProcessRunnerTests.cs index 42a55f24..fde2e513 100644 --- a/CSharpInteractive.Tests/ProcessRunnerTests.cs +++ b/CSharpInteractive.Tests/ProcessRunnerTests.cs @@ -1,8 +1,5 @@ namespace CSharpInteractive.Tests; -using Core; -using HostApi; - public sealed class ProcessRunnerTests : IDisposable { private readonly Mock _processManager = new(); diff --git a/CSharpInteractive.Tests/ProgramTests.cs b/CSharpInteractive.Tests/ProgramTests.cs index aca0ed68..cee41967 100644 --- a/CSharpInteractive.Tests/ProgramTests.cs +++ b/CSharpInteractive.Tests/ProgramTests.cs @@ -1,7 +1,6 @@ namespace CSharpInteractive.Tests; using System.Diagnostics.CodeAnalysis; -using Core; using CSharpInteractive; [SuppressMessage("Performance", "CA1861:Avoid constant arrays as arguments")] diff --git a/CSharpInteractive.Tests/PropertiesTests.cs b/CSharpInteractive.Tests/PropertiesTests.cs index f4e7090e..9a3f2b69 100644 --- a/CSharpInteractive.Tests/PropertiesTests.cs +++ b/CSharpInteractive.Tests/PropertiesTests.cs @@ -1,7 +1,5 @@ namespace CSharpInteractive.Tests; -using Core; - public class PropertiesTests { private readonly Mock> _log; @@ -110,7 +108,7 @@ public void ShouldEnumeratePairs() // When // Then - props.ShouldBe([ + props.ToArray().ShouldBe([ new KeyValuePair("Abc", "Xyz"), new KeyValuePair("1", "2") ]); diff --git a/CSharpInteractive.Tests/README_TEMPLATE.md b/CSharpInteractive.Tests/README_TEMPLATE.md index e3f72789..bf076b48 100644 --- a/CSharpInteractive.Tests/README_TEMPLATE.md +++ b/CSharpInteractive.Tests/README_TEMPLATE.md @@ -31,19 +31,75 @@ - [Build a project in a docker container](#build-a-project-in-a-docker-container) - [Running in docker](#running-in-docker) - .NET CLI + - [Adding a NuGet package](#adding-a-nuget-package) + - [Adding a NuGet package](#adding-a-nuget-package) + - [Adding a NuGet source](#adding-a-nuget-source) + - [Adding a project reference](#adding-a-project-reference) + - [Adding projects to the solution file](#adding-projects-to-the-solution-file) + - [Adding projects to the solution file](#adding-projects-to-the-solution-file) - [Build a project](#build-a-project) - [Build a project using MSBuild](#build-a-project-using-msbuild) - [Clean a project](#clean-a-project) - - [Pack a project](#pack-a-project) - - [Publish a project](#publish-a-project) - - [Restore a project](#restore-a-project) - - [Restore local tools](#restore-local-tools) + - [Clearing the specified NuGet cache type](#clearing-the-specified-nuget-cache-type) + - [Creating a new project from template](#creating-a-new-project-from-template) + - [Deleting a NuGet package to the server](#deleting-a-nuget-package-to-the-server) + - [Disabling a NuGet source](#disabling-a-nuget-source) + - [Display template package metadata](#display-template-package-metadata) + - [Enabling a NuGet source](#enabling-a-nuget-source) + - [Enabling or disabling workload-set update mode](#enabling-or-disabling-workload-set-update-mode) + - [Execute a dotnet application](#execute-a-dotnet-application) + - [Fix (non code style) analyzer issues](#fix-(non-code-style)-analyzer-issues) + - [Fix code style issues](#fix-code-style-issues) + - [Format a code](#format-a-code) + - [Gets the value of a specified NuGet configuration setting](#gets-the-value-of-a-specified-nuget-configuration-setting) + - [Installing a template package](#installing-a-template-package) + - [Installing optional workloads](#installing-optional-workloads) + - [Installing the .NET local tools that are in scope for the current directory](#installing-the-.net-local-tools-that-are-in-scope-for-the-current-directory) + - [Installing the specified .NET tool](#installing-the-specified-.net-tool) + - [Installing the specified .NET tool](#installing-the-specified-.net-tool) + - [Installing workloads needed for a project or a solution](#installing-workloads-needed-for-a-project-or-a-solution) + - [Invoking a local tool](#invoking-a-local-tool) + - [List available templates](#list-available-templates) + - [NuGet package listing](#nuget-package-listing) + - [Packing the code into a NuGet package](#packing-the-code-into-a-nuget-package) + - [Printing all .NET tools of the specified type currently installed](#printing-all-.net-tools-of-the-specified-type-currently-installed) + - [Printing all configured NuGet sources](#printing-all-configured-nuget-sources) + - [Printing all projects in a solution file](#printing-all-projects-in-a-solution-file) + - [Printing installed workloads](#printing-installed-workloads) + - [Printing nuget configuration files currently being applied to a directory](#printing-nuget-configuration-files-currently-being-applied-to-a-directory) + - [Printing the latest available version of the .NET SDK and .NET Runtime, for each feature band](#printing-the-latest-available-version-of-the-.net-sdk-and-.net-runtime,-for-each-feature-band) + - [Printing the location of the specified NuGet cache type](#printing-the-location-of-the-specified-nuget-cache-type) + - [Project reference listing](#project-reference-listing) + - [Publishing the application and its dependencies to a folder for deployment to a hosting system](#publishing-the-application-and-its-dependencies-to-a-folder-for-deployment-to-a-hosting-system) + - [Pushing a NuGet package to the server](#pushing-a-nuget-package-to-the-server) + - [Removing a NuGet package](#removing-a-nuget-package) + - [Removing a NuGet source.](#removing-a-nuget-source.) + - [Repairing workloads installations](#repairing-workloads-installations) + - [Restoring the dependencies and tools of a project](#restoring-the-dependencies-and-tools-of-a-project) - [Run a custom .NET command](#run-a-custom-.net-command) - - [Run a project](#run-a-project) + - [Run a dotnet application](#run-a-dotnet-application) - [Run tests under dotCover](#run-tests-under-dotcover) + - [Running source code without any explicit compile or launch commands](#running-source-code-without-any-explicit-compile-or-launch-commands) + - [Running tests from the specified assemblies](#running-tests-from-the-specified-assemblies) + - [Searche for the templates](#searche-for-the-templates) + - [Searching all .NET tools that are published to NuGet](#searching-all-.net-tools-that-are-published-to-nuget) + - [Searching for a NuGet package](#searching-for-a-nuget-package) + - [Searching for optional workloads](#searching-for-optional-workloads) + - [Sets the value of a specified NuGet configuration setting](#sets-the-value-of-a-specified-nuget-configuration-setting) + - [Show the dependency graph for NuGet package](#show-the-dependency-graph-for-nuget-package) + - [Signing with certificate](#signing-with-certificate) + - [Storing the specified assemblies in the runtime package store.](#storing-the-specified-assemblies-in-the-runtime-package-store.) - [Test a project](#test-a-project) - [Test a project using the MSBuild VSTest target](#test-a-project-using-the-msbuild-vstest-target) - - [Test an assembly](#test-an-assembly) + - [Uninstalling a specified workload](#uninstalling-a-specified-workload) + - [Uninstalling a template package](#uninstalling-a-template-package) + - [Uninstalling the specified .NET tool](#uninstalling-the-specified-.net-tool) + - [Unsets the value of a specified NuGet configuration setting](#unsets-the-value-of-a-specified-nuget-configuration-setting) + - [Updating a NuGet source](#updating-a-nuget-source) + - [Updating installed template packages](#updating-installed-template-packages) + - [Updating installed workloads](#updating-installed-workloads) + - [Working with development certificates](#working-with-development-certificates) + - [Run C# script](#run-c#-script) - [Shuts down build servers](#shuts-down-build-servers) - TeamCity API - [TeamCity integration via service messages](#teamcity-integration-via-service-messages) @@ -209,7 +265,6 @@ private class MyTask(ICommandLineRunner runner) ``` CSharp -// Adds the namespace "HostApi" to use INuGet using HostApi; IEnumerable packages = GetService() @@ -223,7 +278,6 @@ IEnumerable packages = GetService() ``` CSharp -// Adds the namespace "HostApi" to use INuGet using HostApi; var packagesPath = Path.Combine( @@ -245,7 +299,6 @@ IEnumerable packages = GetService().Restore(settings); ``` CSharp -// Adds the namespace "Script.Cmd" to use Command Line API using HostApi; // Creates and run a simple command line @@ -260,20 +313,16 @@ new CommandLine("cmd", "/c", "echo", "Hello").Run(); // Same as previous statement new CommandLine("cmd", "/c") .AddArgs("echo", "Hello") - .Run() - .EnsureSuccess(); + .Run().EnsureSuccess(); (new CommandLine("cmd") + "/c" + "echo" + "Hello") - .Run() - .EnsureSuccess(); + .Run().EnsureSuccess(); "cmd".AsCommandLine("/c", "echo", "Hello") - .Run() - .EnsureSuccess(); + .Run().EnsureSuccess(); ("cmd".AsCommandLine() + "/c" + "echo" + "Hello") - .Run() - .EnsureSuccess(); + .Run().EnsureSuccess(); // Just builds a command line with multiple environment variables var cmd = new CommandLine("cmd", "/c", "echo", "Hello") @@ -298,17 +347,14 @@ cmd = new CommandLine("cmd", "/c", "echo", "Hello") ``` CSharp -// Adds the namespace "HostApi" to use Command Line API using HostApi; GetService() - .Run(new CommandLine("cmd", "/c", "DIR")) - .EnsureSuccess(); + .Run(new CommandLine("cmd", "/c", "DIR")).EnsureSuccess(); // or the same thing using the extension method new CommandLine("cmd", "/c", "DIR") - .Run() - .EnsureSuccess(); + .Run().EnsureSuccess(); // using operator '+' var cmd = new CommandLine("cmd") + "/c" + "DIR"; @@ -326,17 +372,14 @@ cmd.Run().EnsureSuccess(); ``` CSharp -// Adds the namespace "HostApi" to use Command Line API using HostApi; await GetService() - .RunAsync(new CommandLine("cmd", "/C", "DIR")) - .EnsureSuccess(); + .RunAsync(new CommandLine("cmd", "/C", "DIR")).EnsureSuccess(); // or the same thing using the extension method var result = await new CommandLine("cmd", "/c", "DIR") - .RunAsync() - .EnsureSuccess(); + .RunAsync().EnsureSuccess(); ``` @@ -346,14 +389,12 @@ var result = await new CommandLine("cmd", "/c", "DIR") ``` CSharp -// Adds the namespace "HostApi" to use Command Line API using HostApi; var lines = new List(); var result = new CommandLine("cmd", "/c", "SET") .AddVars(("MyEnv", "MyVal")) - .Run(output => lines.Add(output.Line)) - .EnsureSuccess(); + .Run(output => lines.Add(output.Line)).EnsureSuccess(); lines.ShouldContain("MyEnv=MyVal"); ``` @@ -365,16 +406,13 @@ lines.ShouldContain("MyEnv=MyVal"); ``` CSharp -// Adds the namespace "HostApi" to use Command Line API using HostApi; var task = new CommandLine("cmd", "/c", "DIR") - .RunAsync() - .EnsureSuccess(); + .RunAsync().EnsureSuccess(); var result = new CommandLine("cmd", "/c", "SET") - .Run() - .EnsureSuccess(); + .Run().EnsureSuccess(); await task; ``` @@ -386,7 +424,6 @@ await task; Cancellation will destroy the process and its child processes. ``` CSharp -// Adds the namespace "HostApi" to use Command Line API using HostApi; var cancellationTokenSource = new CancellationTokenSource(); @@ -404,15 +441,11 @@ task.IsCompleted.ShouldBeFalse(); If timeout expired a process will be killed. ``` CSharp -// Adds the namespace "HostApi" to use Command Line API using HostApi; -int? exitCode = new CommandLine("cmd", "/c", "TIMEOUT", "/T", "120") +var exitCode = new CommandLine("cmd", "/c", "TIMEOUT", "/T", "120") .Run(default, TimeSpan.FromMilliseconds(1)) - .EnsureSuccess() .ExitCode; - -exitCode.HasValue.ShouldBeFalse(); ``` @@ -422,7 +455,6 @@ exitCode.HasValue.ShouldBeFalse(); ``` CSharp -// Adds the namespace "HostApi" to use .NET build API and Docker API using HostApi; // Creates a base docker command line @@ -434,22 +466,15 @@ var dockerRun = new DockerRun() .WithContainerWorkingDirectory("/MyProjects") .AddVolumes((ToAbsoluteLinuxPath(Environment.CurrentDirectory), "/MyProjects")); - // Creates a new library project in a docker container dockerRun .WithCommandLine(new DotNetCustom("new", "classlib", "-n", "MyLib", "--force")) - .Run() - .EnsureSuccess(); + .Run().EnsureSuccess(); // Builds the library project in a docker container var result = dockerRun .WithCommandLine(new DotNetBuild().WithProject("MyLib/MyLib.csproj")) - .Build() - .EnsureSuccess(); - -// The "result" variable provides details about a build -result.Errors.Any(message => message.State == BuildMessageState.StdError).ShouldBeFalse(); -result.ExitCode.ShouldBe(0); + .Build().EnsureSuccess(); string ToAbsoluteLinuxPath(string path) => "/" + path.Replace(":", "").Replace('\\', '/'); @@ -462,7 +487,6 @@ string ToAbsoluteLinuxPath(string path) => ``` CSharp -// Adds the namespace "HostApi" to use Command Line API and Docker API using HostApi; // Creates some command line to run in a docker container @@ -471,79 +495,71 @@ var cmd = new CommandLine("whoami"); // Runs the command line in a docker container var result = new DockerRun(cmd, "mcr.microsoft.com/dotnet/sdk") .WithAutoRemove(true) - .Run() - .EnsureSuccess(); + .Run().EnsureSuccess(); ``` -### Build a project +### Adding a NuGet package ``` CSharp -// Adds the namespace "HostApi" to use .NET build API 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(); - -// Builds the library project, running a command like: "dotnet build" from the directory "MyLib" -var result = new DotNetBuild() +var result = new DotNetAddPackage() .WithWorkingDirectory("MyLib") - .Build() - .EnsureSuccess(); + .WithPackage("Pure.DI") + .Run().EnsureSuccess(); +``` -// The "result" variable provides details about a build -result.Errors.Any(message => message.State == BuildMessageState.StdError).ShouldBeFalse(); -result.ExitCode.ShouldBe(0); -// Runs tests in docker -result = new DotNetTest() - .WithWorkingDirectory("MyLib") - .Build() - .EnsureSuccess(); -result.ExitCode.ShouldBe(0); -result.Summary.Tests.ShouldBe(1); -result.Tests.Count(test => test.State == TestState.Finished).ShouldBe(1); +### Adding a NuGet package + + + +``` CSharp +using HostApi; + +var result = new DotNetAddReference() + .WithProject(Path.Combine("MyTests", "MyTests.csproj")) + .WithReferences(Path.Combine("MyLib", "MyLib.csproj")) + .Run().EnsureSuccess(); + ``` -### Clean a project +### Build a project ``` CSharp -// Adds the namespace "HostApi" to use .NET build API 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 messages = new List(); +var result = new DotNetBuild() + .WithWorkingDirectory("MyTests") + .Build(message => messages.Add(message)).EnsureSuccess(); -result.ExitCode.ShouldBe(0); +result.Errors.Any(message => message.State == BuildMessageState.StdError).ShouldBeFalse(result.ToString()); +result.ExitCode.ShouldBe(0, result.ToString()); +``` -// Builds the library project, running a command like: "dotnet build" from the directory "MyLib" -result = new DotNetBuild() - .WithWorkingDirectory("MyLib") - .Build() - .EnsureSuccess(); -result.ExitCode.ShouldBe(0); + +### Clean a project + + + +``` CSharp +using HostApi; // Clean the project, running a command like: "dotnet clean" from the directory "MyLib" -result = new DotNetClean() +new DotNetClean() .WithWorkingDirectory("MyLib") - .Build() - .EnsureSuccess(); - -// The "result" variable provides details about a build -result.ExitCode.ShouldBe(0); + .Build().EnsureSuccess(); ``` @@ -553,7 +569,6 @@ result.ExitCode.ShouldBe(0); ``` CSharp -// Adds the namespace "HostApi" to use .NET build API using HostApi; // Gets the dotnet version, running a command like: "dotnet --version" @@ -567,344 +582,1131 @@ version.ShouldNotBeNull(); -### Test a project using the MSBuild VSTest target +### Working with development certificates ``` CSharp -// Adds the namespace "HostApi" to use .NET build API 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(); +// Create a certificate, trust it, and export it to a PEM file. +new DotNetDevCertsHttps() + .WithExportPath("certificate.pem") + .WithTrust(true) + .WithFormat(DotNetCertificateFormat.Pem) + .WithPassword("Abc") + .Run().EnsureSuccess(); +``` -result.ExitCode.ShouldBe(0); -// Runs tests via a command like: "dotnet msbuild /t:VSTest" from the directory "MyTests" -result = new MSBuild() - .WithTarget("VSTest") - .WithWorkingDirectory("MyTests") - .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); +### Execute a dotnet application + + + +``` CSharp +using HostApi; +new DotNetExec() + .WithPathToApplication(Path.Combine(path, "MyApp.dll")) + .Run().EnsureSuccess(); ``` -### Pack a project +### Fix (non code style) analyzer issues ``` CSharp -// Adds the namespace "HostApi" to use .NET build API 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(); +new DotNetFormatAnalyzers() + .WithWorkingDirectory("MyLib") + .WithProject("MyLib.csproj") + .AddDiagnostics("CA1831", "CA1832") + .WithSeverity(DotNetFormatSeverity.Warning) + .Run().EnsureSuccess(); +``` -result.ExitCode.ShouldBe(0); -// Creates a NuGet package of version 1.2.3 for the project, running a command like: "dotnet pack /p:version=1.2.3" from the directory "MyLib" -result = new DotNetPack() - .WithWorkingDirectory("MyLib") - .AddProps(("version", "1.2.3")) - .Build() - .EnsureSuccess(); -result.ExitCode.ShouldBe(0); +### Format a code + + + +``` CSharp +using HostApi; + +new DotNetFormat() + .WithWorkingDirectory("MyLib") + .WithProject("MyLib.csproj") + .AddDiagnostics("IDE0005", "IDE0006") + .AddIncludes(".", "./tests") + .AddExcludes("./obj") + .WithSeverity(DotNetFormatSeverity.Information) + .Run().EnsureSuccess(); ``` -### Publish a project +### Fix code style issues ``` CSharp -// Adds the namespace "HostApi" to use .NET build API 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(); +new DotNetFormatStyle() + .WithWorkingDirectory("MyLib") + .WithProject("MyLib.csproj") + .AddDiagnostics("IDE0005", "IDE0006") + .WithSeverity(DotNetFormatSeverity.Information) + .Run().EnsureSuccess(); +``` + + + +### NuGet package listing + + + +``` CSharp +using HostApi; -result.ExitCode.ShouldBe(0); +new DotNetAddPackage() + .WithWorkingDirectory("MyLib") + .WithPackage("Pure.DI") + .Run().EnsureSuccess(); -// Publish the project, running a command like: "dotnet publish --framework net6.0" from the directory "MyLib" -result = new DotNetPublish() +var lines = new List(); +new DotNetListPackage() .WithWorkingDirectory("MyLib") - .WithFramework("net8.0") - .Build() - .EnsureSuccess(); + .WithVerbosity(DotNetVerbosity.Minimal) + .Run(output => lines.Add(output.Line)); -result.ExitCode.ShouldBe(0); +lines.Any(i => i.Contains("Pure.DI")).ShouldBeTrue(); ``` -### Restore a project +### Project reference listing ``` CSharp -// Adds the namespace "HostApi" to use .NET build API 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(); - -result.ExitCode.ShouldBe(0); +new DotNetAddReference() + .WithProject(Path.Combine("MyTests", "MyTests.csproj")) + .WithReferences(Path.Combine("MyLib", "MyLib.csproj")) + .Run().EnsureSuccess(); -// Restore the project, running a command like: "dotnet restore" from the directory "MyLib" -result = new DotNetRestore() - .WithWorkingDirectory("MyLib") - .Build() - .EnsureSuccess(); +var lines = new List(); +new DotNetListReference() + .WithProject(Path.Combine("MyTests", "MyTests.csproj")) + .Run(output => lines.Add(output.Line)); -result.ExitCode.ShouldBe(0); +lines.Any(i => i.Contains("MyLib.csproj")).ShouldBeTrue(); ``` -### Run a project +### Test a project using the MSBuild VSTest target ``` CSharp -// Adds the namespace "HostApi" to use .NET build API 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(); +// Runs tests via a command +var result = new MSBuild() + .WithTarget("VSTest") + .WithWorkingDirectory("MyTests") + .Build().EnsureSuccess(); -result.ExitCode.ShouldBe(0); +// The "result" variable provides details about a build +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()); +``` -// Runs the console project using a command like: "dotnet run" from the directory "MyApp" -var stdOut = new List(); -result = new DotNetRun().WithWorkingDirectory("MyApp") - .Build(message => stdOut.Add(message.Text)) - .EnsureSuccess(); -result.ExitCode.ShouldBe(0); -// Checks StdOut -stdOut.ShouldBe(new[] {"Hello, World!"}); +### Display template package metadata + + + +``` CSharp +using HostApi; + +new DotNetNewDetails() + .WithTemplateName("CSharpInteractive.Templates") + .Run().EnsureSuccess(); ``` -### Test a project +### Installing a template package ``` CSharp -// Adds the namespace "HostApi" to use .NET build API 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(); +new DotNetNewInstall() + .WithPackage("Pure.DI.Templates") + .Run().EnsureSuccess(); +``` -result.ExitCode.ShouldBe(0); -// Runs tests via a command like: "dotnet test" from the directory "MyTests" -result = new DotNetTest() - .WithWorkingDirectory("MyTests") - .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); +### Creating a new project from template + + + +``` CSharp +using HostApi; + +new DotNetNewList() + .Run().EnsureSuccess(); ``` -### Run tests under dotCover +### List available templates ``` CSharp -// Adds the namespace "HostApi" to use .NET build API 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("classlib") + .WithName("MyLib") + .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 DotNetCustom("tool", "install", "--local", "JetBrains.dotCover.GlobalTool") - .Run() - .EnsureSuccess(); -// Creates a test command -var test = new DotNetTest() - .WithProject("MyTests"); +### Searche for the templates -var dotCoverSnapshot = Path.Combine("MyTests", "dotCover.dcvr"); -var dotCoverReport = Path.Combine("MyTests", "dotCover.html"); -// Modifies the test command by putting "dotCover" in front of all arguments -// to have something like "dotnet dotcover test ..." -// and adding few specific arguments to the end -var testUnderDotCover = test.Customize(cmd => - cmd.ClearArgs() - + "dotcover" - + cmd.Args - + $"--dcOutput={dotCoverSnapshot}" - + "--dcFilters=+:module=TeamCity.CSharpInteractive.HostApi;+:module=dotnet-csi" - + "--dcAttributeFilters=System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage"); -// Runs tests under dotCover via a command like: "dotnet dotcover test ..." -var result = testUnderDotCover - .Build() - .EnsureSuccess(); -// The "result" variable provides details about a build -result.ExitCode.ShouldBe(0); -result.Tests.Count(i => i.State == TestState.Finished).ShouldBe(1); +``` CSharp +using HostApi; -// Generates a HTML code coverage report. -new DotNetCustom("dotCover", "report", $"--source={dotCoverSnapshot}", $"--output={dotCoverReport}", "--reportType=HTML") +new DotNetNewSearch() + .WithTemplateName("build") .Run().EnsureSuccess(); +``` + + -// Check for a dotCover report -File.Exists(dotCoverReport).ShouldBeTrue(); +### Uninstalling a template package + + + +``` CSharp +using HostApi; + +new DotNetNewUninstall() + .WithPackage("Pure.DI.Templates") + .Run(); ``` -### Restore local tools +### Updating installed template packages ``` CSharp -// Adds the namespace "HostApi" to use .NET build API using HostApi; -var projectDir = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()[..4]); -Directory.CreateDirectory(projectDir); +new DotNetNewUpdate() + .Run().EnsureSuccess(); +``` + -// Creates a local tool manifest -new DotNetNew("tool-manifest") - .WithWorkingDirectory(projectDir) - .Run() - .EnsureSuccess(); -// Restore local tools -new DotNetToolRestore() - .WithWorkingDirectory(projectDir) - .Run() - .EnsureSuccess(); +### Adding a NuGet source + + + +``` CSharp +using HostApi; + +new DotNetNuGetAddSource() + .WithName("TestSource") + .WithSource(source) + .Run().EnsureSuccess(); ``` -### Test an assembly +### Gets the value of a specified NuGet configuration setting ``` CSharp -// Adds the namespace "HostApi" to use .NET build API 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(); +string? repositoryPath = default; +new DotNetNuGetConfigGet() + .WithConfigKey("repositoryPath") + .Run(output => repositoryPath = output.Line).EnsureSuccess(); +``` -result.ExitCode.ShouldBe(0); -// Builds the test project, running a command like: "dotnet build -c Release" from the directory "MyTests" -result = new DotNetBuild() - .WithWorkingDirectory("MyTests") - .WithConfiguration("Release") - .WithOutput("MyOutput") - .Build() - .EnsureSuccess(); -result.ExitCode.ShouldBe(0); +### Printing nuget configuration files currently being applied to a directory -// Runs tests via a command like: "dotnet vstest" from the directory "MyTests" -result = new VSTest() - .AddTestFileNames(Path.Combine("MyOutput", "MyTests.dll")) - .WithWorkingDirectory("MyTests") - .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); + +``` CSharp +using HostApi; + +var configPaths = new List(); +new DotNetNuGetConfigPaths() + .Run(output => configPaths.Add(output.Line)).EnsureSuccess(); ``` -### Build a project using MSBuild +### Sets the value of a specified NuGet configuration setting ``` CSharp -// Adds the namespace "HostApi" to use .NET build API 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(); +new DotNetNuGetConfigSet() + .WithConfigFile(configFile) + .WithConfigKey("repositoryPath") + .WithConfigValue("MyValue") + .Run().EnsureSuccess(); +``` -result.ExitCode.ShouldBe(0); -// Builds the library project, running a command like: "dotnet msbuild /t:Build -restore /p:configuration=Release -verbosity=detailed" from the directory "MyLib" -result = new MSBuild() - .WithWorkingDirectory("MyLib") - .WithTarget("Build") - .WithRestore(true) - .AddProps(("configuration", "Release")) - .WithVerbosity(DotNetVerbosity.Detailed) - .Build() - .EnsureSuccess(); -// The "result" variable provides details about a build -result.Errors.Any(message => message.State == BuildMessageState.StdError).ShouldBeFalse(); -result.ExitCode.ShouldBe(0); +### Unsets the value of a specified NuGet configuration setting + + + +``` CSharp +using HostApi; + +new DotNetNuGetConfigUnset() + .WithConfigKey("repositoryPath") + .Run().EnsureSuccess(); ``` -### Shuts down build servers +### Deleting a NuGet package to the server ``` CSharp -// Adds the namespace "HostApi" to use .NET build API using HostApi; -// Shuts down all build servers that are started from dotnet. -new DotNetBuildServerShutdown() - .Run() - .EnsureSuccess(); +new DotNetNuGetDelete() + .WithPackage("MyLib") + .WithPackageVersion("1.0.0") + .WithSource(repoUrl) + .Run().EnsureSuccess(); +``` + + + +### Disabling a NuGet source + + + +``` CSharp +using HostApi; + +new DotNetNuGetDisableSource() + .WithName("TestSource") + .Run().EnsureSuccess(); +``` + + + +### Enabling a NuGet source + + + +``` CSharp +using HostApi; + +new DotNetNuGetEnableSource() + .WithName("TestSource") + .Run().EnsureSuccess(); +``` + + + +### Printing all configured NuGet sources + + + +``` CSharp +using HostApi; + +new DotNetNuGetListSource() + .WithFormat(NuGetListFormat.Short) + .Run().EnsureSuccess(); +``` + + + +### Clearing the specified NuGet cache type + + + +``` CSharp +using HostApi; + +new DotNetNuGetLocalsClear() + .WithCacheLocation(NuGetCacheLocation.Temp) + .Run().EnsureSuccess(); +``` + + + +### Printing the location of the specified NuGet cache type + + + +``` CSharp +using HostApi; + +new DotNetNuGetLocalsList() + .WithCacheLocation(NuGetCacheLocation.GlobalPackages) + .Run().EnsureSuccess(); +``` + + + +### Pushing a NuGet package to the server + + + +``` CSharp +using HostApi; + +new DotNetNuGetPush() + .WithWorkingDirectory("MyLib") + .WithPackage(Path.Combine("packages", "MyLib.1.0.0.nupkg")) + .WithSource(repoUrl) + .Run().EnsureSuccess(); +``` + + + +### Removing a NuGet source. + + + +``` CSharp +using HostApi; + +new DotNetNuGetRemoveSource() + .WithName("TestSource") + .Run().EnsureSuccess(); +``` + + + +### Signing with certificate + + + +``` CSharp +using HostApi; + +new DotNetNuGetSign() + .AddPackages("MyLib.1.2.3.nupkg") + .WithCertificatePath("certificate.pfx") + .WithCertificatePassword("Abc") + .WithTimestampingServer("http://timestamp.digicert.com/") + .Run().EnsureSuccess(); +``` + + + +### Updating a NuGet source + + + +``` CSharp +using HostApi; + +new DotNetNuGetUpdateSource() + .WithName("TestSource") + .WithSource(newSource) + .Run().EnsureSuccess(); +``` + + + +### Show the dependency graph for NuGet package + + + +``` CSharp +using HostApi; + +new DotNetNuGetWhy() + .WithProject(Path.Combine("MyLib", "MyLib.csproj")) + .WithPackage("MyLib.1.2.3.nupkg") + .Run().EnsureSuccess(); +``` + + + +### Searching for a NuGet package + + + +``` CSharp +using System.Text; +using System.Text.Json; +using HostApi; + +var packagesJson = new StringBuilder(); +new DotNetPackageSearch() + .WithSearchTerm("Pure.DI") + .WithFormat(DotNetPackageSearchResultFormat.Json) + .Run(output => packagesJson.AppendLine(output.Line)).EnsureSuccess(); + +var result = JsonSerializer.Deserialize( + packagesJson.ToString(), + new JsonSerializerOptions { PropertyNameCaseInsensitive = true }); + +result.ShouldNotBeNull(); +result.SearchResult.SelectMany(i => i.Packages).Count(i => i.Id == "Pure.DI").ShouldBe(1); + +record Result(int Version, IReadOnlyCollection SearchResult); + +record Source(string SourceName, IReadOnlyCollection Packages); + +record Package( + string Id, + string LatestVersion, + int TotalDownloads, + string Owners); +``` + + + +### Packing the code into a NuGet package + + + +``` CSharp +using HostApi; + +// Creates a NuGet package of version 1.2.3 for the project +new DotNetPack() + .WithWorkingDirectory("MyLib") + .WithOutput(path) + .AddProps(("version", "1.2.3")) + .Build().EnsureSuccess(); +``` + + + +### Publishing the application and its dependencies to a folder for deployment to a hosting system + + + +``` CSharp +using HostApi; + +new DotNetPublish() + .WithWorkingDirectory("MyLib") + .WithFramework("net8.0") + .WithOutput("bin") + .Build().EnsureSuccess(); +``` + + + +### Removing a NuGet package + + + +``` CSharp +using HostApi; + +new DotNetAddPackage() + .WithWorkingDirectory("MyLib") + .WithPackage("Pure.DI") + .Run().EnsureSuccess(); + +new DotNetRemovePackage() + .WithWorkingDirectory("MyLib") + .WithPackage("Pure.DI") + .Run().EnsureSuccess(); +``` + + + +### Adding a project reference + + + +``` CSharp +using HostApi; + +new DotNetAddReference() + .WithProject(Path.Combine("MyTests", "MyTests.csproj")) + .WithReferences(Path.Combine("MyLib", "MyLib.csproj")) + .Run().EnsureSuccess(); + +new DotNetRemoveReference() + .WithProject(Path.Combine("MyTests", "MyTests.csproj")) + .WithReferences(Path.Combine("MyLib", "MyLib.csproj")) + .Run().EnsureSuccess(); + +var lines = new List(); +new DotNetListReference() + .WithProject(Path.Combine("MyTests", "MyTests.csproj")) + .Run(output => lines.Add(output.Line)); + +lines.Any(i => i.Contains("MyLib.csproj")).ShouldBeFalse(); +``` + + + +### Restoring the dependencies and tools of a project + + + +``` CSharp +using HostApi; + +new DotNetRestore() + .WithProject(Path.Combine("MyLib", "MyLib.csproj")) + .Build().EnsureSuccess(); +``` + + + +### Running source code without any explicit compile or launch commands + + + +``` CSharp +using HostApi; + +var stdOut = new List(); +new DotNetRun() + .WithProject(Path.Combine("MyApp", "MyApp.csproj")) + .Build(message => stdOut.Add(message.Text)) + .EnsureSuccess(); + +// Checks stdOut +stdOut.ShouldBe(new[] {"Hello, World!"}); +``` + + + +### Run a dotnet application + + + +``` CSharp +// Adds the namespace "HostApi" to use .NET build API +using HostApi; + +new DotNet() + .WithPathToApplication(Path.Combine(path, "MyApp.dll")) + .Run().EnsureSuccess(); +``` + + + +### Printing the latest available version of the .NET SDK and .NET Runtime, for each feature band + + + +``` CSharp +using HostApi; + +var sdks = new List(); +new DotNetSdkCheck() + .Run(output => + { + if (output.Line.StartsWith("Microsoft.")) + { + var data = output.Line.Split(' ', StringSplitOptions.RemoveEmptyEntries); + if (data.Length >= 2) + { + sdks.Add(new Sdk(data[0], NuGetVersion.Parse(data[1]))); + } + } + }) + .EnsureSuccess(); + +sdks.Count.ShouldBeGreaterThan(0); + +record Sdk(string Name, NuGetVersion Version); +``` + + + +### Adding projects to the solution file + + + +``` CSharp +using HostApi; + +new DotNetNew() + .WithTemplateName("sln") + .WithName("NySolution") + .WithForce(true) + .Run().EnsureSuccess(); + +new DotNetSlnAdd() + .WithSolution("NySolution.sln") + .AddProjects( + Path.Combine("MyLib", "MyLib.csproj"), + Path.Combine("MyTests", "MyTests.csproj")) + .Run().EnsureSuccess(); +``` + + + +### Printing all projects in a solution file + + + +``` CSharp +using HostApi; + +var lines = new List(); +new DotNetSlnList() + .WithSolution("NySolution.sln") + .Run(output => lines.Add(output.Line)) + .EnsureSuccess(); +``` + + + +### Adding projects to the solution file + + + +``` CSharp +using HostApi; + +new DotNetSlnRemove() + .WithSolution("NySolution.sln") + .AddProjects( + Path.Combine("MyLib", "MyLib.csproj")) + .Run().EnsureSuccess(); +``` + + + +### Storing the specified assemblies in the runtime package store. + + + +``` CSharp +using HostApi; + +new DotNetStore() + .AddManifests(Path.Combine("MyLib", "MyLib.csproj")) + .WithFramework("net8.0") + .WithRuntime("win-x64") + .Build(); + +``` + + + +### Test a project + + + +``` CSharp +using HostApi; + +// Runs tests +var result = new DotNetTest() + .WithWorkingDirectory("MyTests") + .Build().EnsureSuccess(); + +// The "result" variable provides details about build and tests +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()); +``` + + + +### Run tests under dotCover + + + +``` CSharp +using HostApi; + +new DotNetToolInstall() + .WithLocal(true) + .WithPackage("JetBrains.dotCover.GlobalTool") + .Run().EnsureSuccess(); + +// Creates a test command +var test = new DotNetTest() + .WithProject("MyTests"); + +var dotCoverSnapshot = Path.Combine("MyTests", "dotCover.dcvr"); +var dotCoverReport = Path.Combine("MyTests", "dotCover.html"); +// Modifies the test command by putting "dotCover" in front of all arguments +// to have something like "dotnet dotcover test ..." +// and adding few specific arguments to the end +var testUnderDotCover = test.Customize(cmd => + cmd.ClearArgs() + + "dotcover" + + cmd.Args + + $"--dcOutput={dotCoverSnapshot}" + + "--dcFilters=+:module=TeamCity.CSharpInteractive.HostApi;+:module=dotnet-csi" + + "--dcAttributeFilters=System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage"); + +// Runs tests under dotCover +var result = testUnderDotCover + .Build().EnsureSuccess(); + +// The "result" variable provides details about a build +result.ExitCode.ShouldBe(0, result.ToString()); +result.Tests.Count(i => i.State == TestState.Finished).ShouldBe(1, result.ToString()); + +// Generates a HTML code coverage report. +new DotNetCustom("dotCover", "report", $"--source={dotCoverSnapshot}", $"--output={dotCoverReport}", "--reportType=HTML") + .Run().EnsureSuccess(); +``` + + + +### Installing the specified .NET tool + + + +``` CSharp +using HostApi; + +new DotNetToolInstall() + .WithLocal(true) + .WithPackage("dotnet-csi") + .Run().EnsureSuccess(); +``` + + + +### Printing all .NET tools of the specified type currently installed + + + +``` CSharp +using HostApi; + +new DotNetToolList() + .WithLocal(true) + .Run().EnsureSuccess(); + +new DotNetToolList() + .WithGlobal(true) + .Run().EnsureSuccess(); +``` + + + +### Installing the .NET local tools that are in scope for the current directory + + + +``` CSharp +using HostApi; + +// Creates a local tool manifest +new DotNetNew() + .WithTemplateName("tool-manifest") + .Run().EnsureSuccess(); + +new DotNetToolRestore() + .Run().EnsureSuccess(); +``` + + + +### Invoking a local tool + + + +``` CSharp +using HostApi; + +var script = Path.GetTempFileName(); +File.WriteAllText(script, "Console.WriteLine($\"Hello, {Args[0]}!\");"); + +var stdOut = new List(); +new DotNetToolRun() + .WithCommandName("dotnet-csi") + .AddArgs(script) + .AddArgs("World") + .Run(output => stdOut.Add(output.Line)) + .EnsureSuccess(); + +// Checks stdOut +stdOut.Contains("Hello, World!").ShouldBeTrue(); +``` + + + +### Searching all .NET tools that are published to NuGet + + + +``` CSharp +using HostApi; + +new DotNetToolSearch() + .WithPackage("dotnet-csi") + .WithDetail(true) + .Run().EnsureSuccess(); +``` + + + +### Uninstalling the specified .NET tool + + + +``` CSharp +using HostApi; + +new DotNetToolUninstall() + .WithPackage("dotnet-csi") + .Run().EnsureSuccess(); +``` + + + +### Installing the specified .NET tool + + + +``` CSharp +using HostApi; + +new DotNetToolUpdate() + .WithLocal(true) + .WithPackage("dotnet-csi") + .Run().EnsureSuccess(); +``` + + + +### Running tests from the specified assemblies + + + +``` CSharp +using HostApi; + +// Runs tests +var result = new VSTest() + .AddTestFileNames(Path.Combine("bin", "MyTests.dll")) + .WithWorkingDirectory(path) + .Build().EnsureSuccess(); + +// The "result" variable provides details about build and tests +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()); +``` + + + +### Enabling or disabling workload-set update mode + + + +``` CSharp +using HostApi; + +new DotNetWorkloadConfig() + .WithUpdateMode(DotNetWorkloadUpdateMode.WorkloadSet) + .Run().EnsureSuccess(); +``` + + + +### Installing optional workloads + + + +``` CSharp +using HostApi; + +new DotNetWorkloadInstall() + .AddWorkloads("aspire") + .Run().EnsureSuccess(); +``` + + + +### Printing installed workloads + + + +``` CSharp +using HostApi; + +new DotNetWorkloadList() + .Run().EnsureSuccess(); +``` + + + +### Repairing workloads installations + + + +``` CSharp +using HostApi; + +new DotNetWorkloadRepair() + .Run().EnsureSuccess(); +``` + + + +### Installing workloads needed for a project or a solution + + + +``` CSharp +using HostApi; + +new DotNetWorkloadRestore() + .WithProject(Path.Combine("MyLib", "MyLib.csproj")) + .Run().EnsureSuccess(); +``` + + + +### Searching for optional workloads + + + +``` CSharp +using HostApi; + +new DotNetWorkloadSearch() + .WithSearchString("maui") + .Run().EnsureSuccess(); +``` + + + +### Uninstalling a specified workload + + + +``` CSharp +using HostApi; + +new DotNetWorkloadUninstall() + .AddWorkloads("aspire") + .Run().EnsureSuccess(); +``` + + + +### Updating installed workloads + + + +``` CSharp +using HostApi; + +new DotNetWorkloadUpdate() + .Run().EnsureSuccess(); +``` + + + +### Build a project using MSBuild + + + +``` CSharp +using HostApi; + +// Creates a new library project, running a command like: "dotnet new classlib -n MyLib --force" +new DotNetNew() + .WithTemplateName("classlib") + .WithName("MyLib") + .WithForce(true) + .Build().EnsureSuccess(); + +// Builds the library project, running a command like: "dotnet msbuild /t:Build -restore /p:configuration=Release -verbosity=detailed" from the directory "MyLib" +var result = new MSBuild() + .WithWorkingDirectory("MyLib") + .WithTarget("Build") + .WithRestore(true) + .AddProps(("configuration", "Release")) + .WithVerbosity(DotNetVerbosity.Detailed) + .Build().EnsureSuccess(); + +// The "result" variable provides details about a build +result.Errors.Any(message => message.State == BuildMessageState.StdError).ShouldBeFalse(result.ToString()); +result.ExitCode.ShouldBe(0, result.ToString()); +``` + + + +### Shuts down build servers + + + +``` CSharp +using HostApi; + +// Shuts down all build servers that are started from dotnet. +new DotNetBuildServerShutdown() + .Run().EnsureSuccess(); +``` + + + +### Run C# script + + + +``` CSharp +using HostApi; + +var script = Path.GetTempFileName(); +File.WriteAllText(script, "Console.WriteLine($\"Hello, {Args[0]}!\");"); + +var stdOut = new List(); +new DotNetCsi() + .WithScript(script) + .AddArgs("World") + .Run(output => stdOut.Add(output.Line)) + .EnsureSuccess(); + +// Checks stdOut +stdOut.Contains("Hello, World!").ShouldBeTrue(); ``` diff --git a/CSharpInteractive.Tests/README_TEMPLATE.tt b/CSharpInteractive.Tests/README_TEMPLATE.tt index 119cfac3..f0f995a4 100644 --- a/CSharpInteractive.Tests/README_TEMPLATE.tt +++ b/CSharpInteractive.Tests/README_TEMPLATE.tt @@ -12,6 +12,19 @@ var solutionPath = Path.Combine(currentPath, ".."); var infos = new List>(); + var commentsDir = Path.Combine(scenariosPath, "Comments"); + if (Directory.Exists(commentsDir)) + { + foreach (var file in Directory.GetFiles(commentsDir, "*.txt")) + { + File.Delete(file); + } + } + else + { + Directory.CreateDirectory(commentsDir); + } + foreach (var file in Directory.GetFiles(scenariosPath, "*.cs")) { var isBody = false; @@ -48,7 +61,7 @@ { var parts = str.Substring(4, str.Length - 4).Split([ '=' - ], 2, StringSplitOptions.RemoveEmptyEntries); + ], 2, StringSplitOptions.RemoveEmptyEntries); if (parts.Length == 2) { var key = parts[0]; @@ -127,12 +140,15 @@ <# foreach (var info in infos.OrderBy(i => i["tag"] + i["priority"]).Where(info => info["visible"] == "true")) { + var file = info["file"]; + var body = info["body"]; + File.WriteAllText(Path.Combine(commentsDir, Path.GetFileNameWithoutExtension(file) + ".txt"), body); #>### <#= info["description"] #> <#= info["header"] #> ``` CSharp -<#= info["body"] #>``` +<#= body #>``` <#= info["footer"] #> diff --git a/CSharpInteractive.Tests/ReferencesScriptOptionsFactoryTests.cs b/CSharpInteractive.Tests/ReferencesScriptOptionsFactoryTests.cs index f27e0d5e..ed9f2b7a 100644 --- a/CSharpInteractive.Tests/ReferencesScriptOptionsFactoryTests.cs +++ b/CSharpInteractive.Tests/ReferencesScriptOptionsFactoryTests.cs @@ -1,7 +1,6 @@ namespace CSharpInteractive.Tests; using System.Reflection; -using Core; using Microsoft.CodeAnalysis.Scripting; public class ReferencesScriptOptionsFactoryTests diff --git a/CSharpInteractive.Tests/ReliableBuildContextTests.cs b/CSharpInteractive.Tests/ReliableBuildContextTests.cs index d923d476..bb6829cc 100644 --- a/CSharpInteractive.Tests/ReliableBuildContextTests.cs +++ b/CSharpInteractive.Tests/ReliableBuildContextTests.cs @@ -1,7 +1,5 @@ namespace CSharpInteractive.Tests; -using Core; -using HostApi; using JetBrains.TeamCity.ServiceMessages; using JetBrains.TeamCity.ServiceMessages.Write; diff --git a/CSharpInteractive.Tests/RuntimeExplorerTests.cs b/CSharpInteractive.Tests/RuntimeExplorerTests.cs index a02c31b9..ea437199 100644 --- a/CSharpInteractive.Tests/RuntimeExplorerTests.cs +++ b/CSharpInteractive.Tests/RuntimeExplorerTests.cs @@ -1,7 +1,6 @@ namespace CSharpInteractive.Tests; using System.Diagnostics.CodeAnalysis; -using Core; [SuppressMessage("Performance", "CA1861:Avoid constant arrays as arguments")] public class RuntimeExplorerTests diff --git a/CSharpInteractive.Tests/ScriptCommandParserTests.cs b/CSharpInteractive.Tests/ScriptCommandParserTests.cs index 570d0bbb..0c3e66d0 100644 --- a/CSharpInteractive.Tests/ScriptCommandParserTests.cs +++ b/CSharpInteractive.Tests/ScriptCommandParserTests.cs @@ -3,7 +3,7 @@ namespace CSharpInteractive.Tests; using Core; -using Environment = Environment; +using Environment = System.Environment; public class ScriptCommandParserTests { diff --git a/CSharpInteractive.Tests/ScriptContentReplacerTests.cs b/CSharpInteractive.Tests/ScriptContentReplacerTests.cs index 78ce23ea..bd0896f5 100644 --- a/CSharpInteractive.Tests/ScriptContentReplacerTests.cs +++ b/CSharpInteractive.Tests/ScriptContentReplacerTests.cs @@ -1,7 +1,6 @@ namespace CSharpInteractive.Tests; using System.Diagnostics.CodeAnalysis; -using Core; using NuGet.Versioning; [SuppressMessage("Performance", "CA1861:Avoid constant arrays as arguments")] diff --git a/CSharpInteractive.Tests/ScriptRunnerTests.cs b/CSharpInteractive.Tests/ScriptRunnerTests.cs index ed21deb1..75f5fbbc 100644 --- a/CSharpInteractive.Tests/ScriptRunnerTests.cs +++ b/CSharpInteractive.Tests/ScriptRunnerTests.cs @@ -1,7 +1,6 @@ namespace CSharpInteractive.Tests; using System.Diagnostics.CodeAnalysis; -using Core; [SuppressMessage("Performance", "CA1861:Avoid constant arrays as arguments")] [SuppressMessage("Usage", "xUnit1042:The member referenced by the MemberData attribute returns untyped data rows")] diff --git a/CSharpInteractive.Tests/SettingCommandParserTests.cs b/CSharpInteractive.Tests/SettingCommandParserTests.cs index 940249d8..0277af65 100644 --- a/CSharpInteractive.Tests/SettingCommandParserTests.cs +++ b/CSharpInteractive.Tests/SettingCommandParserTests.cs @@ -1,7 +1,6 @@ namespace CSharpInteractive.Tests; using System.Diagnostics.CodeAnalysis; -using Core; [SuppressMessage("Usage", "xUnit1042:The member referenced by the MemberData attribute returns untyped data rows")] public class SettingCommandParserTests diff --git a/CSharpInteractive.Tests/SettingCommandRunnerTests.cs b/CSharpInteractive.Tests/SettingCommandRunnerTests.cs index 84f2a23f..46a794f9 100644 --- a/CSharpInteractive.Tests/SettingCommandRunnerTests.cs +++ b/CSharpInteractive.Tests/SettingCommandRunnerTests.cs @@ -1,7 +1,5 @@ namespace CSharpInteractive.Tests; -using Core; - public class SettingCommandRunnerTests { [Fact] diff --git a/CSharpInteractive.Tests/SettingTests.cs b/CSharpInteractive.Tests/SettingTests.cs index 13835bf3..ac60911a 100644 --- a/CSharpInteractive.Tests/SettingTests.cs +++ b/CSharpInteractive.Tests/SettingTests.cs @@ -1,7 +1,5 @@ namespace CSharpInteractive.Tests; -using Core; - public class SettingTests { [Fact] diff --git a/CSharpInteractive.Tests/SettingsTests.cs b/CSharpInteractive.Tests/SettingsTests.cs index 046acf95..42d414a0 100644 --- a/CSharpInteractive.Tests/SettingsTests.cs +++ b/CSharpInteractive.Tests/SettingsTests.cs @@ -1,7 +1,6 @@ namespace CSharpInteractive.Tests; using System.Diagnostics.CodeAnalysis; -using Core; [SuppressMessage("Performance", "CA1861:Avoid constant arrays as arguments")] public class SettingsTests diff --git a/CSharpInteractive.Tests/SourceFileScriptOptionsFactoryTests.cs b/CSharpInteractive.Tests/SourceFileScriptOptionsFactoryTests.cs index ecf838ee..56712f8b 100644 --- a/CSharpInteractive.Tests/SourceFileScriptOptionsFactoryTests.cs +++ b/CSharpInteractive.Tests/SourceFileScriptOptionsFactoryTests.cs @@ -1,6 +1,5 @@ namespace CSharpInteractive.Tests; -using Core; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Scripting; diff --git a/CSharpInteractive.Tests/SourceResolverTests.cs b/CSharpInteractive.Tests/SourceResolverTests.cs index 79af565e..0ed87294 100644 --- a/CSharpInteractive.Tests/SourceResolverTests.cs +++ b/CSharpInteractive.Tests/SourceResolverTests.cs @@ -1,7 +1,6 @@ namespace CSharpInteractive.Tests; using System.IO; -using Core; public class SourceResolverTests { diff --git a/CSharpInteractive.Tests/StartInfoFactoryTests.cs b/CSharpInteractive.Tests/StartInfoFactoryTests.cs index 5a77f411..2e3315bc 100644 --- a/CSharpInteractive.Tests/StartInfoFactoryTests.cs +++ b/CSharpInteractive.Tests/StartInfoFactoryTests.cs @@ -1,8 +1,5 @@ namespace CSharpInteractive.Tests; -using Core; -using HostApi; - public class StartInfoFactoryTests { private readonly Mock _environment = new(); diff --git a/CSharpInteractive.Tests/StatisticsTests.cs b/CSharpInteractive.Tests/StatisticsTests.cs index 1f8a032d..e2fae3ad 100644 --- a/CSharpInteractive.Tests/StatisticsTests.cs +++ b/CSharpInteractive.Tests/StatisticsTests.cs @@ -1,7 +1,5 @@ namespace CSharpInteractive.Tests; -using Core; - public class StatisticsTests { [Fact] diff --git a/CSharpInteractive.Tests/StringServiceTests.cs b/CSharpInteractive.Tests/StringServiceTests.cs index 3f5a1b31..be431f63 100644 --- a/CSharpInteractive.Tests/StringServiceTests.cs +++ b/CSharpInteractive.Tests/StringServiceTests.cs @@ -1,7 +1,5 @@ namespace CSharpInteractive.Tests; -using Core; - public class StringServiceTests { [Theory] diff --git a/CSharpInteractive.Tests/SummaryPresenterTests.cs b/CSharpInteractive.Tests/SummaryPresenterTests.cs index 1bc53427..c1b8311a 100644 --- a/CSharpInteractive.Tests/SummaryPresenterTests.cs +++ b/CSharpInteractive.Tests/SummaryPresenterTests.cs @@ -1,8 +1,6 @@ namespace CSharpInteractive.Tests; using System.Diagnostics.CodeAnalysis; -using Core; -using HostApi; [SuppressMessage("Performance", "CA1861:Avoid constant arrays as arguments")] public class SummaryPresenterTests diff --git a/CSharpInteractive.Tests/TargetFrameworkMonikerParserTests.cs b/CSharpInteractive.Tests/TargetFrameworkMonikerParserTests.cs index 9e910b54..4486b615 100644 --- a/CSharpInteractive.Tests/TargetFrameworkMonikerParserTests.cs +++ b/CSharpInteractive.Tests/TargetFrameworkMonikerParserTests.cs @@ -1,7 +1,5 @@ namespace CSharpInteractive.Tests; -using Core; - public class TargetFrameworkMonikerParserTests { [Theory] diff --git a/CSharpInteractive.Tests/TeamCityContextTests.cs b/CSharpInteractive.Tests/TeamCityContextTests.cs index 314e400c..ba0f1446 100644 --- a/CSharpInteractive.Tests/TeamCityContextTests.cs +++ b/CSharpInteractive.Tests/TeamCityContextTests.cs @@ -2,8 +2,6 @@ namespace CSharpInteractive.Tests; -using Core; - public class TeamCityContextTests { private readonly Mock _environment = new(); diff --git a/CSharpInteractive.Tests/TeamCityInOutTests.cs b/CSharpInteractive.Tests/TeamCityInOutTests.cs index 362aff8d..d902d949 100644 --- a/CSharpInteractive.Tests/TeamCityInOutTests.cs +++ b/CSharpInteractive.Tests/TeamCityInOutTests.cs @@ -1,6 +1,5 @@ namespace CSharpInteractive.Tests; -using Core; using JetBrains.TeamCity.ServiceMessages.Write.Special; public class TeamCityInOutTests diff --git a/CSharpInteractive.Tests/TeamCityLineFormatterTests.cs b/CSharpInteractive.Tests/TeamCityLineFormatterTests.cs index b2070175..d17ce15c 100644 --- a/CSharpInteractive.Tests/TeamCityLineFormatterTests.cs +++ b/CSharpInteractive.Tests/TeamCityLineFormatterTests.cs @@ -1,8 +1,6 @@ namespace CSharpInteractive.Tests; using System.Diagnostics.CodeAnalysis; -using Core; -using HostApi; [SuppressMessage("Usage", "xUnit1042:The member referenced by the MemberData attribute returns untyped data rows")] public class TeamCityLineFormatterTests diff --git a/CSharpInteractive.Tests/TeamCityLogTests.cs b/CSharpInteractive.Tests/TeamCityLogTests.cs index f2f0f425..7139da1f 100644 --- a/CSharpInteractive.Tests/TeamCityLogTests.cs +++ b/CSharpInteractive.Tests/TeamCityLogTests.cs @@ -1,6 +1,5 @@ namespace CSharpInteractive.Tests; -using Core; using JetBrains.TeamCity.ServiceMessages.Write.Special; public class TeamCityLogTests diff --git a/CSharpInteractive.Tests/TeamCityPropertiesTests.cs b/CSharpInteractive.Tests/TeamCityPropertiesTests.cs index 386dd9c0..149b857c 100644 --- a/CSharpInteractive.Tests/TeamCityPropertiesTests.cs +++ b/CSharpInteractive.Tests/TeamCityPropertiesTests.cs @@ -1,7 +1,5 @@ namespace CSharpInteractive.Tests; -using Core; -using HostApi; using JetBrains.TeamCity.ServiceMessages.Write.Special; public class TeamCityPropertiesTests diff --git a/CSharpInteractive.Tests/TextReplacerTests.cs b/CSharpInteractive.Tests/TextReplacerTests.cs index 5b3ac887..3301fd07 100644 --- a/CSharpInteractive.Tests/TextReplacerTests.cs +++ b/CSharpInteractive.Tests/TextReplacerTests.cs @@ -1,7 +1,7 @@ namespace CSharpInteractive.Tests; using Core; -using Environment = Environment; +using Environment = System.Environment; public class TextReplacerTests { diff --git a/CSharpInteractive.Tests/TextToColorStringsTests.cs b/CSharpInteractive.Tests/TextToColorStringsTests.cs index e5fd50ea..cb628419 100644 --- a/CSharpInteractive.Tests/TextToColorStringsTests.cs +++ b/CSharpInteractive.Tests/TextToColorStringsTests.cs @@ -3,7 +3,6 @@ namespace CSharpInteractive.Tests; using System.Diagnostics.CodeAnalysis; -using Core; [SuppressMessage("Usage", "xUnit1042:The member referenced by the MemberData attribute returns untyped data rows")] public class TextToColorStringsTests diff --git a/CSharpInteractive.Tests/TracePresenterTests.cs b/CSharpInteractive.Tests/TracePresenterTests.cs index 962a93bc..498beda1 100644 --- a/CSharpInteractive.Tests/TracePresenterTests.cs +++ b/CSharpInteractive.Tests/TracePresenterTests.cs @@ -1,7 +1,5 @@ namespace CSharpInteractive.Tests; -using Core; - public class TracePresenterTests { private readonly Mock> _log = new(); diff --git a/CSharpInteractive.Tests/UsageScenarios/ArgsScenario.cs b/CSharpInteractive.Tests/UsageScenarios/ArgsScenario.cs index 2c348aa3..cafa6b7a 100644 --- a/CSharpInteractive.Tests/UsageScenarios/ArgsScenario.cs +++ b/CSharpInteractive.Tests/UsageScenarios/ArgsScenario.cs @@ -1,6 +1,6 @@ namespace CSharpInteractive.Tests.UsageScenarios; -public class ArgsScenario : BaseScenario +public class ArgsScenario(ITestOutputHelper output) : BaseScenario(output) { [Fact] public void Run() diff --git a/CSharpInteractive.Tests/UsageScenarios/BaseScenario.cs b/CSharpInteractive.Tests/UsageScenarios/BaseScenario.cs index d97f77b4..5fc9dd51 100644 --- a/CSharpInteractive.Tests/UsageScenarios/BaseScenario.cs +++ b/CSharpInteractive.Tests/UsageScenarios/BaseScenario.cs @@ -1,30 +1,56 @@ // ReSharper disable MemberCanBeProtected.Global +// ReSharper disable MemberCanBeMadeStatic.Global namespace CSharpInteractive.Tests.UsageScenarios; using System.Collections; using System.Diagnostics.CodeAnalysis; +using System.Text; using CSharpInteractive; -using HostApi; -using Environment = Environment; +using NuGet.Versioning; +using Environment = System.Environment; [SuppressMessage("Usage", "CA1816:Dispose methods should call SuppressFinalize")] public class BaseScenario : IHost, IDisposable { + private readonly ITestOutputHelper _output; private readonly string _tempDir; private readonly string _prevCurDir; + private readonly StringBuilder _outputText = new(); - public BaseScenario() + public BaseScenario(ITestOutputHelper output) { + _output = output; Composition.Shared.Root.TestEnvironment.IsTesting = true; Composition.Shared.Root.TestEnvironment.ExitCode = default; _tempDir = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()[..4]); Directory.CreateDirectory(_tempDir); _prevCurDir = Environment.CurrentDirectory; Environment.CurrentDirectory = _tempDir; + Composition.Shared.Root.ConsoleHandler.OutputHandler += ConsoleHandlerOnOutputHandler; + Composition.Shared.Root.ConsoleHandler.ErrorHandler += ConsoleHandlerOnErrorHandler; } + + public int? ExpectedExitCode { get; set; } = 0; - public int ExpectedExitCode { get; set; } + [SuppressMessage("Performance", "CA1822:Пометьте члены как статические")] + public bool HasSdk(string sdkVersion) + { + var versions = new List(); + new DotNetSdkCheck() + .Run(output => + { + if (output.Line.Split(' ', StringSplitOptions.RemoveEmptyEntries) is ["Microsoft.NETCore.App", var versionStr, ..] + && NuGetVersion.TryParse(versionStr, out var version)) + { + versions.Add(version); + } + }) + .EnsureSuccess(); + + var sdkVersionValue = NuGetVersion.Parse(sdkVersion); + return versions.Any(i => i >= sdkVersionValue); + } // ReSharper disable once MemberCanBeProtected.Global public IHost Host => this; @@ -75,6 +101,13 @@ public string this[string key] void IDisposable.Dispose() { + Composition.Shared.Root.ConsoleHandler.OutputHandler -= ConsoleHandlerOnOutputHandler; + Composition.Shared.Root.ConsoleHandler.ErrorHandler -= ConsoleHandlerOnErrorHandler; + if (_outputText.Length > 0) + { + _output.WriteLine(_outputText.ToString()); + } + try { Directory.Delete(_tempDir, true); @@ -85,9 +118,36 @@ void IDisposable.Dispose() } Environment.CurrentDirectory = _prevCurDir; - if (Composition.Shared.Root.TestEnvironment.ExitCode is { } exitCode) + if (ExpectedExitCode is {} expectedExitCode && Composition.Shared.Root.TestEnvironment.ExitCode is { } exitCode) { - exitCode.ShouldBe(ExpectedExitCode); + exitCode.ShouldBe(expectedExitCode); } } + + private void ConsoleHandlerOnOutputHandler(object? sender, string text) => + AddOutput(text, false); + + private void ConsoleHandlerOnErrorHandler(object? sender, string text) => + AddOutput(text, true); + + private void AddOutput(string text, bool isError) + { + _outputText.Append(text.Replace("\x001B", "")); + text = _outputText.ToString(); + do + { + var endOfLine = text.IndexOf(Environment.NewLine, StringComparison.Ordinal); + if (endOfLine == -1) + { + break; + } + + var line = text[..endOfLine]; + _output.WriteLine((isError ? "ERR: " : "STD: ") + line); + text = text[(endOfLine + Environment.NewLine.Length)..]; + } while (text.Length > 0); + + _outputText.Clear(); + _outputText.Append(text); + } } \ No newline at end of file diff --git a/CSharpInteractive.Tests/UsageScenarios/CommandLineAsyncCancellation.cs b/CSharpInteractive.Tests/UsageScenarios/CommandLineAsyncCancellation.cs index 2451950d..9392abb7 100644 --- a/CSharpInteractive.Tests/UsageScenarios/CommandLineAsyncCancellation.cs +++ b/CSharpInteractive.Tests/UsageScenarios/CommandLineAsyncCancellation.cs @@ -4,11 +4,10 @@ namespace CSharpInteractive.Tests.UsageScenarios; using System; -using HostApi; [CollectionDefinition("Integration", DisableParallelization = true)] -[Trait("Integration", "true")] -public class CommandLineAsyncCancellation : BaseScenario +[Trait("Integration", "True")] +public class CommandLineAsyncCancellation(ITestOutputHelper output) : BaseScenario(output) { [SkippableFact] public void Run() @@ -22,7 +21,6 @@ public void Run() // $description=Cancellation of asynchronous run // $header=Cancellation will destroy the process and its child processes. // { - // Adds the namespace "HostApi" to use Command Line API // ## using HostApi; var cancellationTokenSource = new CancellationTokenSource(); diff --git a/CSharpInteractive.Tests/UsageScenarios/CommandLineAsyncScenario.cs b/CSharpInteractive.Tests/UsageScenarios/CommandLineAsyncScenario.cs index e5839526..9b05552f 100644 --- a/CSharpInteractive.Tests/UsageScenarios/CommandLineAsyncScenario.cs +++ b/CSharpInteractive.Tests/UsageScenarios/CommandLineAsyncScenario.cs @@ -5,11 +5,10 @@ namespace CSharpInteractive.Tests.UsageScenarios; using System; -using HostApi; [CollectionDefinition("Integration", DisableParallelization = true)] -[Trait("Integration", "true")] -public class CommandLineAsyncScenario : BaseScenario +[Trait("Integration", "True")] +public class CommandLineAsyncScenario(ITestOutputHelper output) : BaseScenario(output) { [SkippableFact] public async Task Run() @@ -22,19 +21,16 @@ public async Task Run() // $priority=02 // $description=Run a command line asynchronously // { - // Adds the namespace "HostApi" to use Command Line API // ## using HostApi; await GetService() - .RunAsync(new CommandLine("cmd", "/C", "DIR")) - .EnsureSuccess(); + .RunAsync(new CommandLine("cmd", "/C", "DIR")).EnsureSuccess(); // or the same thing using the extension method var result = await new CommandLine("cmd", "/c", "DIR") - .RunAsync() - .EnsureSuccess(); + .RunAsync().EnsureSuccess(); // } - result.ExitCode.HasValue.ShouldBeTrue(); + result.ExitCode.HasValue.ShouldBeTrue(result.ToString()); } } \ No newline at end of file diff --git a/CSharpInteractive.Tests/UsageScenarios/CommandLineInParallelScenario.cs b/CSharpInteractive.Tests/UsageScenarios/CommandLineInParallelScenario.cs index fba2c61d..8a5dc133 100644 --- a/CSharpInteractive.Tests/UsageScenarios/CommandLineInParallelScenario.cs +++ b/CSharpInteractive.Tests/UsageScenarios/CommandLineInParallelScenario.cs @@ -5,11 +5,10 @@ namespace CSharpInteractive.Tests.UsageScenarios; using System; -using HostApi; [CollectionDefinition("Integration", DisableParallelization = true)] -[Trait("Integration", "true")] -public class CommandLineInParallelScenario : BaseScenario +[Trait("Integration", "True")] +public class CommandLineInParallelScenario(ITestOutputHelper output) : BaseScenario(output) { [SkippableFact] public async Task Run() @@ -22,21 +21,18 @@ public async Task Run() // $priority=05 // $description=Run asynchronously in parallel // { - // Adds the namespace "HostApi" to use Command Line API // ## using HostApi; var task = new CommandLine("cmd", "/c", "DIR") - .RunAsync() - .EnsureSuccess(); + .RunAsync().EnsureSuccess(); var result = new CommandLine("cmd", "/c", "SET") - .Run() - .EnsureSuccess(); + .Run().EnsureSuccess(); await task; // } - task.Result.ExitCode.HasValue.ShouldBeTrue(); - result.ExitCode.HasValue.ShouldBeTrue(); + task.Result.ExitCode.HasValue.ShouldBeTrue(result.ToString()); + result.ExitCode.HasValue.ShouldBeTrue(result.ToString()); } } \ No newline at end of file diff --git a/CSharpInteractive.Tests/UsageScenarios/CommandLineOutputScenario.cs b/CSharpInteractive.Tests/UsageScenarios/CommandLineOutputScenario.cs index 32067764..ee00860f 100644 --- a/CSharpInteractive.Tests/UsageScenarios/CommandLineOutputScenario.cs +++ b/CSharpInteractive.Tests/UsageScenarios/CommandLineOutputScenario.cs @@ -4,11 +4,10 @@ namespace CSharpInteractive.Tests.UsageScenarios; using System; -using HostApi; [CollectionDefinition("Integration", DisableParallelization = true)] -[Trait("Integration", "true")] -public class CommandLineOutputScenario : BaseScenario +[Trait("Integration", "True")] +public class CommandLineOutputScenario(ITestOutputHelper output) : BaseScenario(output) { [SkippableFact] public void Run() @@ -21,18 +20,16 @@ public void Run() // $priority=04 // $description=Run and process output // { - // Adds the namespace "HostApi" to use Command Line API // ## using HostApi; var lines = new List(); var result = new CommandLine("cmd", "/c", "SET") .AddVars(("MyEnv", "MyVal")) - .Run(output => lines.Add(output.Line)) - .EnsureSuccess(); + .Run(output => lines.Add(output.Line)).EnsureSuccess(); lines.ShouldContain("MyEnv=MyVal"); // } - result.ExitCode.HasValue.ShouldBeTrue(); + result.ExitCode.HasValue.ShouldBeTrue(result.ToString()); } } \ No newline at end of file diff --git a/CSharpInteractive.Tests/UsageScenarios/CommandLineScenario.cs b/CSharpInteractive.Tests/UsageScenarios/CommandLineScenario.cs index 469adccd..dd38c596 100644 --- a/CSharpInteractive.Tests/UsageScenarios/CommandLineScenario.cs +++ b/CSharpInteractive.Tests/UsageScenarios/CommandLineScenario.cs @@ -4,11 +4,10 @@ namespace CSharpInteractive.Tests.UsageScenarios; using System; -using HostApi; [CollectionDefinition("Integration", DisableParallelization = true)] -[Trait("Integration", "true")] -public class CommandLineScenario : BaseScenario +[Trait("Integration", "True")] +public class CommandLineScenario(ITestOutputHelper output) : BaseScenario(output) { [SkippableFact] public void Run() @@ -21,17 +20,14 @@ public void Run() // $priority=01 // $description=Run a command line // { - // Adds the namespace "HostApi" to use Command Line API // ## using HostApi; GetService() - .Run(new CommandLine("cmd", "/c", "DIR")) - .EnsureSuccess(); + .Run(new CommandLine("cmd", "/c", "DIR")).EnsureSuccess(); // or the same thing using the extension method new CommandLine("cmd", "/c", "DIR") - .Run() - .EnsureSuccess(); + .Run().EnsureSuccess(); // using operator '+' var cmd = new CommandLine("cmd") + "/c" + "DIR"; diff --git a/CSharpInteractive.Tests/UsageScenarios/CommandLineWithTimeoutScenario.cs b/CSharpInteractive.Tests/UsageScenarios/CommandLineWithTimeoutScenario.cs index bdb6d4e9..67a5501e 100644 --- a/CSharpInteractive.Tests/UsageScenarios/CommandLineWithTimeoutScenario.cs +++ b/CSharpInteractive.Tests/UsageScenarios/CommandLineWithTimeoutScenario.cs @@ -4,11 +4,10 @@ namespace CSharpInteractive.Tests.UsageScenarios; using System; -using HostApi; [CollectionDefinition("Integration", DisableParallelization = true)] -[Trait("Integration", "true")] -public class CommandLineWithTimeoutScenario : BaseScenario +[Trait("Integration", "True")] +public class CommandLineWithTimeoutScenario(ITestOutputHelper output) : BaseScenario(output) { [SkippableFact] public void Run() @@ -23,15 +22,13 @@ public void Run() // $description=Run timeout // $header=If timeout expired a process will be killed. // { - // Adds the namespace "HostApi" to use Command Line API // ## using HostApi; - int? exitCode = new CommandLine("cmd", "/c", "TIMEOUT", "/T", "120") + var exitCode = new CommandLine("cmd", "/c", "TIMEOUT", "/T", "120") .Run(default, TimeSpan.FromMilliseconds(1)) - .EnsureSuccess() .ExitCode; - - exitCode.HasValue.ShouldBeFalse(); // } + + exitCode.HasValue.ShouldBeFalse(exitCode.ToString()); } } \ No newline at end of file diff --git a/CSharpInteractive.Tests/UsageScenarios/CommandLinesScenario.cs b/CSharpInteractive.Tests/UsageScenarios/CommandLinesScenario.cs index c973c868..fb742944 100644 --- a/CSharpInteractive.Tests/UsageScenarios/CommandLinesScenario.cs +++ b/CSharpInteractive.Tests/UsageScenarios/CommandLinesScenario.cs @@ -7,11 +7,10 @@ namespace CSharpInteractive.Tests.UsageScenarios; using System; -using HostApi; [CollectionDefinition("Integration", DisableParallelization = true)] -[Trait("Integration", "true")] -public class CommandLinesScenario : BaseScenario +[Trait("Integration", "True")] +public class CommandLinesScenario(ITestOutputHelper output) : BaseScenario(output) { [SkippableFact] public void Run() @@ -23,7 +22,6 @@ public void Run() // $priority=00 // $description=Build command lines // { - // Adds the namespace "Script.Cmd" to use Command Line API // ## using HostApi; // Creates and run a simple command line @@ -38,20 +36,16 @@ public void Run() // Same as previous statement new CommandLine("cmd", "/c") .AddArgs("echo", "Hello") - .Run() - .EnsureSuccess(); + .Run().EnsureSuccess(); (new CommandLine("cmd") + "/c" + "echo" + "Hello") - .Run() - .EnsureSuccess(); + .Run().EnsureSuccess(); "cmd".AsCommandLine("/c", "echo", "Hello") - .Run() - .EnsureSuccess(); + .Run().EnsureSuccess(); ("cmd".AsCommandLine() + "/c" + "echo" + "Hello") - .Run() - .EnsureSuccess(); + .Run().EnsureSuccess(); // Just builds a command line with multiple environment variables var cmd = new CommandLine("cmd", "/c", "echo", "Hello") diff --git a/CSharpInteractive.Tests/UsageScenarios/Comments/ArgsScenario.txt b/CSharpInteractive.Tests/UsageScenarios/Comments/ArgsScenario.txt new file mode 100644 index 00000000..8f0d4ed1 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/Comments/ArgsScenario.txt @@ -0,0 +1,9 @@ +if (Args.Count > 0) +{ + WriteLine(Args[0]); +} + +if (Args.Count > 1) +{ + WriteLine(Args[1]); +} diff --git a/CSharpInteractive.Tests/UsageScenarios/Comments/CommandLineAsyncCancellation.txt b/CSharpInteractive.Tests/UsageScenarios/Comments/CommandLineAsyncCancellation.txt new file mode 100644 index 00000000..3f47e3cf --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/Comments/CommandLineAsyncCancellation.txt @@ -0,0 +1,8 @@ +using HostApi; + +var cancellationTokenSource = new CancellationTokenSource(); +var task = new CommandLine("cmd", "/c", "TIMEOUT", "/T", "120") + .RunAsync(default, cancellationTokenSource.Token); + +cancellationTokenSource.CancelAfter(TimeSpan.FromMilliseconds(100)); +task.IsCompleted.ShouldBeFalse(); diff --git a/CSharpInteractive.Tests/UsageScenarios/Comments/CommandLineAsyncScenario.txt b/CSharpInteractive.Tests/UsageScenarios/Comments/CommandLineAsyncScenario.txt new file mode 100644 index 00000000..6b77705b --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/Comments/CommandLineAsyncScenario.txt @@ -0,0 +1,8 @@ +using HostApi; + +await GetService() + .RunAsync(new CommandLine("cmd", "/C", "DIR")).EnsureSuccess(); + +// or the same thing using the extension method +var result = await new CommandLine("cmd", "/c", "DIR") + .RunAsync().EnsureSuccess(); diff --git a/CSharpInteractive.Tests/UsageScenarios/Comments/CommandLineInParallelScenario.txt b/CSharpInteractive.Tests/UsageScenarios/Comments/CommandLineInParallelScenario.txt new file mode 100644 index 00000000..316c2809 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/Comments/CommandLineInParallelScenario.txt @@ -0,0 +1,9 @@ +using HostApi; + +var task = new CommandLine("cmd", "/c", "DIR") + .RunAsync().EnsureSuccess(); + +var result = new CommandLine("cmd", "/c", "SET") + .Run().EnsureSuccess(); + +await task; diff --git a/CSharpInteractive.Tests/UsageScenarios/Comments/CommandLineOutputScenario.txt b/CSharpInteractive.Tests/UsageScenarios/Comments/CommandLineOutputScenario.txt new file mode 100644 index 00000000..cac5c9e5 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/Comments/CommandLineOutputScenario.txt @@ -0,0 +1,8 @@ +using HostApi; + +var lines = new List(); +var result = new CommandLine("cmd", "/c", "SET") + .AddVars(("MyEnv", "MyVal")) + .Run(output => lines.Add(output.Line)).EnsureSuccess(); + +lines.ShouldContain("MyEnv=MyVal"); diff --git a/CSharpInteractive.Tests/UsageScenarios/Comments/CommandLineScenario.txt b/CSharpInteractive.Tests/UsageScenarios/Comments/CommandLineScenario.txt new file mode 100644 index 00000000..ad9001b1 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/Comments/CommandLineScenario.txt @@ -0,0 +1,16 @@ +using HostApi; + +GetService() + .Run(new CommandLine("cmd", "/c", "DIR")).EnsureSuccess(); + +// or the same thing using the extension method +new CommandLine("cmd", "/c", "DIR") + .Run().EnsureSuccess(); + +// using operator '+' +var cmd = new CommandLine("cmd") + "/c" + "DIR"; +cmd.Run().EnsureSuccess(); + +// with environment variables +cmd = new CommandLine("cmd") + "/c" + "DIR" + ("MyEnvVar", "Some Value"); +cmd.Run().EnsureSuccess(); diff --git a/CSharpInteractive.Tests/UsageScenarios/Comments/CommandLineWithTimeoutScenario.txt b/CSharpInteractive.Tests/UsageScenarios/Comments/CommandLineWithTimeoutScenario.txt new file mode 100644 index 00000000..0de1d771 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/Comments/CommandLineWithTimeoutScenario.txt @@ -0,0 +1,5 @@ +using HostApi; + +var exitCode = new CommandLine("cmd", "/c", "TIMEOUT", "/T", "120") + .Run(default, TimeSpan.FromMilliseconds(1)) + .ExitCode; diff --git a/CSharpInteractive.Tests/UsageScenarios/Comments/CommandLinesScenario.txt b/CSharpInteractive.Tests/UsageScenarios/Comments/CommandLinesScenario.txt new file mode 100644 index 00000000..dff5b3ab --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/Comments/CommandLinesScenario.txt @@ -0,0 +1,39 @@ +using HostApi; + +// Creates and run a simple command line +"whoami".AsCommandLine().Run().EnsureSuccess(); + +// Creates and run a simple command line +new CommandLine("whoami").Run().EnsureSuccess(); + +// Creates and run a command line with arguments +new CommandLine("cmd", "/c", "echo", "Hello").Run(); + +// Same as previous statement +new CommandLine("cmd", "/c") + .AddArgs("echo", "Hello") + .Run().EnsureSuccess(); + +(new CommandLine("cmd") + "/c" + "echo" + "Hello") + .Run().EnsureSuccess(); + +"cmd".AsCommandLine("/c", "echo", "Hello") + .Run().EnsureSuccess(); + +("cmd".AsCommandLine() + "/c" + "echo" + "Hello") + .Run().EnsureSuccess(); + +// Just builds a command line with multiple environment variables +var cmd = new CommandLine("cmd", "/c", "echo", "Hello") + .AddVars(("Var1", "val1"), ("var2", "Val2")); + +// Same as previous statement +cmd = new CommandLine("cmd") + "/c" + "echo" + "Hello" + ("Var1", "val1") + ("var2", "Val2"); + +// Builds a command line to run from a specific working directory +cmd = new CommandLine("cmd", "/c", "echo", "Hello") + .WithWorkingDirectory("MyDyrectory"); + +// Builds a command line and replaces all command line arguments +cmd = new CommandLine("cmd", "/c", "echo", "Hello") + .WithArgs("/c", "echo", "Hello !!!"); diff --git a/CSharpInteractive.Tests/UsageScenarios/Comments/DockerDotNetBuildScenario.txt b/CSharpInteractive.Tests/UsageScenarios/Comments/DockerDotNetBuildScenario.txt new file mode 100644 index 00000000..f35b66f8 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/Comments/DockerDotNetBuildScenario.txt @@ -0,0 +1,23 @@ +using HostApi; + +// Creates a base docker command line +var dockerRun = new DockerRun() + .WithAutoRemove(true) + .WithInteractive(true) + .WithImage("mcr.microsoft.com/dotnet/sdk") + .WithPlatform("linux") + .WithContainerWorkingDirectory("/MyProjects") + .AddVolumes((ToAbsoluteLinuxPath(Environment.CurrentDirectory), "/MyProjects")); + +// Creates a new library project in a docker container +dockerRun + .WithCommandLine(new DotNetCustom("new", "classlib", "-n", "MyLib", "--force")) + .Run().EnsureSuccess(); + +// Builds the library project in a docker container +var result = dockerRun + .WithCommandLine(new DotNetBuild().WithProject("MyLib/MyLib.csproj")) + .Build().EnsureSuccess(); + +string ToAbsoluteLinuxPath(string path) => + "/" + path.Replace(":", "").Replace('\\', '/'); diff --git a/CSharpInteractive.Tests/UsageScenarios/Comments/DockerRunScenario.txt b/CSharpInteractive.Tests/UsageScenarios/Comments/DockerRunScenario.txt new file mode 100644 index 00000000..534595e5 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/Comments/DockerRunScenario.txt @@ -0,0 +1,9 @@ +using HostApi; + +// Creates some command line to run in a docker container +var cmd = new CommandLine("whoami"); + +// Runs the command line in a docker container +var result = new DockerRun(cmd, "mcr.microsoft.com/dotnet/sdk") + .WithAutoRemove(true) + .Run().EnsureSuccess(); diff --git a/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetAddPackageScenario.txt b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetAddPackageScenario.txt new file mode 100644 index 00000000..91ada1c9 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetAddPackageScenario.txt @@ -0,0 +1,6 @@ +using HostApi; + +var result = new DotNetAddPackage() + .WithWorkingDirectory("MyLib") + .WithPackage("Pure.DI") + .Run().EnsureSuccess(); diff --git a/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetAddReferenceScenario.txt b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetAddReferenceScenario.txt new file mode 100644 index 00000000..9cfe1466 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetAddReferenceScenario.txt @@ -0,0 +1,7 @@ +using HostApi; + +var result = new DotNetAddReference() + .WithProject(Path.Combine("MyTests", "MyTests.csproj")) + .WithReferences(Path.Combine("MyLib", "MyLib.csproj")) + .Run().EnsureSuccess(); + diff --git a/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetBuildScenario.txt b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetBuildScenario.txt new file mode 100644 index 00000000..22daf53b --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetBuildScenario.txt @@ -0,0 +1,9 @@ +using HostApi; + +var messages = new List(); +var result = new DotNetBuild() + .WithWorkingDirectory("MyTests") + .Build(message => messages.Add(message)).EnsureSuccess(); + +result.Errors.Any(message => message.State == BuildMessageState.StdError).ShouldBeFalse(result.ToString()); +result.ExitCode.ShouldBe(0, result.ToString()); diff --git a/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetBuildServerShutdownScenario.txt b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetBuildServerShutdownScenario.txt new file mode 100644 index 00000000..1164ab3b --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetBuildServerShutdownScenario.txt @@ -0,0 +1,5 @@ +using HostApi; + +// Shuts down all build servers that are started from dotnet. +new DotNetBuildServerShutdown() + .Run().EnsureSuccess(); diff --git a/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetCleanScenario.txt b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetCleanScenario.txt new file mode 100644 index 00000000..ec771853 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetCleanScenario.txt @@ -0,0 +1,6 @@ +using HostApi; + +// Clean the project, running a command like: "dotnet clean" from the directory "MyLib" +new DotNetClean() + .WithWorkingDirectory("MyLib") + .Build().EnsureSuccess(); diff --git a/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetCsiScenario.txt b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetCsiScenario.txt new file mode 100644 index 00000000..b49c061f --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetCsiScenario.txt @@ -0,0 +1,14 @@ +using HostApi; + +var script = Path.GetTempFileName(); +File.WriteAllText(script, "Console.WriteLine($\"Hello, {Args[0]}!\");"); + +var stdOut = new List(); +new DotNetCsi() + .WithScript(script) + .AddArgs("World") + .Run(output => stdOut.Add(output.Line)) + .EnsureSuccess(); + +// Checks stdOut +stdOut.Contains("Hello, World!").ShouldBeTrue(); diff --git a/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetCustomScenario.txt b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetCustomScenario.txt new file mode 100644 index 00000000..a9c013a1 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetCustomScenario.txt @@ -0,0 +1,9 @@ +using HostApi; + +// Gets the dotnet version, running a command like: "dotnet --version" +NuGetVersion? version = default; +new DotNetCustom("--version") + .Run(message => NuGetVersion.TryParse(message.Line, out version)) + .EnsureSuccess(); + +version.ShouldNotBeNull(); diff --git a/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetDevCertsHttpsScenario.txt b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetDevCertsHttpsScenario.txt new file mode 100644 index 00000000..a68efaf6 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetDevCertsHttpsScenario.txt @@ -0,0 +1,9 @@ +using HostApi; + +// Create a certificate, trust it, and export it to a PEM file. +new DotNetDevCertsHttps() + .WithExportPath("certificate.pem") + .WithTrust(true) + .WithFormat(DotNetCertificateFormat.Pem) + .WithPassword("Abc") + .Run().EnsureSuccess(); diff --git a/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetExecScenario.txt b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetExecScenario.txt new file mode 100644 index 00000000..8cd977c0 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetExecScenario.txt @@ -0,0 +1,4 @@ +using HostApi; +new DotNetExec() + .WithPathToApplication(Path.Combine(path, "MyApp.dll")) + .Run().EnsureSuccess(); diff --git a/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetFormatAnalyzersScenario.txt b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetFormatAnalyzersScenario.txt new file mode 100644 index 00000000..d55e50d7 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetFormatAnalyzersScenario.txt @@ -0,0 +1,8 @@ +using HostApi; + +new DotNetFormatAnalyzers() + .WithWorkingDirectory("MyLib") + .WithProject("MyLib.csproj") + .AddDiagnostics("CA1831", "CA1832") + .WithSeverity(DotNetFormatSeverity.Warning) + .Run().EnsureSuccess(); diff --git a/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetFormatScenario.txt b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetFormatScenario.txt new file mode 100644 index 00000000..3797999f --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetFormatScenario.txt @@ -0,0 +1,10 @@ +using HostApi; + +new DotNetFormat() + .WithWorkingDirectory("MyLib") + .WithProject("MyLib.csproj") + .AddDiagnostics("IDE0005", "IDE0006") + .AddIncludes(".", "./tests") + .AddExcludes("./obj") + .WithSeverity(DotNetFormatSeverity.Information) + .Run().EnsureSuccess(); diff --git a/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetFormatStyleScenario.txt b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetFormatStyleScenario.txt new file mode 100644 index 00000000..674a59d6 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetFormatStyleScenario.txt @@ -0,0 +1,8 @@ +using HostApi; + +new DotNetFormatStyle() + .WithWorkingDirectory("MyLib") + .WithProject("MyLib.csproj") + .AddDiagnostics("IDE0005", "IDE0006") + .WithSeverity(DotNetFormatSeverity.Information) + .Run().EnsureSuccess(); diff --git a/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetListPackageScenario.txt b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetListPackageScenario.txt new file mode 100644 index 00000000..3c8044b9 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetListPackageScenario.txt @@ -0,0 +1,14 @@ +using HostApi; + +new DotNetAddPackage() + .WithWorkingDirectory("MyLib") + .WithPackage("Pure.DI") + .Run().EnsureSuccess(); + +var lines = new List(); +new DotNetListPackage() + .WithWorkingDirectory("MyLib") + .WithVerbosity(DotNetVerbosity.Minimal) + .Run(output => lines.Add(output.Line)); + +lines.Any(i => i.Contains("Pure.DI")).ShouldBeTrue(); diff --git a/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetListReferenceScenario.txt b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetListReferenceScenario.txt new file mode 100644 index 00000000..bf2c28f4 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetListReferenceScenario.txt @@ -0,0 +1,13 @@ +using HostApi; + +new DotNetAddReference() + .WithProject(Path.Combine("MyTests", "MyTests.csproj")) + .WithReferences(Path.Combine("MyLib", "MyLib.csproj")) + .Run().EnsureSuccess(); + +var lines = new List(); +new DotNetListReference() + .WithProject(Path.Combine("MyTests", "MyTests.csproj")) + .Run(output => lines.Add(output.Line)); + +lines.Any(i => i.Contains("MyLib.csproj")).ShouldBeTrue(); diff --git a/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetMSBuildVSTestScenario.txt b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetMSBuildVSTestScenario.txt new file mode 100644 index 00000000..72f5df30 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetMSBuildVSTestScenario.txt @@ -0,0 +1,12 @@ +using HostApi; + +// Runs tests via a command +var result = new MSBuild() + .WithTarget("VSTest") + .WithWorkingDirectory("MyTests") + .Build().EnsureSuccess(); + +// The "result" variable provides details about a build +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()); diff --git a/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetNewDetailsScenario.txt b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetNewDetailsScenario.txt new file mode 100644 index 00000000..0bb8edc2 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetNewDetailsScenario.txt @@ -0,0 +1,5 @@ +using HostApi; + +new DotNetNewDetails() + .WithTemplateName("CSharpInteractive.Templates") + .Run().EnsureSuccess(); diff --git a/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetNewInstallScenario.txt b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetNewInstallScenario.txt new file mode 100644 index 00000000..6740ea33 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetNewInstallScenario.txt @@ -0,0 +1,5 @@ +using HostApi; + +new DotNetNewInstall() + .WithPackage("Pure.DI.Templates") + .Run().EnsureSuccess(); diff --git a/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetNewListScenario.txt b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetNewListScenario.txt new file mode 100644 index 00000000..5ff33d14 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetNewListScenario.txt @@ -0,0 +1,4 @@ +using HostApi; + +new DotNetNewList() + .Run().EnsureSuccess(); diff --git a/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetNewScenario.txt b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetNewScenario.txt new file mode 100644 index 00000000..e2b41029 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetNewScenario.txt @@ -0,0 +1,7 @@ +using HostApi; + +new DotNetNew() + .WithTemplateName("classlib") + .WithName("MyLib") + .WithForce(true) + .Run().EnsureSuccess(); diff --git a/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetNewSearchScenario.txt b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetNewSearchScenario.txt new file mode 100644 index 00000000..d06410dd --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetNewSearchScenario.txt @@ -0,0 +1,5 @@ +using HostApi; + +new DotNetNewSearch() + .WithTemplateName("build") + .Run().EnsureSuccess(); diff --git a/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetNewUninstallScenario.txt b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetNewUninstallScenario.txt new file mode 100644 index 00000000..1fe445a2 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetNewUninstallScenario.txt @@ -0,0 +1,5 @@ +using HostApi; + +new DotNetNewUninstall() + .WithPackage("Pure.DI.Templates") + .Run(); diff --git a/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetNewUpdateScenario.txt b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetNewUpdateScenario.txt new file mode 100644 index 00000000..365aabf2 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetNewUpdateScenario.txt @@ -0,0 +1,4 @@ +using HostApi; + +new DotNetNewUpdate() + .Run().EnsureSuccess(); diff --git a/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetNuGetAddSourceScenario.txt b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetNuGetAddSourceScenario.txt new file mode 100644 index 00000000..54d518a2 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetNuGetAddSourceScenario.txt @@ -0,0 +1,6 @@ +using HostApi; + +new DotNetNuGetAddSource() + .WithName("TestSource") + .WithSource(source) + .Run().EnsureSuccess(); diff --git a/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetNuGetConfigGetScenario.txt b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetNuGetConfigGetScenario.txt new file mode 100644 index 00000000..b61fe61f --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetNuGetConfigGetScenario.txt @@ -0,0 +1,6 @@ +using HostApi; + +string? repositoryPath = default; +new DotNetNuGetConfigGet() + .WithConfigKey("repositoryPath") + .Run(output => repositoryPath = output.Line).EnsureSuccess(); diff --git a/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetNuGetConfigPathsScenario.txt b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetNuGetConfigPathsScenario.txt new file mode 100644 index 00000000..7340e55f --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetNuGetConfigPathsScenario.txt @@ -0,0 +1,5 @@ +using HostApi; + +var configPaths = new List(); +new DotNetNuGetConfigPaths() + .Run(output => configPaths.Add(output.Line)).EnsureSuccess(); diff --git a/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetNuGetConfigSetScenario.txt b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetNuGetConfigSetScenario.txt new file mode 100644 index 00000000..9af47856 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetNuGetConfigSetScenario.txt @@ -0,0 +1,7 @@ +using HostApi; + +new DotNetNuGetConfigSet() + .WithConfigFile(configFile) + .WithConfigKey("repositoryPath") + .WithConfigValue("MyValue") + .Run().EnsureSuccess(); diff --git a/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetNuGetConfigUnsetScenario.txt b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetNuGetConfigUnsetScenario.txt new file mode 100644 index 00000000..5ff4cb94 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetNuGetConfigUnsetScenario.txt @@ -0,0 +1,5 @@ +using HostApi; + +new DotNetNuGetConfigUnset() + .WithConfigKey("repositoryPath") + .Run().EnsureSuccess(); diff --git a/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetNuGetDeleteScenario.txt b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetNuGetDeleteScenario.txt new file mode 100644 index 00000000..122c4eee --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetNuGetDeleteScenario.txt @@ -0,0 +1,7 @@ +using HostApi; + +new DotNetNuGetDelete() + .WithPackage("MyLib") + .WithPackageVersion("1.0.0") + .WithSource(repoUrl) + .Run().EnsureSuccess(); diff --git a/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetNuGetDisableSourceScenario.txt b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetNuGetDisableSourceScenario.txt new file mode 100644 index 00000000..61986e64 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetNuGetDisableSourceScenario.txt @@ -0,0 +1,5 @@ +using HostApi; + +new DotNetNuGetDisableSource() + .WithName("TestSource") + .Run().EnsureSuccess(); diff --git a/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetNuGetEnableSourceScenario.txt b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetNuGetEnableSourceScenario.txt new file mode 100644 index 00000000..6047c05d --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetNuGetEnableSourceScenario.txt @@ -0,0 +1,5 @@ +using HostApi; + +new DotNetNuGetEnableSource() + .WithName("TestSource") + .Run().EnsureSuccess(); diff --git a/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetNuGetListSourceScenario.txt b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetNuGetListSourceScenario.txt new file mode 100644 index 00000000..9c8dfe26 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetNuGetListSourceScenario.txt @@ -0,0 +1,5 @@ +using HostApi; + +new DotNetNuGetListSource() + .WithFormat(NuGetListFormat.Short) + .Run().EnsureSuccess(); diff --git a/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetNuGetLocalsClearScenario.txt b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetNuGetLocalsClearScenario.txt new file mode 100644 index 00000000..a6272b94 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetNuGetLocalsClearScenario.txt @@ -0,0 +1,5 @@ +using HostApi; + +new DotNetNuGetLocalsClear() + .WithCacheLocation(NuGetCacheLocation.Temp) + .Run().EnsureSuccess(); diff --git a/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetNuGetLocalsListScenario.txt b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetNuGetLocalsListScenario.txt new file mode 100644 index 00000000..c6fa9224 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetNuGetLocalsListScenario.txt @@ -0,0 +1,5 @@ +using HostApi; + +new DotNetNuGetLocalsList() + .WithCacheLocation(NuGetCacheLocation.GlobalPackages) + .Run().EnsureSuccess(); diff --git a/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetNuGetPushScenario.txt b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetNuGetPushScenario.txt new file mode 100644 index 00000000..5799a682 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetNuGetPushScenario.txt @@ -0,0 +1,7 @@ +using HostApi; + +new DotNetNuGetPush() + .WithWorkingDirectory("MyLib") + .WithPackage(Path.Combine("packages", "MyLib.1.0.0.nupkg")) + .WithSource(repoUrl) + .Run().EnsureSuccess(); diff --git a/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetNuGetRemoveSourceScenario.txt b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetNuGetRemoveSourceScenario.txt new file mode 100644 index 00000000..860d0415 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetNuGetRemoveSourceScenario.txt @@ -0,0 +1,5 @@ +using HostApi; + +new DotNetNuGetRemoveSource() + .WithName("TestSource") + .Run().EnsureSuccess(); diff --git a/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetNuGetSignScenario.txt b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetNuGetSignScenario.txt new file mode 100644 index 00000000..9c8723c7 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetNuGetSignScenario.txt @@ -0,0 +1,8 @@ +using HostApi; + +new DotNetNuGetSign() + .AddPackages("MyLib.1.2.3.nupkg") + .WithCertificatePath("certificate.pfx") + .WithCertificatePassword("Abc") + .WithTimestampingServer("http://timestamp.digicert.com/") + .Run().EnsureSuccess(); diff --git a/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetNuGetUpdateSourceScenario.txt b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetNuGetUpdateSourceScenario.txt new file mode 100644 index 00000000..93e43ec8 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetNuGetUpdateSourceScenario.txt @@ -0,0 +1,6 @@ +using HostApi; + +new DotNetNuGetUpdateSource() + .WithName("TestSource") + .WithSource(newSource) + .Run().EnsureSuccess(); diff --git a/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetNuGetWhyScenario.txt b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetNuGetWhyScenario.txt new file mode 100644 index 00000000..246b4f2a --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetNuGetWhyScenario.txt @@ -0,0 +1,6 @@ +using HostApi; + +new DotNetNuGetWhy() + .WithProject(Path.Combine("MyLib", "MyLib.csproj")) + .WithPackage("MyLib.1.2.3.nupkg") + .Run().EnsureSuccess(); diff --git a/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetPackScenario.txt b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetPackScenario.txt new file mode 100644 index 00000000..95549bdd --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetPackScenario.txt @@ -0,0 +1,8 @@ +using HostApi; + +// Creates a NuGet package of version 1.2.3 for the project +new DotNetPack() + .WithWorkingDirectory("MyLib") + .WithOutput(path) + .AddProps(("version", "1.2.3")) + .Build().EnsureSuccess(); diff --git a/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetPackageSearchScenario.txt b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetPackageSearchScenario.txt new file mode 100644 index 00000000..f0400523 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetPackageSearchScenario.txt @@ -0,0 +1,26 @@ +using System.Text; +using System.Text.Json; +using HostApi; + +var packagesJson = new StringBuilder(); +new DotNetPackageSearch() + .WithSearchTerm("Pure.DI") + .WithFormat(DotNetPackageSearchResultFormat.Json) + .Run(output => packagesJson.AppendLine(output.Line)).EnsureSuccess(); + +var result = JsonSerializer.Deserialize( + packagesJson.ToString(), + new JsonSerializerOptions { PropertyNameCaseInsensitive = true }); + +result.ShouldNotBeNull(); +result.SearchResult.SelectMany(i => i.Packages).Count(i => i.Id == "Pure.DI").ShouldBe(1); + +record Result(int Version, IReadOnlyCollection SearchResult); + +record Source(string SourceName, IReadOnlyCollection Packages); + +record Package( + string Id, + string LatestVersion, + int TotalDownloads, + string Owners); diff --git a/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetPublishScenario.txt b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetPublishScenario.txt new file mode 100644 index 00000000..8a53a739 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetPublishScenario.txt @@ -0,0 +1,7 @@ +using HostApi; + +new DotNetPublish() + .WithWorkingDirectory("MyLib") + .WithFramework("net8.0") + .WithOutput("bin") + .Build().EnsureSuccess(); diff --git a/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetRemovePackageScenario.txt b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetRemovePackageScenario.txt new file mode 100644 index 00000000..1b2a585d --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetRemovePackageScenario.txt @@ -0,0 +1,11 @@ +using HostApi; + +new DotNetAddPackage() + .WithWorkingDirectory("MyLib") + .WithPackage("Pure.DI") + .Run().EnsureSuccess(); + +new DotNetRemovePackage() + .WithWorkingDirectory("MyLib") + .WithPackage("Pure.DI") + .Run().EnsureSuccess(); diff --git a/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetRemoveReferenceScenario.txt b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetRemoveReferenceScenario.txt new file mode 100644 index 00000000..1a4c0934 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetRemoveReferenceScenario.txt @@ -0,0 +1,18 @@ +using HostApi; + +new DotNetAddReference() + .WithProject(Path.Combine("MyTests", "MyTests.csproj")) + .WithReferences(Path.Combine("MyLib", "MyLib.csproj")) + .Run().EnsureSuccess(); + +new DotNetRemoveReference() + .WithProject(Path.Combine("MyTests", "MyTests.csproj")) + .WithReferences(Path.Combine("MyLib", "MyLib.csproj")) + .Run().EnsureSuccess(); + +var lines = new List(); +new DotNetListReference() + .WithProject(Path.Combine("MyTests", "MyTests.csproj")) + .Run(output => lines.Add(output.Line)); + +lines.Any(i => i.Contains("MyLib.csproj")).ShouldBeFalse(); diff --git a/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetRestoreScenario.txt b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetRestoreScenario.txt new file mode 100644 index 00000000..cbd4e0a0 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetRestoreScenario.txt @@ -0,0 +1,5 @@ +using HostApi; + +new DotNetRestore() + .WithProject(Path.Combine("MyLib", "MyLib.csproj")) + .Build().EnsureSuccess(); diff --git a/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetRunScenario.txt b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetRunScenario.txt new file mode 100644 index 00000000..1ff92911 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetRunScenario.txt @@ -0,0 +1,10 @@ +using HostApi; + +var stdOut = new List(); +new DotNetRun() + .WithProject(Path.Combine("MyApp", "MyApp.csproj")) + .Build(message => stdOut.Add(message.Text)) + .EnsureSuccess(); + +// Checks stdOut +stdOut.ShouldBe(new[] {"Hello, World!"}); diff --git a/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetScenario.txt b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetScenario.txt new file mode 100644 index 00000000..00589f5e --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetScenario.txt @@ -0,0 +1,6 @@ +// Adds the namespace "HostApi" to use .NET build API +using HostApi; + +new DotNet() + .WithPathToApplication(Path.Combine(path, "MyApp.dll")) + .Run().EnsureSuccess(); diff --git a/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetSdkCheckScenario.txt b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetSdkCheckScenario.txt new file mode 100644 index 00000000..a8ab6bf0 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetSdkCheckScenario.txt @@ -0,0 +1,20 @@ +using HostApi; + +var sdks = new List(); +new DotNetSdkCheck() + .Run(output => + { + if (output.Line.StartsWith("Microsoft.")) + { + var data = output.Line.Split(' ', StringSplitOptions.RemoveEmptyEntries); + if (data.Length >= 2) + { + sdks.Add(new Sdk(data[0], NuGetVersion.Parse(data[1]))); + } + } + }) + .EnsureSuccess(); + +sdks.Count.ShouldBeGreaterThan(0); + +record Sdk(string Name, NuGetVersion Version); diff --git a/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetSlnAddScenario.txt b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetSlnAddScenario.txt new file mode 100644 index 00000000..38ab75e7 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetSlnAddScenario.txt @@ -0,0 +1,14 @@ +using HostApi; + +new DotNetNew() + .WithTemplateName("sln") + .WithName("NySolution") + .WithForce(true) + .Run().EnsureSuccess(); + +new DotNetSlnAdd() + .WithSolution("NySolution.sln") + .AddProjects( + Path.Combine("MyLib", "MyLib.csproj"), + Path.Combine("MyTests", "MyTests.csproj")) + .Run().EnsureSuccess(); diff --git a/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetSlnListScenario.txt b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetSlnListScenario.txt new file mode 100644 index 00000000..cc048099 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetSlnListScenario.txt @@ -0,0 +1,7 @@ +using HostApi; + +var lines = new List(); +new DotNetSlnList() + .WithSolution("NySolution.sln") + .Run(output => lines.Add(output.Line)) + .EnsureSuccess(); diff --git a/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetSlnRemoveScenario.txt b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetSlnRemoveScenario.txt new file mode 100644 index 00000000..4e7ab827 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetSlnRemoveScenario.txt @@ -0,0 +1,7 @@ +using HostApi; + +new DotNetSlnRemove() + .WithSolution("NySolution.sln") + .AddProjects( + Path.Combine("MyLib", "MyLib.csproj")) + .Run().EnsureSuccess(); diff --git a/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetStoreScenario.txt b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetStoreScenario.txt new file mode 100644 index 00000000..92c81541 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetStoreScenario.txt @@ -0,0 +1,8 @@ +using HostApi; + +new DotNetStore() + .AddManifests(Path.Combine("MyLib", "MyLib.csproj")) + .WithFramework("net8.0") + .WithRuntime("win-x64") + .Build(); + diff --git a/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetTestScenario.txt b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetTestScenario.txt new file mode 100644 index 00000000..4690f8de --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetTestScenario.txt @@ -0,0 +1,11 @@ +using HostApi; + +// Runs tests +var result = new DotNetTest() + .WithWorkingDirectory("MyTests") + .Build().EnsureSuccess(); + +// The "result" variable provides details about build and tests +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()); diff --git a/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetTestWithDotCoverScenario.txt b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetTestWithDotCoverScenario.txt new file mode 100644 index 00000000..10975d9b --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetTestWithDotCoverScenario.txt @@ -0,0 +1,35 @@ +using HostApi; + +new DotNetToolInstall() + .WithLocal(true) + .WithPackage("JetBrains.dotCover.GlobalTool") + .Run().EnsureSuccess(); + +// Creates a test command +var test = new DotNetTest() + .WithProject("MyTests"); + +var dotCoverSnapshot = Path.Combine("MyTests", "dotCover.dcvr"); +var dotCoverReport = Path.Combine("MyTests", "dotCover.html"); +// Modifies the test command by putting "dotCover" in front of all arguments +// to have something like "dotnet dotcover test ..." +// and adding few specific arguments to the end +var testUnderDotCover = test.Customize(cmd => + cmd.ClearArgs() + + "dotcover" + + cmd.Args + + $"--dcOutput={dotCoverSnapshot}" + + "--dcFilters=+:module=TeamCity.CSharpInteractive.HostApi;+:module=dotnet-csi" + + "--dcAttributeFilters=System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage"); + +// Runs tests under dotCover +var result = testUnderDotCover + .Build().EnsureSuccess(); + +// The "result" variable provides details about a build +result.ExitCode.ShouldBe(0, result.ToString()); +result.Tests.Count(i => i.State == TestState.Finished).ShouldBe(1, result.ToString()); + +// Generates a HTML code coverage report. +new DotNetCustom("dotCover", "report", $"--source={dotCoverSnapshot}", $"--output={dotCoverReport}", "--reportType=HTML") + .Run().EnsureSuccess(); diff --git a/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetToolInstallScenario.txt b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetToolInstallScenario.txt new file mode 100644 index 00000000..269d2064 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetToolInstallScenario.txt @@ -0,0 +1,6 @@ +using HostApi; + +new DotNetToolInstall() + .WithLocal(true) + .WithPackage("dotnet-csi") + .Run().EnsureSuccess(); diff --git a/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetToolListScenario.txt b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetToolListScenario.txt new file mode 100644 index 00000000..b3fd79fc --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetToolListScenario.txt @@ -0,0 +1,9 @@ +using HostApi; + +new DotNetToolList() + .WithLocal(true) + .Run().EnsureSuccess(); + +new DotNetToolList() + .WithGlobal(true) + .Run().EnsureSuccess(); diff --git a/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetToolRestoreScenario.txt b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetToolRestoreScenario.txt new file mode 100644 index 00000000..46e16809 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetToolRestoreScenario.txt @@ -0,0 +1,9 @@ +using HostApi; + +// Creates a local tool manifest +new DotNetNew() + .WithTemplateName("tool-manifest") + .Run().EnsureSuccess(); + +new DotNetToolRestore() + .Run().EnsureSuccess(); diff --git a/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetToolRunScenario.txt b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetToolRunScenario.txt new file mode 100644 index 00000000..e8296035 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetToolRunScenario.txt @@ -0,0 +1,15 @@ +using HostApi; + +var script = Path.GetTempFileName(); +File.WriteAllText(script, "Console.WriteLine($\"Hello, {Args[0]}!\");"); + +var stdOut = new List(); +new DotNetToolRun() + .WithCommandName("dotnet-csi") + .AddArgs(script) + .AddArgs("World") + .Run(output => stdOut.Add(output.Line)) + .EnsureSuccess(); + +// Checks stdOut +stdOut.Contains("Hello, World!").ShouldBeTrue(); diff --git a/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetToolSearchScenario.txt b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetToolSearchScenario.txt new file mode 100644 index 00000000..2ca26de4 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetToolSearchScenario.txt @@ -0,0 +1,6 @@ +using HostApi; + +new DotNetToolSearch() + .WithPackage("dotnet-csi") + .WithDetail(true) + .Run().EnsureSuccess(); diff --git a/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetToolUninstallScenario.txt b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetToolUninstallScenario.txt new file mode 100644 index 00000000..bfd6de5b --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetToolUninstallScenario.txt @@ -0,0 +1,5 @@ +using HostApi; + +new DotNetToolUninstall() + .WithPackage("dotnet-csi") + .Run().EnsureSuccess(); diff --git a/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetToolUpdateScenario.txt b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetToolUpdateScenario.txt new file mode 100644 index 00000000..e84f9791 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetToolUpdateScenario.txt @@ -0,0 +1,6 @@ +using HostApi; + +new DotNetToolUpdate() + .WithLocal(true) + .WithPackage("dotnet-csi") + .Run().EnsureSuccess(); diff --git a/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetVSTestScenario.txt b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetVSTestScenario.txt new file mode 100644 index 00000000..2e0886b2 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetVSTestScenario.txt @@ -0,0 +1,12 @@ +using HostApi; + +// Runs tests +var result = new VSTest() + .AddTestFileNames(Path.Combine("bin", "MyTests.dll")) + .WithWorkingDirectory(path) + .Build().EnsureSuccess(); + +// The "result" variable provides details about build and tests +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()); diff --git a/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetWorkloadConfigScenario.txt b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetWorkloadConfigScenario.txt new file mode 100644 index 00000000..f293be89 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetWorkloadConfigScenario.txt @@ -0,0 +1,5 @@ +using HostApi; + +new DotNetWorkloadConfig() + .WithUpdateMode(DotNetWorkloadUpdateMode.WorkloadSet) + .Run().EnsureSuccess(); diff --git a/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetWorkloadInstallScenario.txt b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetWorkloadInstallScenario.txt new file mode 100644 index 00000000..8948511d --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetWorkloadInstallScenario.txt @@ -0,0 +1,5 @@ +using HostApi; + +new DotNetWorkloadInstall() + .AddWorkloads("aspire") + .Run().EnsureSuccess(); diff --git a/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetWorkloadListScenario.txt b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetWorkloadListScenario.txt new file mode 100644 index 00000000..59ad11dc --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetWorkloadListScenario.txt @@ -0,0 +1,4 @@ +using HostApi; + +new DotNetWorkloadList() + .Run().EnsureSuccess(); diff --git a/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetWorkloadRepairScenario.txt b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetWorkloadRepairScenario.txt new file mode 100644 index 00000000..4a8a633c --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetWorkloadRepairScenario.txt @@ -0,0 +1,4 @@ +using HostApi; + +new DotNetWorkloadRepair() + .Run().EnsureSuccess(); diff --git a/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetWorkloadRestoreScenario.txt b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetWorkloadRestoreScenario.txt new file mode 100644 index 00000000..b56e21c5 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetWorkloadRestoreScenario.txt @@ -0,0 +1,5 @@ +using HostApi; + +new DotNetWorkloadRestore() + .WithProject(Path.Combine("MyLib", "MyLib.csproj")) + .Run().EnsureSuccess(); diff --git a/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetWorkloadSearchScenario.txt b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetWorkloadSearchScenario.txt new file mode 100644 index 00000000..4fcecfc9 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetWorkloadSearchScenario.txt @@ -0,0 +1,5 @@ +using HostApi; + +new DotNetWorkloadSearch() + .WithSearchString("maui") + .Run().EnsureSuccess(); diff --git a/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetWorkloadUninstallScenario.txt b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetWorkloadUninstallScenario.txt new file mode 100644 index 00000000..033d425d --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetWorkloadUninstallScenario.txt @@ -0,0 +1,5 @@ +using HostApi; + +new DotNetWorkloadUninstall() + .AddWorkloads("aspire") + .Run().EnsureSuccess(); diff --git a/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetWorkloadUpdateScenario.txt b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetWorkloadUpdateScenario.txt new file mode 100644 index 00000000..088746d4 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/Comments/DotNetWorkloadUpdateScenario.txt @@ -0,0 +1,4 @@ +using HostApi; + +new DotNetWorkloadUpdate() + .Run().EnsureSuccess(); diff --git a/CSharpInteractive.Tests/UsageScenarios/Comments/GetServiceScenario.txt b/CSharpInteractive.Tests/UsageScenarios/Comments/GetServiceScenario.txt new file mode 100644 index 00000000..d64ed0fb --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/Comments/GetServiceScenario.txt @@ -0,0 +1,4 @@ +GetService(); + +var serviceProvider = GetService(); +serviceProvider.GetService(typeof(INuGet)); diff --git a/CSharpInteractive.Tests/UsageScenarios/Comments/HostScenario.txt b/CSharpInteractive.Tests/UsageScenarios/Comments/HostScenario.txt new file mode 100644 index 00000000..d7e1ca68 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/Comments/HostScenario.txt @@ -0,0 +1,2 @@ +var packages = Host.GetService(); +Host.WriteLine("Hello"); diff --git a/CSharpInteractive.Tests/UsageScenarios/Comments/LogErrorScenario.txt b/CSharpInteractive.Tests/UsageScenarios/Comments/LogErrorScenario.txt new file mode 100644 index 00000000..eede6e08 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/Comments/LogErrorScenario.txt @@ -0,0 +1 @@ +Error("Error info", "Error identifier"); diff --git a/CSharpInteractive.Tests/UsageScenarios/Comments/LogInfoScenario.txt b/CSharpInteractive.Tests/UsageScenarios/Comments/LogInfoScenario.txt new file mode 100644 index 00000000..d2d25ecb --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/Comments/LogInfoScenario.txt @@ -0,0 +1 @@ +Info("Some info"); diff --git a/CSharpInteractive.Tests/UsageScenarios/Comments/LogTraceScenario.txt b/CSharpInteractive.Tests/UsageScenarios/Comments/LogTraceScenario.txt new file mode 100644 index 00000000..3761cd7f --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/Comments/LogTraceScenario.txt @@ -0,0 +1 @@ +Trace("Some trace info"); diff --git a/CSharpInteractive.Tests/UsageScenarios/Comments/LogWarningScenario.txt b/CSharpInteractive.Tests/UsageScenarios/Comments/LogWarningScenario.txt new file mode 100644 index 00000000..063bbaeb --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/Comments/LogWarningScenario.txt @@ -0,0 +1 @@ +Warning("Warning info"); diff --git a/CSharpInteractive.Tests/UsageScenarios/Comments/MSBuildScenario.txt b/CSharpInteractive.Tests/UsageScenarios/Comments/MSBuildScenario.txt new file mode 100644 index 00000000..9ef915ba --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/Comments/MSBuildScenario.txt @@ -0,0 +1,21 @@ +using HostApi; + +// Creates a new library project, running a command like: "dotnet new classlib -n MyLib --force" +new DotNetNew() + .WithTemplateName("classlib") + .WithName("MyLib") + .WithForce(true) + .Build().EnsureSuccess(); + +// Builds the library project, running a command like: "dotnet msbuild /t:Build -restore /p:configuration=Release -verbosity=detailed" from the directory "MyLib" +var result = new MSBuild() + .WithWorkingDirectory("MyLib") + .WithTarget("Build") + .WithRestore(true) + .AddProps(("configuration", "Release")) + .WithVerbosity(DotNetVerbosity.Detailed) + .Build().EnsureSuccess(); + +// The "result" variable provides details about a build +result.Errors.Any(message => message.State == BuildMessageState.StdError).ShouldBeFalse(result.ToString()); +result.ExitCode.ShouldBe(0, result.ToString()); diff --git a/CSharpInteractive.Tests/UsageScenarios/Comments/NuGetRestoreAdvanced.txt b/CSharpInteractive.Tests/UsageScenarios/Comments/NuGetRestoreAdvanced.txt new file mode 100644 index 00000000..bce0d658 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/Comments/NuGetRestoreAdvanced.txt @@ -0,0 +1,12 @@ +using HostApi; + +var packagesPath = Path.Combine( + Path.GetTempPath(), + Guid.NewGuid().ToString()[..4]); + +var settings = new NuGetRestoreSettings("IoC.Container") + .WithVersionRange(VersionRange.Parse("[1.3, 1.3.8)")) + .WithTargetFrameworkMoniker("net5.0") + .WithPackagesPath(packagesPath); + +IEnumerable packages = GetService().Restore(settings); diff --git a/CSharpInteractive.Tests/UsageScenarios/Comments/NuGetRestoreScenario.txt b/CSharpInteractive.Tests/UsageScenarios/Comments/NuGetRestoreScenario.txt new file mode 100644 index 00000000..6d9c9584 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/Comments/NuGetRestoreScenario.txt @@ -0,0 +1,4 @@ +using HostApi; + +IEnumerable packages = GetService() + .Restore(new NuGetRestoreSettings("IoC.Container").WithVersionRange(VersionRange.All)); diff --git a/CSharpInteractive.Tests/UsageScenarios/Comments/PropsScenario.txt b/CSharpInteractive.Tests/UsageScenarios/Comments/PropsScenario.txt new file mode 100644 index 00000000..d01ce035 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/Comments/PropsScenario.txt @@ -0,0 +1,6 @@ +WriteLine(Props["version"]); +WriteLine(Props.Get("configuration", "Release")); + +// Some CI/CDs have integration of these properties. +// For example in TeamCity this property with all changes will be available in the next TeamCity steps. +Props["version"] = "1.1.6"; diff --git a/CSharpInteractive.Tests/UsageScenarios/Comments/ServiceCollectionScenario.txt b/CSharpInteractive.Tests/UsageScenarios/Comments/ServiceCollectionScenario.txt new file mode 100644 index 00000000..e1b1b913 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/Comments/ServiceCollectionScenario.txt @@ -0,0 +1,20 @@ +public void Run() +{ + var serviceProvider = + GetService() + .AddTransient() + .BuildServiceProvider(); + + var myTask = serviceProvider.GetRequiredService(); + var exitCode = myTask.Run(); + exitCode.ShouldBe(0); +} + +private class MyTask(ICommandLineRunner runner) +{ + public int? Run() => runner + .Run(new CommandLine("whoami")) + .EnsureSuccess() + .ExitCode; +} + diff --git a/CSharpInteractive.Tests/UsageScenarios/Comments/TeamCityServiceMessagesScenario.txt b/CSharpInteractive.Tests/UsageScenarios/Comments/TeamCityServiceMessagesScenario.txt new file mode 100644 index 00000000..69611885 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/Comments/TeamCityServiceMessagesScenario.txt @@ -0,0 +1,18 @@ +// Adds a namespace to use ITeamCityWriter +using JetBrains.TeamCity.ServiceMessages.Write.Special; + +using var writer = GetService(); +using (var tests = writer.OpenBlock("My Tests")) +{ + using (var test = tests.OpenTest("Test1")) + { + test.WriteStdOutput("Hello"); + test.WriteImage("TestsResults/Test1Screenshot.jpg", "Screenshot"); + test.WriteDuration(TimeSpan.FromMilliseconds(10)); + } + + using (var test = tests.OpenTest("Test2")) + { + test.WriteIgnored("Some reason"); + } +} diff --git a/CSharpInteractive.Tests/UsageScenarios/Comments/WriteEmptyLineScenario.txt b/CSharpInteractive.Tests/UsageScenarios/Comments/WriteEmptyLineScenario.txt new file mode 100644 index 00000000..448b0400 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/Comments/WriteEmptyLineScenario.txt @@ -0,0 +1 @@ +WriteLine(); diff --git a/CSharpInteractive.Tests/UsageScenarios/Comments/WriteLineScenario.txt b/CSharpInteractive.Tests/UsageScenarios/Comments/WriteLineScenario.txt new file mode 100644 index 00000000..7f4afc14 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/Comments/WriteLineScenario.txt @@ -0,0 +1 @@ +WriteLine("Hello"); diff --git a/CSharpInteractive.Tests/UsageScenarios/Comments/WriteLineWithColourScenario.txt b/CSharpInteractive.Tests/UsageScenarios/Comments/WriteLineWithColourScenario.txt new file mode 100644 index 00000000..15d058b1 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/Comments/WriteLineWithColourScenario.txt @@ -0,0 +1 @@ +WriteLine("Hello", Header); diff --git a/CSharpInteractive.Tests/UsageScenarios/DockerDotNetBuildScenario.cs b/CSharpInteractive.Tests/UsageScenarios/DockerDotNetBuildScenario.cs index 10162bcb..48210256 100644 --- a/CSharpInteractive.Tests/UsageScenarios/DockerDotNetBuildScenario.cs +++ b/CSharpInteractive.Tests/UsageScenarios/DockerDotNetBuildScenario.cs @@ -3,16 +3,16 @@ // ReSharper disable ReturnValueOfPureMethodIsNotUsed // ReSharper disable SeparateLocalFunctionsWithJumpStatement +// ReSharper disable MoveLocalFunctionAfterJumpStatement namespace CSharpInteractive.Tests.UsageScenarios; using System; using System.Diagnostics.CodeAnalysis; -using HostApi; [CollectionDefinition("Integration", DisableParallelization = true)] -[Trait("Integration", "true")] -[Trait("Docker", "true")] -public class DockerDotNetBuildScenario : BaseScenario +[Trait("Integration", "True")] +[Trait("Docker", "True")] +public class DockerDotNetBuildScenario(ITestOutputHelper output) : BaseScenario(output) { //[Fact(Skip = "Linux Docker only")] [SuppressMessage("Usage", "xUnit1004:Test methods should not be skipped")] @@ -24,7 +24,6 @@ public void Run() // $priority=01 // $description=Build a project in a docker container // { - // Adds the namespace "HostApi" to use .NET build API and Docker API // ## using HostApi; // Creates a base docker command line @@ -36,25 +35,21 @@ public void Run() .WithContainerWorkingDirectory("/MyProjects") .AddVolumes((ToAbsoluteLinuxPath(Environment.CurrentDirectory), "/MyProjects")); - // Creates a new library project in a docker container dockerRun .WithCommandLine(new DotNetCustom("new", "classlib", "-n", "MyLib", "--force")) - .Run() - .EnsureSuccess(); + .Run().EnsureSuccess(); // Builds the library project in a docker container var result = dockerRun .WithCommandLine(new DotNetBuild().WithProject("MyLib/MyLib.csproj")) - .Build() - .EnsureSuccess(); - - // The "result" variable provides details about a build - result.Errors.Any(message => message.State == BuildMessageState.StdError).ShouldBeFalse(); - result.ExitCode.ShouldBe(0); + .Build().EnsureSuccess(); string ToAbsoluteLinuxPath(string path) => "/" + path.Replace(":", "").Replace('\\', '/'); // } + + // The "result" variable provides details about a build + result.Errors.Any(message => message.State == BuildMessageState.StdError).ShouldBeFalse(result.ToString()); } } \ No newline at end of file diff --git a/CSharpInteractive.Tests/UsageScenarios/DockerRunScenario.cs b/CSharpInteractive.Tests/UsageScenarios/DockerRunScenario.cs index 8532aeeb..fccd2998 100644 --- a/CSharpInteractive.Tests/UsageScenarios/DockerRunScenario.cs +++ b/CSharpInteractive.Tests/UsageScenarios/DockerRunScenario.cs @@ -4,12 +4,10 @@ namespace CSharpInteractive.Tests.UsageScenarios; -using HostApi; - [CollectionDefinition("Integration", DisableParallelization = true)] -[Trait("Integration", "true")] -[Trait("Docker", "true")] -public class DockerRunScenario : BaseScenario +[Trait("Integration", "True")] +[Trait("Docker", "True")] +public class DockerRunScenario(ITestOutputHelper output) : BaseScenario(output) { [Fact] public void Run() @@ -19,7 +17,6 @@ public void Run() // $priority=01 // $description=Running in docker // { - // Adds the namespace "HostApi" to use Command Line API and Docker API // ## using HostApi; // Creates some command line to run in a docker container @@ -28,10 +25,7 @@ public void Run() // Runs the command line in a docker container var result = new DockerRun(cmd, "mcr.microsoft.com/dotnet/sdk") .WithAutoRemove(true) - .Run() - .EnsureSuccess(); + .Run().EnsureSuccess(); // } - - result.ExitCode.ShouldBe(0); } } \ No newline at end of file diff --git a/CSharpInteractive.Tests/UsageScenarios/DotNetAddPackageScenario.cs b/CSharpInteractive.Tests/UsageScenarios/DotNetAddPackageScenario.cs new file mode 100644 index 00000000..994fda3b --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/DotNetAddPackageScenario.cs @@ -0,0 +1,42 @@ +// ReSharper disable StringLiteralTypo +// ReSharper disable ObjectCreationAsStatement +// ReSharper disable ReturnValueOfPureMethodIsNotUsed +// ReSharper disable CommentTypo + +namespace CSharpInteractive.Tests.UsageScenarios; + +[CollectionDefinition("Integration", DisableParallelization = true)] +[Trait("Integration", "True")] +public class DotNetAddPackageScenario(ITestOutputHelper output) : BaseScenario(output) +{ + [Fact] + public void Run() + { + new DotNetNew() + .WithTemplateName("classlib") + .WithName("MyLib") + .WithForce(true) + .Run().EnsureSuccess(); + + // $visible=true + // $tag=07 .NET CLI + // $priority=01 + // $description=Adding a NuGet package + // { + // ## using HostApi; + + var result = new DotNetAddPackage() + .WithWorkingDirectory("MyLib") + .WithPackage("Pure.DI") + .Run().EnsureSuccess(); + // } + + var lines = new List(); + new DotNetListPackage() + .WithWorkingDirectory("MyLib") + .WithVerbosity(DotNetVerbosity.Minimal) + .Run(output => lines.Add(output.Line)); + + lines.Any(i => i.Contains("Pure.DI")).ShouldBeTrue(result.ToString()); + } +} \ No newline at end of file diff --git a/CSharpInteractive.Tests/UsageScenarios/DotNetAddReferenceScenario.cs b/CSharpInteractive.Tests/UsageScenarios/DotNetAddReferenceScenario.cs new file mode 100644 index 00000000..1c586e28 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/DotNetAddReferenceScenario.cs @@ -0,0 +1,48 @@ +// ReSharper disable StringLiteralTypo +// ReSharper disable ObjectCreationAsStatement +// ReSharper disable ReturnValueOfPureMethodIsNotUsed +// ReSharper disable CommentTypo + +namespace CSharpInteractive.Tests.UsageScenarios; + +[CollectionDefinition("Integration", DisableParallelization = true)] +[Trait("Integration", "True")] +public class DotNetAddReferenceScenario(ITestOutputHelper output) : BaseScenario(output) +{ + [Fact] + public void Run() + { + new DotNetNew() + .WithTemplateName("classlib") + .WithName("MyLib") + .WithForce(true) + .Run().EnsureSuccess(); + + new DotNetNew() + .WithTemplateName("xunit") + .WithName("MyTests") + .WithForce(true) + .Run().EnsureSuccess(); + + // $visible=true + // $tag=07 .NET CLI + // $priority=01 + // $description=Adding a NuGet package + // { + // ## using HostApi; + + var result = new DotNetAddReference() + .WithProject(Path.Combine("MyTests", "MyTests.csproj")) + .WithReferences(Path.Combine("MyLib", "MyLib.csproj")) + .Run().EnsureSuccess(); + + // } + + var lines = new List(); + new DotNetListReference() + .WithProject(Path.Combine("MyTests", "MyTests.csproj")) + .Run(output => lines.Add(output.Line)); + + lines.Any(i => i.Contains("MyLib.csproj")).ShouldBeTrue(result.ToString()); + } +} \ No newline at end of file diff --git a/CSharpInteractive.Tests/UsageScenarios/DotNetBuildScenario.cs b/CSharpInteractive.Tests/UsageScenarios/DotNetBuildScenario.cs index 78b372fc..57012da0 100644 --- a/CSharpInteractive.Tests/UsageScenarios/DotNetBuildScenario.cs +++ b/CSharpInteractive.Tests/UsageScenarios/DotNetBuildScenario.cs @@ -5,47 +5,44 @@ namespace CSharpInteractive.Tests.UsageScenarios; -using HostApi; - [CollectionDefinition("Integration", DisableParallelization = true)] -[Trait("Integration", "true")] -public class DotNetBuildScenario : BaseScenario +[Trait("Integration", "True")] +public class DotNetBuildScenario(ITestOutputHelper output) : BaseScenario(output) { [Fact] public void Run() { + new DotNetNew() + .WithTemplateName("xunit") + .WithName("MyTests") + .WithForce(true) + .Run().EnsureSuccess(); + // $visible=true // $tag=07 .NET CLI // $priority=01 // $description=Build a project // { - // Adds the namespace "HostApi" to use .NET build API // ## 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(); - - // Builds the library project, running a command like: "dotnet build" from the directory "MyLib" + var messages = new List(); var result = new DotNetBuild() - .WithWorkingDirectory("MyLib") - .Build() - .EnsureSuccess(); - - // The "result" variable provides details about a build - result.Errors.Any(message => message.State == BuildMessageState.StdError).ShouldBeFalse(); - result.ExitCode.ShouldBe(0); + .WithWorkingDirectory("MyTests") + .Build(message => messages.Add(message)).EnsureSuccess(); + + result.Errors.Any(message => message.State == BuildMessageState.StdError).ShouldBeFalse(result.ToString()); + result.ExitCode.ShouldBe(0, result.ToString()); + // } + + messages.Count.ShouldBeGreaterThan(0, result.ToString()); + result.Errors.Any(message => message.State == BuildMessageState.StdError).ShouldBeFalse(result.ToString()); - // Runs tests in docker result = new DotNetTest() - .WithWorkingDirectory("MyLib") - .Build() - .EnsureSuccess(); - - result.ExitCode.ShouldBe(0); - result.Summary.Tests.ShouldBe(1); - result.Tests.Count(test => test.State == TestState.Finished).ShouldBe(1); - // } + .WithWorkingDirectory("MyTests") + .Build().EnsureSuccess(); + + 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()); } } \ No newline at end of file diff --git a/CSharpInteractive.Tests/UsageScenarios/DotNetBuildServerShutdownScenario.cs b/CSharpInteractive.Tests/UsageScenarios/DotNetBuildServerShutdownScenario.cs index f2c282b2..8d5c3359 100644 --- a/CSharpInteractive.Tests/UsageScenarios/DotNetBuildServerShutdownScenario.cs +++ b/CSharpInteractive.Tests/UsageScenarios/DotNetBuildServerShutdownScenario.cs @@ -4,11 +4,9 @@ namespace CSharpInteractive.Tests.UsageScenarios; -using HostApi; - [CollectionDefinition("Integration", DisableParallelization = true)] -[Trait("Integration", "true")] -public class DotNetBuildServerShutdownScenario : BaseScenario +[Trait("Integration", "True")] +public class DotNetBuildServerShutdownScenario(ITestOutputHelper output) : BaseScenario(output) { [Fact] public void Run() @@ -18,13 +16,11 @@ public void Run() // $priority=02 // $description=Shuts down build servers // { - // Adds the namespace "HostApi" to use .NET build API // ## using HostApi; // Shuts down all build servers that are started from dotnet. new DotNetBuildServerShutdown() - .Run() - .EnsureSuccess(); + .Run().EnsureSuccess(); // } } } \ No newline at end of file diff --git a/CSharpInteractive.Tests/UsageScenarios/DotNetCleanScenario.cs b/CSharpInteractive.Tests/UsageScenarios/DotNetCleanScenario.cs index 222bc9b8..27f2701f 100644 --- a/CSharpInteractive.Tests/UsageScenarios/DotNetCleanScenario.cs +++ b/CSharpInteractive.Tests/UsageScenarios/DotNetCleanScenario.cs @@ -5,46 +5,34 @@ namespace CSharpInteractive.Tests.UsageScenarios; -using HostApi; - [CollectionDefinition("Integration", DisableParallelization = true)] -[Trait("Integration", "true")] -public class DotNetCleanScenario : BaseScenario +[Trait("Integration", "True")] +public class DotNetCleanScenario(ITestOutputHelper output) : BaseScenario(output) { [Fact] public void Run() { + new DotNetNew() + .WithTemplateName("classlib") + .WithName("MyLib") + .WithForce(true) + .Run().EnsureSuccess(); + + new DotNetBuild() + .WithWorkingDirectory("MyLib") + .Build().EnsureSuccess(); + // $visible=true // $tag=07 .NET CLI // $priority=01 // $description=Clean a project // { - // Adds the namespace "HostApi" to use .NET build API // ## 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(); - - 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(); - - result.ExitCode.ShouldBe(0); - + // Clean the project, running a command like: "dotnet clean" from the directory "MyLib" - result = new DotNetClean() + new DotNetClean() .WithWorkingDirectory("MyLib") - .Build() - .EnsureSuccess(); - - // The "result" variable provides details about a build - result.ExitCode.ShouldBe(0); + .Build().EnsureSuccess(); // } } } \ No newline at end of file diff --git a/CSharpInteractive.Tests/UsageScenarios/DotNetCsiScenario.cs b/CSharpInteractive.Tests/UsageScenarios/DotNetCsiScenario.cs new file mode 100644 index 00000000..f8e28ae3 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/DotNetCsiScenario.cs @@ -0,0 +1,38 @@ +// ReSharper disable StringLiteralTypo +// ReSharper disable ObjectCreationAsStatement +// ReSharper disable ReturnValueOfPureMethodIsNotUsed + +namespace CSharpInteractive.Tests.UsageScenarios; + +using System.Diagnostics.CodeAnalysis; + +[CollectionDefinition("Integration", DisableParallelization = true)] +[Trait("Integration", "True")] +[SuppressMessage("Performance", "CA1861:Avoid constant arrays as arguments")] +public class DotNetCsiScenario(ITestOutputHelper output) : BaseScenario(output) +{ + [Fact] + public void Run() + { + // $visible=true + // $tag=07 .NET CLI + // $priority=02 + // $description=Run C# script + // { + // ## using HostApi; + + var script = Path.GetTempFileName(); + File.WriteAllText(script, "Console.WriteLine($\"Hello, {Args[0]}!\");"); + + var stdOut = new List(); + new DotNetCsi() + .WithScript(script) + .AddArgs("World") + .Run(output => stdOut.Add(output.Line)) + .EnsureSuccess(); + + // Checks stdOut + stdOut.Contains("Hello, World!").ShouldBeTrue(); + // } + } +} \ No newline at end of file diff --git a/CSharpInteractive.Tests/UsageScenarios/DotNetCustomScenario.cs b/CSharpInteractive.Tests/UsageScenarios/DotNetCustomScenario.cs index c4c59ad5..1ec1fcba 100644 --- a/CSharpInteractive.Tests/UsageScenarios/DotNetCustomScenario.cs +++ b/CSharpInteractive.Tests/UsageScenarios/DotNetCustomScenario.cs @@ -5,13 +5,12 @@ namespace CSharpInteractive.Tests.UsageScenarios; using System.Diagnostics.CodeAnalysis; -using HostApi; using NuGet.Versioning; [CollectionDefinition("Integration", DisableParallelization = true)] -[Trait("Integration", "true")] +[Trait("Integration", "True")] [SuppressMessage("Performance", "CA1806:Do not ignore method results")] -public class DotNetCustomScenario : BaseScenario +public class DotNetCustomScenario(ITestOutputHelper output) : BaseScenario(output) { [Fact] public void Run() @@ -21,7 +20,6 @@ public void Run() // $priority=01 // $description=Run a custom .NET command // { - // Adds the namespace "HostApi" to use .NET build API // ## using HostApi; // Gets the dotnet version, running a command like: "dotnet --version" diff --git a/CSharpInteractive.Tests/UsageScenarios/DotNetDevCertsHttpsScenario.cs b/CSharpInteractive.Tests/UsageScenarios/DotNetDevCertsHttpsScenario.cs new file mode 100644 index 00000000..ea103a1c --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/DotNetDevCertsHttpsScenario.cs @@ -0,0 +1,33 @@ +// ReSharper disable StringLiteralTypo +// ReSharper disable ObjectCreationAsStatement +// ReSharper disable ReturnValueOfPureMethodIsNotUsed + +namespace CSharpInteractive.Tests.UsageScenarios; + +using System.Diagnostics.CodeAnalysis; + +[CollectionDefinition("Integration", DisableParallelization = true)] +[Trait("Integration", "True")] +[SuppressMessage("Performance", "CA1861:Avoid constant arrays as arguments")] +public class DotNetDevCertsHttpsScenario(ITestOutputHelper output) : BaseScenario(output) +{ + [Fact] + public void Run() + { + // $visible=true + // $tag=07 .NET CLI + // $priority=01 + // $description=Working with development certificates + // { + // ## using HostApi; + + // Create a certificate, trust it, and export it to a PEM file. + new DotNetDevCertsHttps() + .WithExportPath("certificate.pem") + .WithTrust(true) + .WithFormat(DotNetCertificateFormat.Pem) + .WithPassword("Abc") + .Run().EnsureSuccess(); + // } + } +} \ No newline at end of file diff --git a/CSharpInteractive.Tests/UsageScenarios/DotNetExecScenario.cs b/CSharpInteractive.Tests/UsageScenarios/DotNetExecScenario.cs new file mode 100644 index 00000000..e534c8c8 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/DotNetExecScenario.cs @@ -0,0 +1,41 @@ +// ReSharper disable StringLiteralTypo +// ReSharper disable ObjectCreationAsStatement +// ReSharper disable ReturnValueOfPureMethodIsNotUsed + +namespace CSharpInteractive.Tests.UsageScenarios; + +using System.Diagnostics.CodeAnalysis; + +[CollectionDefinition("Integration", DisableParallelization = true)] +[Trait("Integration", "True")] +[SuppressMessage("Performance", "CA1861:Avoid constant arrays as arguments")] +public class DotNetExecScenario(ITestOutputHelper output) : BaseScenario(output) +{ + [Fact] + public void Run() + { + // Creates a new console project + new DotNetNew() + .WithTemplateName("console") + .WithName("MyApp") + .WithForce(true) + .Run().EnsureSuccess(); + + var path = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); + new DotNetPublish() + .WithWorkingDirectory("MyApp") + .WithOutput(path) + .Build().EnsureSuccess(); + + // $visible=true + // $tag=07 .NET CLI + // $priority=01 + // $description=Execute a dotnet application + // { + // ## using HostApi; + new DotNetExec() + .WithPathToApplication(Path.Combine(path, "MyApp.dll")) + .Run().EnsureSuccess(); + // } + } +} \ No newline at end of file diff --git a/CSharpInteractive.Tests/UsageScenarios/DotNetFormatAnalyzersScenario.cs b/CSharpInteractive.Tests/UsageScenarios/DotNetFormatAnalyzersScenario.cs new file mode 100644 index 00000000..bcb4e16c --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/DotNetFormatAnalyzersScenario.cs @@ -0,0 +1,36 @@ +// ReSharper disable StringLiteralTypo +// ReSharper disable ObjectCreationAsStatement +// ReSharper disable ReturnValueOfPureMethodIsNotUsed +// ReSharper disable CommentTypo + +namespace CSharpInteractive.Tests.UsageScenarios; + +[CollectionDefinition("Integration", DisableParallelization = true)] +[Trait("Integration", "True")] +public class DotNetFormatAnalyzersScenario(ITestOutputHelper output) : BaseScenario(output) +{ + [Fact] + public void Run() + { + new DotNetNew() + .WithTemplateName("classlib") + .WithName("MyLib") + .WithForce(true) + .Run().EnsureSuccess(); + + // $visible=true + // $tag=07 .NET CLI + // $priority=01 + // $description=Fix (non code style) analyzer issues + // { + // ## using HostApi; + + new DotNetFormatAnalyzers() + .WithWorkingDirectory("MyLib") + .WithProject("MyLib.csproj") + .AddDiagnostics("CA1831", "CA1832") + .WithSeverity(DotNetFormatSeverity.Warning) + .Run().EnsureSuccess(); + // } + } +} \ No newline at end of file diff --git a/CSharpInteractive.Tests/UsageScenarios/DotNetFormatScenario.cs b/CSharpInteractive.Tests/UsageScenarios/DotNetFormatScenario.cs new file mode 100644 index 00000000..8bcbbab1 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/DotNetFormatScenario.cs @@ -0,0 +1,38 @@ +// ReSharper disable StringLiteralTypo +// ReSharper disable ObjectCreationAsStatement +// ReSharper disable ReturnValueOfPureMethodIsNotUsed +// ReSharper disable CommentTypo + +namespace CSharpInteractive.Tests.UsageScenarios; + +[CollectionDefinition("Integration", DisableParallelization = true)] +[Trait("Integration", "True")] +public class DotNetFormatScenario(ITestOutputHelper output) : BaseScenario(output) +{ + [Fact] + public void Run() + { + new DotNetNew() + .WithTemplateName("classlib") + .WithName("MyLib") + .WithForce(true) + .Run().EnsureSuccess(); + + // $visible=true + // $tag=07 .NET CLI + // $priority=01 + // $description=Format a code + // { + // ## using HostApi; + + new DotNetFormat() + .WithWorkingDirectory("MyLib") + .WithProject("MyLib.csproj") + .AddDiagnostics("IDE0005", "IDE0006") + .AddIncludes(".", "./tests") + .AddExcludes("./obj") + .WithSeverity(DotNetFormatSeverity.Information) + .Run().EnsureSuccess(); + // } + } +} \ No newline at end of file diff --git a/CSharpInteractive.Tests/UsageScenarios/DotNetFormatStyleScenario.cs b/CSharpInteractive.Tests/UsageScenarios/DotNetFormatStyleScenario.cs new file mode 100644 index 00000000..f746e6ec --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/DotNetFormatStyleScenario.cs @@ -0,0 +1,36 @@ +// ReSharper disable StringLiteralTypo +// ReSharper disable ObjectCreationAsStatement +// ReSharper disable ReturnValueOfPureMethodIsNotUsed +// ReSharper disable CommentTypo + +namespace CSharpInteractive.Tests.UsageScenarios; + +[CollectionDefinition("Integration", DisableParallelization = true)] +[Trait("Integration", "True")] +public class DotNetFormatStyleScenario(ITestOutputHelper output) : BaseScenario(output) +{ + [Fact] + public void Run() + { + new DotNetNew() + .WithTemplateName("classlib") + .WithName("MyLib") + .WithForce(true) + .Run().EnsureSuccess(); + + // $visible=true + // $tag=07 .NET CLI + // $priority=01 + // $description=Fix code style issues + // { + // ## using HostApi; + + new DotNetFormatStyle() + .WithWorkingDirectory("MyLib") + .WithProject("MyLib.csproj") + .AddDiagnostics("IDE0005", "IDE0006") + .WithSeverity(DotNetFormatSeverity.Information) + .Run().EnsureSuccess(); + // } + } +} \ No newline at end of file diff --git a/CSharpInteractive.Tests/UsageScenarios/DotNetListPackageScenario.cs b/CSharpInteractive.Tests/UsageScenarios/DotNetListPackageScenario.cs new file mode 100644 index 00000000..9fa09c1d --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/DotNetListPackageScenario.cs @@ -0,0 +1,42 @@ +// ReSharper disable StringLiteralTypo +// ReSharper disable ObjectCreationAsStatement +// ReSharper disable ReturnValueOfPureMethodIsNotUsed +// ReSharper disable CommentTypo + +namespace CSharpInteractive.Tests.UsageScenarios; + +[CollectionDefinition("Integration", DisableParallelization = true)] +[Trait("Integration", "True")] +public class DotNetListPackageScenario(ITestOutputHelper output) : BaseScenario(output) +{ + [Fact] + public void Run() + { + new DotNetNew() + .WithTemplateName("classlib") + .WithName("MyLib") + .WithForce(true) + .Run().EnsureSuccess(); + + // $visible=true + // $tag=07 .NET CLI + // $priority=01 + // $description=NuGet package listing + // { + // ## using HostApi; + + new DotNetAddPackage() + .WithWorkingDirectory("MyLib") + .WithPackage("Pure.DI") + .Run().EnsureSuccess(); + + var lines = new List(); + new DotNetListPackage() + .WithWorkingDirectory("MyLib") + .WithVerbosity(DotNetVerbosity.Minimal) + .Run(output => lines.Add(output.Line)); + + lines.Any(i => i.Contains("Pure.DI")).ShouldBeTrue(); + // } + } +} \ No newline at end of file diff --git a/CSharpInteractive.Tests/UsageScenarios/DotNetListReferenceScenario.cs b/CSharpInteractive.Tests/UsageScenarios/DotNetListReferenceScenario.cs new file mode 100644 index 00000000..98e9fd0c --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/DotNetListReferenceScenario.cs @@ -0,0 +1,47 @@ +// ReSharper disable StringLiteralTypo +// ReSharper disable ObjectCreationAsStatement +// ReSharper disable ReturnValueOfPureMethodIsNotUsed +// ReSharper disable CommentTypo + +namespace CSharpInteractive.Tests.UsageScenarios; + +[CollectionDefinition("Integration", DisableParallelization = true)] +[Trait("Integration", "True")] +public class DotNetListReferenceScenario(ITestOutputHelper output) : BaseScenario(output) +{ + [Fact] + public void Run() + { + new DotNetNew() + .WithTemplateName("classlib") + .WithName("MyLib") + .WithForce(true) + .Run().EnsureSuccess(); + + new DotNetNew() + .WithTemplateName("xunit") + .WithName("MyTests") + .WithForce(true) + .Run().EnsureSuccess(); + + // $visible=true + // $tag=07 .NET CLI + // $priority=01 + // $description=Project reference listing + // { + // ## using HostApi; + + new DotNetAddReference() + .WithProject(Path.Combine("MyTests", "MyTests.csproj")) + .WithReferences(Path.Combine("MyLib", "MyLib.csproj")) + .Run().EnsureSuccess(); + + var lines = new List(); + new DotNetListReference() + .WithProject(Path.Combine("MyTests", "MyTests.csproj")) + .Run(output => lines.Add(output.Line)); + + lines.Any(i => i.Contains("MyLib.csproj")).ShouldBeTrue(); + // } + } +} \ No newline at end of file diff --git a/CSharpInteractive.Tests/UsageScenarios/DotNetMSBuildVSTestScenario.cs b/CSharpInteractive.Tests/UsageScenarios/DotNetMSBuildVSTestScenario.cs index bf536afe..e3c6ea97 100644 --- a/CSharpInteractive.Tests/UsageScenarios/DotNetMSBuildVSTestScenario.cs +++ b/CSharpInteractive.Tests/UsageScenarios/DotNetMSBuildVSTestScenario.cs @@ -5,41 +5,36 @@ namespace CSharpInteractive.Tests.UsageScenarios; -using HostApi; - [CollectionDefinition("Integration", DisableParallelization = true)] -[Trait("Integration", "true")] -public class DotNetMSBuildVSTestScenario : BaseScenario +[Trait("Integration", "True")] +public class DotNetMSBuildVSTestScenario(ITestOutputHelper output) : BaseScenario(output) { [Fact] public void Run() { + new DotNetNew() + .WithTemplateName("mstest") + .WithName("MyTests") + .WithForce(true) + .Run().EnsureSuccess(); + // $visible=true // $tag=07 .NET CLI // $priority=01 // $description=Test a project using the MSBuild VSTest target // { - // Adds the namespace "HostApi" to use .NET build API // ## 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(); - - result.ExitCode.ShouldBe(0); - - // Runs tests via a command like: "dotnet msbuild /t:VSTest" from the directory "MyTests" - result = new MSBuild() + // Runs tests via a command + var 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()); // } } } \ No newline at end of file diff --git a/CSharpInteractive.Tests/UsageScenarios/DotNetNewDetailsScenario.cs b/CSharpInteractive.Tests/UsageScenarios/DotNetNewDetailsScenario.cs new file mode 100644 index 00000000..37f2925b --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/DotNetNewDetailsScenario.cs @@ -0,0 +1,27 @@ +// ReSharper disable StringLiteralTypo +// ReSharper disable ObjectCreationAsStatement +// ReSharper disable ReturnValueOfPureMethodIsNotUsed +// ReSharper disable CommentTypo + +namespace CSharpInteractive.Tests.UsageScenarios; + +[CollectionDefinition("Integration", DisableParallelization = true)] +[Trait("Integration", "True")] +public class DotNetNewDetailsScenario(ITestOutputHelper output) : BaseScenario(output) +{ + [Fact] + public void Run() + { + // $visible=true + // $tag=07 .NET CLI + // $priority=01 + // $description=Display template package metadata + // { + // ## using HostApi; + + new DotNetNewDetails() + .WithTemplateName("CSharpInteractive.Templates") + .Run().EnsureSuccess(); + // } + } +} \ No newline at end of file diff --git a/CSharpInteractive.Tests/UsageScenarios/DotNetNewInstallScenario.cs b/CSharpInteractive.Tests/UsageScenarios/DotNetNewInstallScenario.cs new file mode 100644 index 00000000..68afe410 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/DotNetNewInstallScenario.cs @@ -0,0 +1,38 @@ +// ReSharper disable StringLiteralTypo +// ReSharper disable ObjectCreationAsStatement +// ReSharper disable ReturnValueOfPureMethodIsNotUsed +// ReSharper disable CommentTypo + +namespace CSharpInteractive.Tests.UsageScenarios; + +[CollectionDefinition("Integration", DisableParallelization = true)] +[Trait("Integration", "True")] +public class DotNetNewInstallScenario(ITestOutputHelper output) : BaseScenario(output) +{ + [Fact] + public void Run() + { + var exitCode = new DotNetNewUninstall() + .WithPackage("Pure.DI.Templates") + .Run().ExitCode; + + // $visible=true + // $tag=07 .NET CLI + // $priority=01 + // $description=Installing a template package + // { + // ## using HostApi; + + new DotNetNewInstall() + .WithPackage("Pure.DI.Templates") + .Run().EnsureSuccess(); + // } + + if (exitCode == 0) + { + new DotNetNewUninstall() + .WithPackage("Pure.DI.Templates") + .Run(); + } + } +} \ No newline at end of file diff --git a/CSharpInteractive.Tests/UsageScenarios/DotNetNewListScenario.cs b/CSharpInteractive.Tests/UsageScenarios/DotNetNewListScenario.cs new file mode 100644 index 00000000..e12fb6c5 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/DotNetNewListScenario.cs @@ -0,0 +1,26 @@ +// ReSharper disable StringLiteralTypo +// ReSharper disable ObjectCreationAsStatement +// ReSharper disable ReturnValueOfPureMethodIsNotUsed +// ReSharper disable CommentTypo + +namespace CSharpInteractive.Tests.UsageScenarios; + +[CollectionDefinition("Integration", DisableParallelization = true)] +[Trait("Integration", "True")] +public class DotNetNewListScenario(ITestOutputHelper output) : BaseScenario(output) +{ + [Fact] + public void Run() + { + // $visible=true + // $tag=07 .NET CLI + // $priority=01 + // $description=Creating a new project from template + // { + // ## using HostApi; + + new DotNetNewList() + .Run().EnsureSuccess(); + // } + } +} \ No newline at end of file diff --git a/CSharpInteractive.Tests/UsageScenarios/DotNetNewScenario.cs b/CSharpInteractive.Tests/UsageScenarios/DotNetNewScenario.cs new file mode 100644 index 00000000..a85a680e --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/DotNetNewScenario.cs @@ -0,0 +1,29 @@ +// ReSharper disable StringLiteralTypo +// ReSharper disable ObjectCreationAsStatement +// ReSharper disable ReturnValueOfPureMethodIsNotUsed +// ReSharper disable CommentTypo + +namespace CSharpInteractive.Tests.UsageScenarios; + +[CollectionDefinition("Integration", DisableParallelization = true)] +[Trait("Integration", "True")] +public class DotNetNewScenario(ITestOutputHelper output) : BaseScenario(output) +{ + [Fact] + public void Run() + { + // $visible=true + // $tag=07 .NET CLI + // $priority=01 + // $description=List available templates + // { + // ## using HostApi; + + new DotNetNew() + .WithTemplateName("classlib") + .WithName("MyLib") + .WithForce(true) + .Run().EnsureSuccess(); + // } + } +} \ No newline at end of file diff --git a/CSharpInteractive.Tests/UsageScenarios/DotNetNewSearchScenario.cs b/CSharpInteractive.Tests/UsageScenarios/DotNetNewSearchScenario.cs new file mode 100644 index 00000000..98533e21 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/DotNetNewSearchScenario.cs @@ -0,0 +1,27 @@ +// ReSharper disable StringLiteralTypo +// ReSharper disable ObjectCreationAsStatement +// ReSharper disable ReturnValueOfPureMethodIsNotUsed +// ReSharper disable CommentTypo + +namespace CSharpInteractive.Tests.UsageScenarios; + +[CollectionDefinition("Integration", DisableParallelization = true)] +[Trait("Integration", "True")] +public class DotNetNewSearchScenario(ITestOutputHelper output) : BaseScenario(output) +{ + [Fact] + public void Run() + { + // $visible=true + // $tag=07 .NET CLI + // $priority=01 + // $description=Searche for the templates + // { + // ## using HostApi; + + new DotNetNewSearch() + .WithTemplateName("build") + .Run().EnsureSuccess(); + // } + } +} \ No newline at end of file diff --git a/CSharpInteractive.Tests/UsageScenarios/DotNetNewUninstallScenario.cs b/CSharpInteractive.Tests/UsageScenarios/DotNetNewUninstallScenario.cs new file mode 100644 index 00000000..a2de415d --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/DotNetNewUninstallScenario.cs @@ -0,0 +1,38 @@ +// ReSharper disable StringLiteralTypo +// ReSharper disable ObjectCreationAsStatement +// ReSharper disable ReturnValueOfPureMethodIsNotUsed +// ReSharper disable CommentTypo + +namespace CSharpInteractive.Tests.UsageScenarios; + +[CollectionDefinition("Integration", DisableParallelization = true)] +[Trait("Integration", "True")] +public class DotNetNewUninstallScenario(ITestOutputHelper output) : BaseScenario(output) +{ + [Fact] + public void Run() + { + var exitCode = new DotNetNewInstall() + .WithPackage("Pure.DI.Templates") + .Run().ExitCode; + + // $visible=true + // $tag=07 .NET CLI + // $priority=01 + // $description=Uninstalling a template package + // { + // ## using HostApi; + + new DotNetNewUninstall() + .WithPackage("Pure.DI.Templates") + .Run(); + // } + + if (exitCode == 0) + { + new DotNetNewInstall() + .WithPackage("Pure.DI.Templates") + .Run(); + } + } +} \ No newline at end of file diff --git a/CSharpInteractive.Tests/UsageScenarios/DotNetNewUpdateScenario.cs b/CSharpInteractive.Tests/UsageScenarios/DotNetNewUpdateScenario.cs new file mode 100644 index 00000000..03c0e2e7 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/DotNetNewUpdateScenario.cs @@ -0,0 +1,26 @@ +// ReSharper disable StringLiteralTypo +// ReSharper disable ObjectCreationAsStatement +// ReSharper disable ReturnValueOfPureMethodIsNotUsed +// ReSharper disable CommentTypo + +namespace CSharpInteractive.Tests.UsageScenarios; + +[CollectionDefinition("Integration", DisableParallelization = true)] +[Trait("Integration", "True")] +public class DotNetNewUpdateScenario(ITestOutputHelper output) : BaseScenario(output) +{ + [Fact] + public void Run() + { + // $visible=true + // $tag=07 .NET CLI + // $priority=01 + // $description=Updating installed template packages + // { + // ## using HostApi; + + new DotNetNewUpdate() + .Run().EnsureSuccess(); + // } + } +} \ No newline at end of file diff --git a/CSharpInteractive.Tests/UsageScenarios/DotNetNuGetAddSourceScenario.cs b/CSharpInteractive.Tests/UsageScenarios/DotNetNuGetAddSourceScenario.cs new file mode 100644 index 00000000..08baae6b --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/DotNetNuGetAddSourceScenario.cs @@ -0,0 +1,38 @@ +// ReSharper disable StringLiteralTypo +// ReSharper disable ObjectCreationAsStatement +// ReSharper disable ReturnValueOfPureMethodIsNotUsed +// ReSharper disable CommentTypo + +namespace CSharpInteractive.Tests.UsageScenarios; + +[CollectionDefinition("Integration", DisableParallelization = true)] +[Trait("Integration", "True")] +public class DotNetNuGetAddSourceScenario(ITestOutputHelper output) : BaseScenario(output) +{ + [Fact] + public void Run() + { + new DotNetNuGetRemoveSource() + .WithName("TestSource") + .Run(); + + var source = Path.GetFullPath("."); + + // $visible=true + // $tag=07 .NET CLI + // $priority=01 + // $description=Adding a NuGet source + // { + // ## using HostApi; + + new DotNetNuGetAddSource() + .WithName("TestSource") + .WithSource(source) + .Run().EnsureSuccess(); + // } + + new DotNetNuGetRemoveSource() + .WithName("TestSource") + .Run(); + } +} \ No newline at end of file diff --git a/CSharpInteractive.Tests/UsageScenarios/DotNetNuGetConfigGetScenario.cs b/CSharpInteractive.Tests/UsageScenarios/DotNetNuGetConfigGetScenario.cs new file mode 100644 index 00000000..20069830 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/DotNetNuGetConfigGetScenario.cs @@ -0,0 +1,43 @@ +// ReSharper disable StringLiteralTypo +// ReSharper disable ObjectCreationAsStatement +// ReSharper disable ReturnValueOfPureMethodIsNotUsed + +namespace CSharpInteractive.Tests.UsageScenarios; + +using System.Diagnostics.CodeAnalysis; +using NuGet.Versioning; + +[CollectionDefinition("Integration", DisableParallelization = true)] +[Trait("Integration", "True")] +[SuppressMessage("Performance", "CA1861:Avoid constant arrays as arguments")] +public class DotNetNuGetConfigSetScenario(ITestOutputHelper output) : BaseScenario(output) +{ + [SkippableFact] + public void Run() + { + Skip.IfNot(HasSdk("8.0.10")); + var configFile = Path.GetFullPath("nuget.config"); + File.WriteAllText(configFile, ""); + + new DotNetNuGetConfigSet() + .WithConfigFile(configFile) + .WithConfigKey("repositoryPath") + .WithConfigValue("MyValue") + .Run().EnsureSuccess(); + + // $visible=true + // $tag=07 .NET CLI + // $priority=01 + // $description=Gets the value of a specified NuGet configuration setting + // { + // ## using HostApi; + + string? repositoryPath = default; + new DotNetNuGetConfigGet() + .WithConfigKey("repositoryPath") + .Run(output => repositoryPath = output.Line).EnsureSuccess(); + // } + + repositoryPath.ShouldBe("MyValue"); + } +} \ No newline at end of file diff --git a/CSharpInteractive.Tests/UsageScenarios/DotNetNuGetConfigPathsScenario.cs b/CSharpInteractive.Tests/UsageScenarios/DotNetNuGetConfigPathsScenario.cs new file mode 100644 index 00000000..77acbe43 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/DotNetNuGetConfigPathsScenario.cs @@ -0,0 +1,36 @@ +// ReSharper disable StringLiteralTypo +// ReSharper disable ObjectCreationAsStatement +// ReSharper disable ReturnValueOfPureMethodIsNotUsed + +namespace CSharpInteractive.Tests.UsageScenarios; + +using System.Diagnostics.CodeAnalysis; + +[CollectionDefinition("Integration", DisableParallelization = true)] +[Trait("Integration", "True")] +[SuppressMessage("Performance", "CA1861:Avoid constant arrays as arguments")] +public class DotNetNuGetConfigPathsScenario(ITestOutputHelper output) : BaseScenario(output) +{ + [SkippableFact] + public void Run() + { + Skip.IfNot(HasSdk("8.0.10")); + var configFile = Path.GetFullPath("nuget.config"); + File.WriteAllText(configFile, ""); + + // $visible=true + // $tag=07 .NET CLI + // $priority=01 + // $description=Printing nuget configuration files currently being applied to a directory + // { + // ## using HostApi; + + var configPaths = new List(); + new DotNetNuGetConfigPaths() + .Run(output => configPaths.Add(output.Line)).EnsureSuccess(); + // } + + configPaths.Count.ShouldBeGreaterThan(0); + configPaths.Contains(Path.GetFullPath(configFile)); + } +} \ No newline at end of file diff --git a/CSharpInteractive.Tests/UsageScenarios/DotNetNuGetConfigSetScenario.cs b/CSharpInteractive.Tests/UsageScenarios/DotNetNuGetConfigSetScenario.cs new file mode 100644 index 00000000..3e8f6642 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/DotNetNuGetConfigSetScenario.cs @@ -0,0 +1,42 @@ +// ReSharper disable StringLiteralTypo +// ReSharper disable ObjectCreationAsStatement +// ReSharper disable ReturnValueOfPureMethodIsNotUsed + +namespace CSharpInteractive.Tests.UsageScenarios; + +using System.Diagnostics.CodeAnalysis; + +[CollectionDefinition("Integration", DisableParallelization = true)] +[Trait("Integration", "True")] +[SuppressMessage("Performance", "CA1861:Avoid constant arrays as arguments")] +public class DotNetNuGetConfigGetScenario(ITestOutputHelper output) : BaseScenario(output) +{ + [SkippableFact] + public void Run() + { + Skip.IfNot(HasSdk("8.0.10")); + var configFile = Path.GetFullPath("nuget.config"); + File.WriteAllText(configFile, ""); + + // $visible=true + // $tag=07 .NET CLI + // $priority=01 + // $description=Sets the value of a specified NuGet configuration setting + // { + // ## using HostApi; + + new DotNetNuGetConfigSet() + .WithConfigFile(configFile) + .WithConfigKey("repositoryPath") + .WithConfigValue("MyValue") + .Run().EnsureSuccess(); + // } + + string? repositoryPath = default; + new DotNetNuGetConfigGet() + .WithConfigKey("repositoryPath") + .Run(output => repositoryPath = output.Line).EnsureSuccess(); + + repositoryPath.ShouldBe("MyValue"); + } +} \ No newline at end of file diff --git a/CSharpInteractive.Tests/UsageScenarios/DotNetNuGetConfigUnsetScenario.cs b/CSharpInteractive.Tests/UsageScenarios/DotNetNuGetConfigUnsetScenario.cs new file mode 100644 index 00000000..c28b517e --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/DotNetNuGetConfigUnsetScenario.cs @@ -0,0 +1,45 @@ +// ReSharper disable StringLiteralTypo +// ReSharper disable ObjectCreationAsStatement +// ReSharper disable ReturnValueOfPureMethodIsNotUsed + +namespace CSharpInteractive.Tests.UsageScenarios; + +using System.Diagnostics.CodeAnalysis; + +[CollectionDefinition("Integration", DisableParallelization = true)] +[Trait("Integration", "True")] +[SuppressMessage("Performance", "CA1861:Avoid constant arrays as arguments")] +public class DotNetNuGetConfigUnsetScenario(ITestOutputHelper output) : BaseScenario(output) +{ + [SkippableFact] + public void Run() + { + Skip.IfNot(HasSdk("8.0.10")); + ExpectedExitCode = default; + var configFile = Path.GetFullPath("nuget.config"); + File.WriteAllText(configFile, ""); + new DotNetNuGetConfigSet() + .WithConfigFile(configFile) + .WithConfigKey("repositoryPath") + .WithConfigValue("MyValue") + .Run().EnsureSuccess(); + + // $visible=true + // $tag=07 .NET CLI + // $priority=01 + // $description=Unsets the value of a specified NuGet configuration setting + // { + // ## using HostApi; + + new DotNetNuGetConfigUnset() + .WithConfigKey("repositoryPath") + .Run().EnsureSuccess(); + // } + + string? repositoryPath = default; + new DotNetNuGetConfigGet() + .WithConfigKey("repositoryPath") + .Run(output => repositoryPath = output.Line).EnsureSuccess(); + repositoryPath.ShouldNotBe("MyValue"); + } +} \ No newline at end of file diff --git a/CSharpInteractive.Tests/UsageScenarios/DotNetNuGetDeleteScenario.cs b/CSharpInteractive.Tests/UsageScenarios/DotNetNuGetDeleteScenario.cs new file mode 100644 index 00000000..5322b6bc --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/DotNetNuGetDeleteScenario.cs @@ -0,0 +1,48 @@ +// ReSharper disable StringLiteralTypo +// ReSharper disable ObjectCreationAsStatement +// ReSharper disable ReturnValueOfPureMethodIsNotUsed +// ReSharper disable CommentTypo + +namespace CSharpInteractive.Tests.UsageScenarios; + +[CollectionDefinition("Integration", DisableParallelization = true)] +[Trait("Integration", "True")] +public class DotNetNuGetDeleteScenario(ITestOutputHelper output) : BaseScenario(output) +{ + [Fact] + public void Run() + { + new DotNetNew() + .WithTemplateName("classlib") + .WithName("MyLib") + .WithForce(true) + .Run().EnsureSuccess(); + + new DotNetPack() + .WithWorkingDirectory("MyLib") + .WithOutput("packages") + .Build().EnsureSuccess(); + + var repoUrl = Path.GetFullPath("."); + + new DotNetNuGetPush() + .WithWorkingDirectory("MyLib") + .WithPackage(Path.Combine("packages", "MyLib.1.0.0.nupkg")) + .WithSource(repoUrl) + .Run().EnsureSuccess(); + + // $visible=true + // $tag=07 .NET CLI + // $priority=01 + // $description=Deleting a NuGet package to the server + // { + // ## using HostApi; + + new DotNetNuGetDelete() + .WithPackage("MyLib") + .WithPackageVersion("1.0.0") + .WithSource(repoUrl) + .Run().EnsureSuccess(); + // } + } +} \ No newline at end of file diff --git a/CSharpInteractive.Tests/UsageScenarios/DotNetNuGetDisableSourceScenario.cs b/CSharpInteractive.Tests/UsageScenarios/DotNetNuGetDisableSourceScenario.cs new file mode 100644 index 00000000..bd5e3b10 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/DotNetNuGetDisableSourceScenario.cs @@ -0,0 +1,42 @@ +// ReSharper disable StringLiteralTypo +// ReSharper disable ObjectCreationAsStatement +// ReSharper disable ReturnValueOfPureMethodIsNotUsed +// ReSharper disable CommentTypo + +namespace CSharpInteractive.Tests.UsageScenarios; + +[CollectionDefinition("Integration", DisableParallelization = true)] +[Trait("Integration", "True")] +public class DotNetNuGetDisableSourceScenario(ITestOutputHelper output) : BaseScenario(output) +{ + [Fact] + public void Run() + { + new DotNetNuGetRemoveSource() + .WithName("TestSource") + .Run(); + + var source = Path.GetFullPath("."); + + new DotNetNuGetAddSource() + .WithName("TestSource") + .WithSource(source) + .Run().EnsureSuccess(); + + // $visible=true + // $tag=07 .NET CLI + // $priority=01 + // $description=Disabling a NuGet source + // { + // ## using HostApi; + + new DotNetNuGetDisableSource() + .WithName("TestSource") + .Run().EnsureSuccess(); + // } + + new DotNetNuGetRemoveSource() + .WithName("TestSource") + .Run(); + } +} \ No newline at end of file diff --git a/CSharpInteractive.Tests/UsageScenarios/DotNetNuGetEnableSourceScenario.cs b/CSharpInteractive.Tests/UsageScenarios/DotNetNuGetEnableSourceScenario.cs new file mode 100644 index 00000000..c52185a9 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/DotNetNuGetEnableSourceScenario.cs @@ -0,0 +1,46 @@ +// ReSharper disable StringLiteralTypo +// ReSharper disable ObjectCreationAsStatement +// ReSharper disable ReturnValueOfPureMethodIsNotUsed +// ReSharper disable CommentTypo + +namespace CSharpInteractive.Tests.UsageScenarios; + +[CollectionDefinition("Integration", DisableParallelization = true)] +[Trait("Integration", "True")] +public class DotNetNuGetEnableSourceScenario(ITestOutputHelper output) : BaseScenario(output) +{ + [Fact] + public void Run() + { + new DotNetNuGetRemoveSource() + .WithName("TestSource") + .Run(); + + var source = Path.GetFullPath("."); + + new DotNetNuGetAddSource() + .WithName("TestSource") + .WithSource(source) + .Run().EnsureSuccess(); + + new DotNetNuGetDisableSource() + .WithName("TestSource") + .Run().EnsureSuccess(); + + // $visible=true + // $tag=07 .NET CLI + // $priority=01 + // $description=Enabling a NuGet source + // { + // ## using HostApi; + + new DotNetNuGetEnableSource() + .WithName("TestSource") + .Run().EnsureSuccess(); + // } + + new DotNetNuGetRemoveSource() + .WithName("TestSource") + .Run(); + } +} \ No newline at end of file diff --git a/CSharpInteractive.Tests/UsageScenarios/DotNetNuGetListSourceScenario.cs b/CSharpInteractive.Tests/UsageScenarios/DotNetNuGetListSourceScenario.cs new file mode 100644 index 00000000..941836fc --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/DotNetNuGetListSourceScenario.cs @@ -0,0 +1,27 @@ +// ReSharper disable StringLiteralTypo +// ReSharper disable ObjectCreationAsStatement +// ReSharper disable ReturnValueOfPureMethodIsNotUsed +// ReSharper disable CommentTypo + +namespace CSharpInteractive.Tests.UsageScenarios; + +[CollectionDefinition("Integration", DisableParallelization = true)] +[Trait("Integration", "True")] +public class DotNetNuGetListSourceScenario(ITestOutputHelper output) : BaseScenario(output) +{ + [Fact] + public void Run() + { + // $visible=true + // $tag=07 .NET CLI + // $priority=01 + // $description=Printing all configured NuGet sources + // { + // ## using HostApi; + + new DotNetNuGetListSource() + .WithFormat(NuGetListFormat.Short) + .Run().EnsureSuccess(); + // } + } +} \ No newline at end of file diff --git a/CSharpInteractive.Tests/UsageScenarios/DotNetNuGetLocalsClearScenario.cs b/CSharpInteractive.Tests/UsageScenarios/DotNetNuGetLocalsClearScenario.cs new file mode 100644 index 00000000..c6e18c09 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/DotNetNuGetLocalsClearScenario.cs @@ -0,0 +1,27 @@ +// ReSharper disable StringLiteralTypo +// ReSharper disable ObjectCreationAsStatement +// ReSharper disable ReturnValueOfPureMethodIsNotUsed +// ReSharper disable CommentTypo + +namespace CSharpInteractive.Tests.UsageScenarios; + +[CollectionDefinition("Integration", DisableParallelization = true)] +[Trait("Integration", "True")] +public class DotNetNuGetLocalsClearScenario(ITestOutputHelper output) : BaseScenario(output) +{ + [Fact] + public void Run() + { + // $visible=true + // $tag=07 .NET CLI + // $priority=01 + // $description=Clearing the specified NuGet cache type + // { + // ## using HostApi; + + new DotNetNuGetLocalsClear() + .WithCacheLocation(NuGetCacheLocation.Temp) + .Run().EnsureSuccess(); + // } + } +} \ No newline at end of file diff --git a/CSharpInteractive.Tests/UsageScenarios/DotNetNuGetLocalsListScenario.cs b/CSharpInteractive.Tests/UsageScenarios/DotNetNuGetLocalsListScenario.cs new file mode 100644 index 00000000..e6bb2664 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/DotNetNuGetLocalsListScenario.cs @@ -0,0 +1,27 @@ +// ReSharper disable StringLiteralTypo +// ReSharper disable ObjectCreationAsStatement +// ReSharper disable ReturnValueOfPureMethodIsNotUsed +// ReSharper disable CommentTypo + +namespace CSharpInteractive.Tests.UsageScenarios; + +[CollectionDefinition("Integration", DisableParallelization = true)] +[Trait("Integration", "True")] +public class DotNetNuGetLocalsListScenario(ITestOutputHelper output) : BaseScenario(output) +{ + [Fact] + public void Run() + { + // $visible=true + // $tag=07 .NET CLI + // $priority=01 + // $description=Printing the location of the specified NuGet cache type + // { + // ## using HostApi; + + new DotNetNuGetLocalsList() + .WithCacheLocation(NuGetCacheLocation.GlobalPackages) + .Run().EnsureSuccess(); + // } + } +} \ No newline at end of file diff --git a/CSharpInteractive.Tests/UsageScenarios/DotNetNuGetPushScenario.cs b/CSharpInteractive.Tests/UsageScenarios/DotNetNuGetPushScenario.cs new file mode 100644 index 00000000..00df5c97 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/DotNetNuGetPushScenario.cs @@ -0,0 +1,42 @@ +// ReSharper disable StringLiteralTypo +// ReSharper disable ObjectCreationAsStatement +// ReSharper disable ReturnValueOfPureMethodIsNotUsed +// ReSharper disable CommentTypo + +namespace CSharpInteractive.Tests.UsageScenarios; + +[CollectionDefinition("Integration", DisableParallelization = true)] +[Trait("Integration", "True")] +public class DotNetNuGetPushScenario(ITestOutputHelper output) : BaseScenario(output) +{ + [Fact] + public void Run() + { + new DotNetNew() + .WithTemplateName("classlib") + .WithName("MyLib") + .WithForce(true) + .Run().EnsureSuccess(); + + new DotNetPack() + .WithWorkingDirectory("MyLib") + .WithOutput("packages") + .Build().EnsureSuccess(); + + var repoUrl = Path.GetFullPath("."); + + // $visible=true + // $tag=07 .NET CLI + // $priority=01 + // $description=Pushing a NuGet package to the server + // { + // ## using HostApi; + + new DotNetNuGetPush() + .WithWorkingDirectory("MyLib") + .WithPackage(Path.Combine("packages", "MyLib.1.0.0.nupkg")) + .WithSource(repoUrl) + .Run().EnsureSuccess(); + // } + } +} \ No newline at end of file diff --git a/CSharpInteractive.Tests/UsageScenarios/DotNetNuGetRemoveSourceScenario.cs b/CSharpInteractive.Tests/UsageScenarios/DotNetNuGetRemoveSourceScenario.cs new file mode 100644 index 00000000..b7822427 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/DotNetNuGetRemoveSourceScenario.cs @@ -0,0 +1,38 @@ +// ReSharper disable StringLiteralTypo +// ReSharper disable ObjectCreationAsStatement +// ReSharper disable ReturnValueOfPureMethodIsNotUsed +// ReSharper disable CommentTypo + +namespace CSharpInteractive.Tests.UsageScenarios; + +[CollectionDefinition("Integration", DisableParallelization = true)] +[Trait("Integration", "True")] +public class DotNetNuGetRemoveSourceScenario(ITestOutputHelper output) : BaseScenario(output) +{ + [Fact] + public void Run() + { + new DotNetNuGetRemoveSource() + .WithName("TestSource") + .Run(); + + var source = Path.GetFullPath("."); + + new DotNetNuGetAddSource() + .WithName("TestSource") + .WithSource(source) + .Run().EnsureSuccess(); + + // $visible=true + // $tag=07 .NET CLI + // $priority=01 + // $description=Removing a NuGet source. + // { + // ## using HostApi; + + new DotNetNuGetRemoveSource() + .WithName("TestSource") + .Run().EnsureSuccess(); + // } + } +} \ No newline at end of file diff --git a/CSharpInteractive.Tests/UsageScenarios/DotNetNuGetSignScenario.cs b/CSharpInteractive.Tests/UsageScenarios/DotNetNuGetSignScenario.cs new file mode 100644 index 00000000..2393b9e6 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/DotNetNuGetSignScenario.cs @@ -0,0 +1,51 @@ +// ReSharper disable StringLiteralTypo +// ReSharper disable ObjectCreationAsStatement +// ReSharper disable ReturnValueOfPureMethodIsNotUsed +// ReSharper disable CommentTypo + +namespace CSharpInteractive.Tests.UsageScenarios; + +[CollectionDefinition("Integration", DisableParallelization = true)] +[Trait("Integration", "True")] +public class DotNetNuGetSignScenario(ITestOutputHelper output) : BaseScenario(output) +{ + [Fact(Skip = "Certificate chain validation failed.")] + public void Run() + { + ExpectedExitCode = 1; + + new DotNetNew() + .WithTemplateName("classlib") + .WithName("MyLib") + .WithForce(true) + .Run().EnsureSuccess(); + + new DotNetPack() + .WithWorkingDirectory("MyLib") + .AddProps(("version", "1.2.3")) + .WithOutput(Path.GetFullPath(".")) + .Build().EnsureSuccess(); + + new DotNetDevCertsHttps() + .WithExportPath("certificate.pfx") + .WithTrust(true) + .WithFormat(DotNetCertificateFormat.Pfx) + .WithPassword("Abc") + .Run().EnsureSuccess(); + + // $visible=true + // $tag=07 .NET CLI + // $priority=01 + // $description=Signing with certificate + // { + // ## using HostApi; + + new DotNetNuGetSign() + .AddPackages("MyLib.1.2.3.nupkg") + .WithCertificatePath("certificate.pfx") + .WithCertificatePassword("Abc") + .WithTimestampingServer("http://timestamp.digicert.com/") + .Run().EnsureSuccess(); + // } + } +} \ No newline at end of file diff --git a/CSharpInteractive.Tests/UsageScenarios/DotNetNuGetUpdateSourceScenario.cs b/CSharpInteractive.Tests/UsageScenarios/DotNetNuGetUpdateSourceScenario.cs new file mode 100644 index 00000000..2d2d2177 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/DotNetNuGetUpdateSourceScenario.cs @@ -0,0 +1,44 @@ +// ReSharper disable StringLiteralTypo +// ReSharper disable ObjectCreationAsStatement +// ReSharper disable ReturnValueOfPureMethodIsNotUsed +// ReSharper disable CommentTypo + +namespace CSharpInteractive.Tests.UsageScenarios; + +[CollectionDefinition("Integration", DisableParallelization = true)] +[Trait("Integration", "True")] +public class DotNetNuGetUpdateSourceScenario(ITestOutputHelper output) : BaseScenario(output) +{ + [Fact] + public void Run() + { + new DotNetNuGetRemoveSource() + .WithName("TestSource") + .Run(); + + var source = Path.GetFullPath("."); + var newSource = Path.GetFullPath("."); + + new DotNetNuGetAddSource() + .WithName("TestSource") + .WithSource(source) + .Run().EnsureSuccess(); + + // $visible=true + // $tag=07 .NET CLI + // $priority=01 + // $description=Updating a NuGet source + // { + // ## using HostApi; + + new DotNetNuGetUpdateSource() + .WithName("TestSource") + .WithSource(newSource) + .Run().EnsureSuccess(); + // } + + new DotNetNuGetRemoveSource() + .WithName("TestSource") + .Run(); + } +} \ No newline at end of file diff --git a/CSharpInteractive.Tests/UsageScenarios/DotNetNuGetWhyScenario.cs b/CSharpInteractive.Tests/UsageScenarios/DotNetNuGetWhyScenario.cs new file mode 100644 index 00000000..f01c85b5 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/DotNetNuGetWhyScenario.cs @@ -0,0 +1,41 @@ +// ReSharper disable StringLiteralTypo +// ReSharper disable ObjectCreationAsStatement +// ReSharper disable ReturnValueOfPureMethodIsNotUsed +// ReSharper disable CommentTypo + +namespace CSharpInteractive.Tests.UsageScenarios; + +[CollectionDefinition("Integration", DisableParallelization = true)] +[Trait("Integration", "True")] +public class DotNetNuGetWhyScenario(ITestOutputHelper output) : BaseScenario(output) +{ + [SkippableFact] + public void Run() + { + Skip.IfNot(HasSdk("8.0.10")); + new DotNetNew() + .WithTemplateName("classlib") + .WithName("MyLib") + .WithForce(true) + .Run().EnsureSuccess(); + + new DotNetPack() + .WithWorkingDirectory("MyLib") + .AddProps(("version", "1.2.3")) + .WithOutput(Path.GetFullPath(".")) + .Build().EnsureSuccess(); + + // $visible=true + // $tag=07 .NET CLI + // $priority=01 + // $description=Show the dependency graph for NuGet package + // { + // ## using HostApi; + + new DotNetNuGetWhy() + .WithProject(Path.Combine("MyLib", "MyLib.csproj")) + .WithPackage("MyLib.1.2.3.nupkg") + .Run().EnsureSuccess(); + // } + } +} \ No newline at end of file diff --git a/CSharpInteractive.Tests/UsageScenarios/DotNetPackScenario.cs b/CSharpInteractive.Tests/UsageScenarios/DotNetPackScenario.cs index 23acc7e2..77d4e7a7 100644 --- a/CSharpInteractive.Tests/UsageScenarios/DotNetPackScenario.cs +++ b/CSharpInteractive.Tests/UsageScenarios/DotNetPackScenario.cs @@ -5,38 +5,36 @@ namespace CSharpInteractive.Tests.UsageScenarios; -using HostApi; - [CollectionDefinition("Integration", DisableParallelization = true)] -[Trait("Integration", "true")] -public class DotNetPackScenario : BaseScenario +[Trait("Integration", "True")] +public class DotNetPackScenario(ITestOutputHelper output) : BaseScenario(output) { [Fact] public void Run() { + new DotNetNew() + .WithTemplateName("classlib") + .WithName("MyLib") + .WithForce(true) + .Run().EnsureSuccess(); + + var path = Path.GetFullPath("."); + // $visible=true // $tag=07 .NET CLI // $priority=01 - // $description=Pack a project + // $description=Packing the code into a NuGet package // { - // Adds the namespace "HostApi" to use .NET build API // ## 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(); - - result.ExitCode.ShouldBe(0); - - // Creates a NuGet package of version 1.2.3 for the project, running a command like: "dotnet pack /p:version=1.2.3" from the directory "MyLib" - result = new DotNetPack() + // Creates a NuGet package of version 1.2.3 for the project + new DotNetPack() .WithWorkingDirectory("MyLib") + .WithOutput(path) .AddProps(("version", "1.2.3")) - .Build() - .EnsureSuccess(); - - result.ExitCode.ShouldBe(0); + .Build().EnsureSuccess(); // } + + File.Exists(Path.Combine(path, "MyLib.1.2.3.nupkg")).ShouldBeTrue(); } } \ No newline at end of file diff --git a/CSharpInteractive.Tests/UsageScenarios/DotNetPackageSearchScenario.cs b/CSharpInteractive.Tests/UsageScenarios/DotNetPackageSearchScenario.cs new file mode 100644 index 00000000..3134b274 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/DotNetPackageSearchScenario.cs @@ -0,0 +1,57 @@ +// ReSharper disable StringLiteralTypo +// ReSharper disable ObjectCreationAsStatement +// ReSharper disable ReturnValueOfPureMethodIsNotUsed +// ReSharper disable CommentTypo + +// ReSharper disable ClassNeverInstantiated.Local +// ReSharper disable ArrangeTypeMemberModifiers +// ReSharper disable NotAccessedPositionalProperty.Local +namespace CSharpInteractive.Tests.UsageScenarios; + +using System.Text; +using System.Text.Json; + +[CollectionDefinition("Integration", DisableParallelization = true)] +[Trait("Integration", "True")] +public class DotNetPackageSearchScenario(ITestOutputHelper output) : BaseScenario(output) +{ + [Fact] + public void Run() + { + // $visible=true + // $tag=07 .NET CLI + // $priority=01 + // $description=Searching for a NuGet package + // { + // ## using System.Text; + // ## using System.Text.Json; + // ## using HostApi; + + var packagesJson = new StringBuilder(); + new DotNetPackageSearch() + .WithSearchTerm("Pure.DI") + .WithFormat(DotNetPackageSearchResultFormat.Json) + .Run(output => packagesJson.AppendLine(output.Line)).EnsureSuccess(); + + var result = JsonSerializer.Deserialize( + packagesJson.ToString(), + new JsonSerializerOptions { PropertyNameCaseInsensitive = true }); + + result.ShouldNotBeNull(); + result.SearchResult.SelectMany(i => i.Packages).Count(i => i.Id == "Pure.DI").ShouldBe(1); + // } + } + + // { + + record Result(int Version, IReadOnlyCollection SearchResult); + + record Source(string SourceName, IReadOnlyCollection Packages); + + record Package( + string Id, + string LatestVersion, + int TotalDownloads, + string Owners); + // } +} \ No newline at end of file diff --git a/CSharpInteractive.Tests/UsageScenarios/DotNetPublishScenario.cs b/CSharpInteractive.Tests/UsageScenarios/DotNetPublishScenario.cs index 0ed7a152..83610f5f 100644 --- a/CSharpInteractive.Tests/UsageScenarios/DotNetPublishScenario.cs +++ b/CSharpInteractive.Tests/UsageScenarios/DotNetPublishScenario.cs @@ -5,38 +5,31 @@ namespace CSharpInteractive.Tests.UsageScenarios; -using HostApi; - [CollectionDefinition("Integration", DisableParallelization = true)] -[Trait("Integration", "true")] -public class DotNetPublishScenario : BaseScenario +[Trait("Integration", "True")] +public class DotNetPublishScenario(ITestOutputHelper output) : BaseScenario(output) { [Fact] public void Run() { + new DotNetNew() + .WithTemplateName("classlib") + .WithName("MyLib") + .WithForce(true) + .Run().EnsureSuccess(); + // $visible=true // $tag=07 .NET CLI // $priority=01 - // $description=Publish a project + // $description=Publishing the application and its dependencies to a folder for deployment to a hosting system // { - // Adds the namespace "HostApi" to use .NET build API // ## 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(); - - result.ExitCode.ShouldBe(0); - - // Publish the project, running a command like: "dotnet publish --framework net6.0" from the directory "MyLib" - result = new DotNetPublish() + new DotNetPublish() .WithWorkingDirectory("MyLib") .WithFramework("net8.0") - .Build() - .EnsureSuccess(); - - result.ExitCode.ShouldBe(0); + .WithOutput("bin") + .Build().EnsureSuccess(); // } } } \ No newline at end of file diff --git a/CSharpInteractive.Tests/UsageScenarios/DotNetRemovePackageScenario.cs b/CSharpInteractive.Tests/UsageScenarios/DotNetRemovePackageScenario.cs new file mode 100644 index 00000000..74570e31 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/DotNetRemovePackageScenario.cs @@ -0,0 +1,47 @@ +// ReSharper disable StringLiteralTypo +// ReSharper disable ObjectCreationAsStatement +// ReSharper disable ReturnValueOfPureMethodIsNotUsed +// ReSharper disable CommentTypo + +namespace CSharpInteractive.Tests.UsageScenarios; + +[CollectionDefinition("Integration", DisableParallelization = true)] +[Trait("Integration", "True")] +public class DotNetRemovePackageScenario(ITestOutputHelper output) : BaseScenario(output) +{ + [Fact] + public void Run() + { + new DotNetNew() + .WithTemplateName("classlib") + .WithName("MyLib") + .WithForce(true) + .Run().EnsureSuccess(); + + // $visible=true + // $tag=07 .NET CLI + // $priority=01 + // $description=Removing a NuGet package + // { + // ## using HostApi; + + new DotNetAddPackage() + .WithWorkingDirectory("MyLib") + .WithPackage("Pure.DI") + .Run().EnsureSuccess(); + + new DotNetRemovePackage() + .WithWorkingDirectory("MyLib") + .WithPackage("Pure.DI") + .Run().EnsureSuccess(); + // } + + var lines = new List(); + new DotNetListPackage() + .WithWorkingDirectory("MyLib") + .WithVerbosity(DotNetVerbosity.Minimal) + .Run(output => lines.Add(output.Line)); + + lines.Any(i => i.Contains("Pure.DI")).ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/CSharpInteractive.Tests/UsageScenarios/DotNetRemoveReferenceScenario.cs b/CSharpInteractive.Tests/UsageScenarios/DotNetRemoveReferenceScenario.cs new file mode 100644 index 00000000..c5ad7b7c --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/DotNetRemoveReferenceScenario.cs @@ -0,0 +1,52 @@ +// ReSharper disable StringLiteralTypo +// ReSharper disable ObjectCreationAsStatement +// ReSharper disable ReturnValueOfPureMethodIsNotUsed +// ReSharper disable CommentTypo + +namespace CSharpInteractive.Tests.UsageScenarios; + +[CollectionDefinition("Integration", DisableParallelization = true)] +[Trait("Integration", "True")] +public class DotNetRemoveReferenceScenario(ITestOutputHelper output) : BaseScenario(output) +{ + [Fact] + public void Run() + { + new DotNetNew() + .WithTemplateName("classlib") + .WithName("MyLib") + .WithForce(true) + .Run().EnsureSuccess(); + + new DotNetNew() + .WithTemplateName("xunit") + .WithName("MyTests") + .WithForce(true) + .Run().EnsureSuccess(); + + // $visible=true + // $tag=07 .NET CLI + // $priority=01 + // $description=Adding a project reference + // { + // ## using HostApi; + + new DotNetAddReference() + .WithProject(Path.Combine("MyTests", "MyTests.csproj")) + .WithReferences(Path.Combine("MyLib", "MyLib.csproj")) + .Run().EnsureSuccess(); + + new DotNetRemoveReference() + .WithProject(Path.Combine("MyTests", "MyTests.csproj")) + .WithReferences(Path.Combine("MyLib", "MyLib.csproj")) + .Run().EnsureSuccess(); + + var lines = new List(); + new DotNetListReference() + .WithProject(Path.Combine("MyTests", "MyTests.csproj")) + .Run(output => lines.Add(output.Line)); + + lines.Any(i => i.Contains("MyLib.csproj")).ShouldBeFalse(); + // } + } +} \ No newline at end of file diff --git a/CSharpInteractive.Tests/UsageScenarios/DotNetRestoreScenario.cs b/CSharpInteractive.Tests/UsageScenarios/DotNetRestoreScenario.cs index 23814db8..d88554aa 100644 --- a/CSharpInteractive.Tests/UsageScenarios/DotNetRestoreScenario.cs +++ b/CSharpInteractive.Tests/UsageScenarios/DotNetRestoreScenario.cs @@ -5,37 +5,29 @@ namespace CSharpInteractive.Tests.UsageScenarios; -using HostApi; - [CollectionDefinition("Integration", DisableParallelization = true)] -[Trait("Integration", "true")] -public class DotNetRestoreScenario : BaseScenario +[Trait("Integration", "True")] +public class DotNetRestoreScenario(ITestOutputHelper output) : BaseScenario(output) { [Fact] public void Run() { + new DotNetNew() + .WithTemplateName("classlib") + .WithName("MyLib") + .WithForce(true) + .Run().EnsureSuccess(); + // $visible=true // $tag=07 .NET CLI // $priority=01 - // $description=Restore a project + // $description=Restoring the dependencies and tools of a project // { - // Adds the namespace "HostApi" to use .NET build API // ## 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(); - - result.ExitCode.ShouldBe(0); - - // Restore the project, running a command like: "dotnet restore" from the directory "MyLib" - result = new DotNetRestore() - .WithWorkingDirectory("MyLib") - .Build() - .EnsureSuccess(); - - result.ExitCode.ShouldBe(0); + new DotNetRestore() + .WithProject(Path.Combine("MyLib", "MyLib.csproj")) + .Build().EnsureSuccess(); // } } } \ No newline at end of file diff --git a/CSharpInteractive.Tests/UsageScenarios/DotNetRunScenario.cs b/CSharpInteractive.Tests/UsageScenarios/DotNetRunScenario.cs index 5e3a1a4c..22dbf81b 100644 --- a/CSharpInteractive.Tests/UsageScenarios/DotNetRunScenario.cs +++ b/CSharpInteractive.Tests/UsageScenarios/DotNetRunScenario.cs @@ -5,40 +5,35 @@ namespace CSharpInteractive.Tests.UsageScenarios; using System.Diagnostics.CodeAnalysis; -using HostApi; [CollectionDefinition("Integration", DisableParallelization = true)] -[Trait("Integration", "true")] +[Trait("Integration", "True")] [SuppressMessage("Performance", "CA1861:Avoid constant arrays as arguments")] -public class DotNetRunScenario : BaseScenario +public class DotNetRunScenario(ITestOutputHelper output) : BaseScenario(output) { [Fact] public void Run() { + new DotNetNew() + .WithTemplateName("console") + .WithName("MyApp") + .WithForce(true) + .Run().EnsureSuccess(); + // $visible=true // $tag=07 .NET CLI // $priority=01 - // $description=Run a project + // $description=Running source code without any explicit compile or launch commands // { - // Adds the namespace "HostApi" to use .NET build API // ## 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(); - - result.ExitCode.ShouldBe(0); - - // Runs the console project using a command like: "dotnet run" from the directory "MyApp" var stdOut = new List(); - result = new DotNetRun().WithWorkingDirectory("MyApp") + new DotNetRun() + .WithProject(Path.Combine("MyApp", "MyApp.csproj")) .Build(message => stdOut.Add(message.Text)) .EnsureSuccess(); - result.ExitCode.ShouldBe(0); - - // Checks StdOut + // Checks stdOut stdOut.ShouldBe(new[] {"Hello, World!"}); // } } diff --git a/CSharpInteractive.Tests/UsageScenarios/DotNetScenario.cs b/CSharpInteractive.Tests/UsageScenarios/DotNetScenario.cs new file mode 100644 index 00000000..beb8e150 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/DotNetScenario.cs @@ -0,0 +1,42 @@ +// ReSharper disable StringLiteralTypo +// ReSharper disable ObjectCreationAsStatement +// ReSharper disable ReturnValueOfPureMethodIsNotUsed + +namespace CSharpInteractive.Tests.UsageScenarios; + +using System.Diagnostics.CodeAnalysis; + +[CollectionDefinition("Integration", DisableParallelization = true)] +[Trait("Integration", "True")] +[SuppressMessage("Performance", "CA1861:Avoid constant arrays as arguments")] +public class DotNetScenario(ITestOutputHelper output) : BaseScenario(output) +{ + [Fact] + public void Run() + { + new DotNetNew() + .WithTemplateName("console") + .WithName("MyApp") + .WithForce(true) + .Run().EnsureSuccess(); + + var path = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); + new DotNetPublish() + .WithWorkingDirectory("MyApp") + .WithOutput(path) + .Build().EnsureSuccess(); + + // $visible=true + // $tag=07 .NET CLI + // $priority=01 + // $description=Run a dotnet application + // { + // Adds the namespace "HostApi" to use .NET build API + // ## using HostApi; + + new DotNet() + .WithPathToApplication(Path.Combine(path, "MyApp.dll")) + .Run().EnsureSuccess(); + // } + } +} \ No newline at end of file diff --git a/CSharpInteractive.Tests/UsageScenarios/DotNetSdkCheckScenario.cs b/CSharpInteractive.Tests/UsageScenarios/DotNetSdkCheckScenario.cs new file mode 100644 index 00000000..5ad1abeb --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/DotNetSdkCheckScenario.cs @@ -0,0 +1,50 @@ +// ReSharper disable StringLiteralTypo +// ReSharper disable ObjectCreationAsStatement +// ReSharper disable ReturnValueOfPureMethodIsNotUsed + +// ReSharper disable ArrangeTypeMemberModifiers +// ReSharper disable NotAccessedPositionalProperty.Local +namespace CSharpInteractive.Tests.UsageScenarios; + +using System.Diagnostics.CodeAnalysis; +using NuGet.Versioning; + +[CollectionDefinition("Integration", DisableParallelization = true)] +[Trait("Integration", "True")] +[SuppressMessage("Performance", "CA1861:Avoid constant arrays as arguments")] +public class DotNetSdkCheckScenario(ITestOutputHelper output) : BaseScenario(output) +{ + [Fact] + public void Run() + { + // $visible=true + // $tag=07 .NET CLI + // $priority=01 + // $description=Printing the latest available version of the .NET SDK and .NET Runtime, for each feature band + // { + // ## using HostApi; + + var sdks = new List(); + new DotNetSdkCheck() + .Run(output => + { + if (output.Line.StartsWith("Microsoft.")) + { + var data = output.Line.Split(' ', StringSplitOptions.RemoveEmptyEntries); + if (data.Length >= 2) + { + sdks.Add(new Sdk(data[0], NuGetVersion.Parse(data[1]))); + } + } + }) + .EnsureSuccess(); + + sdks.Count.ShouldBeGreaterThan(0); + // } + } + + // { + + record Sdk(string Name, NuGetVersion Version); + // } +} \ No newline at end of file diff --git a/CSharpInteractive.Tests/UsageScenarios/DotNetSlnAddScenario.cs b/CSharpInteractive.Tests/UsageScenarios/DotNetSlnAddScenario.cs new file mode 100644 index 00000000..c9d6632d --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/DotNetSlnAddScenario.cs @@ -0,0 +1,56 @@ +// ReSharper disable StringLiteralTypo +// ReSharper disable ObjectCreationAsStatement +// ReSharper disable ReturnValueOfPureMethodIsNotUsed +// ReSharper disable CommentTypo + +namespace CSharpInteractive.Tests.UsageScenarios; + +[CollectionDefinition("Integration", DisableParallelization = true)] +[Trait("Integration", "True")] +public class DotNetSlnAddScenario(ITestOutputHelper output) : BaseScenario(output) +{ + [Fact] + public void Run() + { + new DotNetNew() + .WithTemplateName("classlib") + .WithName("MyLib") + .WithForce(true) + .Run().EnsureSuccess(); + + new DotNetNew() + .WithTemplateName("xunit") + .WithName("MyTests") + .WithForce(true) + .Run().EnsureSuccess(); + + // $visible=true + // $tag=07 .NET CLI + // $priority=01 + // $description=Adding projects to the solution file + // { + // ## using HostApi; + + new DotNetNew() + .WithTemplateName("sln") + .WithName("NySolution") + .WithForce(true) + .Run().EnsureSuccess(); + + new DotNetSlnAdd() + .WithSolution("NySolution.sln") + .AddProjects( + Path.Combine("MyLib", "MyLib.csproj"), + Path.Combine("MyTests", "MyTests.csproj")) + .Run().EnsureSuccess(); + // } + + var lines = new List(); + new DotNetSlnList() + .WithSolution("NySolution.sln") + .Run(output => lines.Add(output.Line)) + .EnsureSuccess(); + + lines.Count.ShouldBe(4); + } +} \ No newline at end of file diff --git a/CSharpInteractive.Tests/UsageScenarios/DotNetSlnListScenario.cs b/CSharpInteractive.Tests/UsageScenarios/DotNetSlnListScenario.cs new file mode 100644 index 00000000..9fb5cddc --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/DotNetSlnListScenario.cs @@ -0,0 +1,56 @@ +// ReSharper disable StringLiteralTypo +// ReSharper disable ObjectCreationAsStatement +// ReSharper disable ReturnValueOfPureMethodIsNotUsed +// ReSharper disable CommentTypo + +namespace CSharpInteractive.Tests.UsageScenarios; + +[CollectionDefinition("Integration", DisableParallelization = true)] +[Trait("Integration", "True")] +public class DotNetSlnListScenario(ITestOutputHelper output) : BaseScenario(output) +{ + [Fact] + public void Run() + { + new DotNetNew() + .WithTemplateName("classlib") + .WithName("MyLib") + .WithForce(true) + .Run().EnsureSuccess(); + + new DotNetNew() + .WithTemplateName("xunit") + .WithName("MyTests") + .WithForce(true) + .Run().EnsureSuccess(); + + new DotNetNew() + .WithTemplateName("sln") + .WithName("NySolution") + .WithForce(true) + .Run().EnsureSuccess(); + + new DotNetSlnAdd() + .WithSolution("NySolution.sln") + .AddProjects( + Path.Combine("MyLib", "MyLib.csproj"), + Path.Combine("MyTests", "MyTests.csproj")) + .Run().EnsureSuccess(); + + // $visible=true + // $tag=07 .NET CLI + // $priority=01 + // $description=Printing all projects in a solution file + // { + // ## using HostApi; + + var lines = new List(); + new DotNetSlnList() + .WithSolution("NySolution.sln") + .Run(output => lines.Add(output.Line)) + .EnsureSuccess(); + // } + + lines.Count.ShouldBe(4); + } +} \ No newline at end of file diff --git a/CSharpInteractive.Tests/UsageScenarios/DotNetSlnRemoveScenario.cs b/CSharpInteractive.Tests/UsageScenarios/DotNetSlnRemoveScenario.cs new file mode 100644 index 00000000..0c1e812f --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/DotNetSlnRemoveScenario.cs @@ -0,0 +1,62 @@ +// ReSharper disable StringLiteralTypo +// ReSharper disable ObjectCreationAsStatement +// ReSharper disable ReturnValueOfPureMethodIsNotUsed +// ReSharper disable CommentTypo + +namespace CSharpInteractive.Tests.UsageScenarios; + +[CollectionDefinition("Integration", DisableParallelization = true)] +[Trait("Integration", "True")] +public class DotNetSlnRemoveScenario(ITestOutputHelper output) : BaseScenario(output) +{ + [Fact] + public void Run() + { + new DotNetNew() + .WithTemplateName("classlib") + .WithName("MyLib") + .WithForce(true) + .Run().EnsureSuccess(); + + new DotNetNew() + .WithTemplateName("xunit") + .WithName("MyTests") + .WithForce(true) + .Run().EnsureSuccess(); + + new DotNetNew() + .WithTemplateName("sln") + .WithName("NySolution") + .WithForce(true) + .Run().EnsureSuccess(); + + new DotNetSlnAdd() + .WithSolution("NySolution.sln") + .AddProjects( + Path.Combine("MyLib", "MyLib.csproj"), + Path.Combine("MyTests", "MyTests.csproj")) + .Run().EnsureSuccess(); + + // $visible=true + // $tag=07 .NET CLI + // $priority=01 + // $description=Adding projects to the solution file + // { + // ## using HostApi; + + new DotNetSlnRemove() + .WithSolution("NySolution.sln") + .AddProjects( + Path.Combine("MyLib", "MyLib.csproj")) + .Run().EnsureSuccess(); + // } + + var lines = new List(); + new DotNetSlnList() + .WithSolution("NySolution.sln") + .Run(output => lines.Add(output.Line)) + .EnsureSuccess(); + + lines.Count.ShouldBe(3); + } +} \ No newline at end of file diff --git a/CSharpInteractive.Tests/UsageScenarios/DotNetStoreScenario.cs b/CSharpInteractive.Tests/UsageScenarios/DotNetStoreScenario.cs new file mode 100644 index 00000000..9322bfdb --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/DotNetStoreScenario.cs @@ -0,0 +1,38 @@ +// ReSharper disable StringLiteralTypo +// ReSharper disable ObjectCreationAsStatement +// ReSharper disable ReturnValueOfPureMethodIsNotUsed +// ReSharper disable CommentTypo + +namespace CSharpInteractive.Tests.UsageScenarios; + +[CollectionDefinition("Integration", DisableParallelization = true)] +[Trait("Integration", "True")] +public class DotNetStoreScenario(ITestOutputHelper output) : BaseScenario(output) +{ + [Fact] + public void Run() + { + new DotNetNew() + .WithTemplateName("classlib") + .WithName("MyLib") + .WithForce(true) + .Run().EnsureSuccess(); + + // $visible=true + // $tag=07 .NET CLI + // $priority=01 + // $description=Storing the specified assemblies in the runtime package store. + // { + // ## using HostApi; + + new DotNetStore() + .AddManifests(Path.Combine("MyLib", "MyLib.csproj")) + .WithFramework("net8.0") + .WithRuntime("win-x64") + .Build(); + + // } + + new DotNetSdkCheck().Run(); + } +} \ No newline at end of file diff --git a/CSharpInteractive.Tests/UsageScenarios/DotNetTestScenario.cs b/CSharpInteractive.Tests/UsageScenarios/DotNetTestScenario.cs index 762f58d4..a2ad4a50 100644 --- a/CSharpInteractive.Tests/UsageScenarios/DotNetTestScenario.cs +++ b/CSharpInteractive.Tests/UsageScenarios/DotNetTestScenario.cs @@ -4,40 +4,35 @@ namespace CSharpInteractive.Tests.UsageScenarios; -using HostApi; - [CollectionDefinition("Integration", DisableParallelization = true)] -[Trait("Integration", "true")] -public class DotNetTestScenario : BaseScenario +[Trait("Integration", "True")] +public class DotNetTestScenario(ITestOutputHelper output) : BaseScenario(output) { [Fact] public void Run() { + new DotNetNew() + .WithTemplateName("mstest") + .WithName("MyTests") + .WithForce(true) + .Run().EnsureSuccess(); + // $visible=true // $tag=07 .NET CLI // $priority=01 // $description=Test a project // { - // Adds the namespace "HostApi" to use .NET build API // ## 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(); - - result.ExitCode.ShouldBe(0); - - // Runs tests via a command like: "dotnet test" from the directory "MyTests" - result = new DotNetTest() + // Runs tests + var result = new DotNetTest() .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); + // The "result" variable provides details about build and tests + 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()); // } } @@ -45,9 +40,12 @@ public void Run() public void RunAsCommandLine() { // Creates a new test project, running a command like: "dotnet new mstest -n MyTests --force" - var result = new DotNetNew("mstest", "-n", "MyTests", "--force").Build(); - result.ExitCode.ShouldBe(0); - + new DotNetNew() + .WithTemplateName("mstest") + .WithName("MyTests") + .WithForce(true) + .Build().EnsureSuccess(); + // Runs tests via a command like: "dotnet test" from the directory "MyTests" var lines = new List(); new DotNetTest() diff --git a/CSharpInteractive.Tests/UsageScenarios/DotNetTestWithDotCoverScenario.cs b/CSharpInteractive.Tests/UsageScenarios/DotNetTestWithDotCoverScenario.cs index bdd19d5a..a00f4d8e 100644 --- a/CSharpInteractive.Tests/UsageScenarios/DotNetTestWithDotCoverScenario.cs +++ b/CSharpInteractive.Tests/UsageScenarios/DotNetTestWithDotCoverScenario.cs @@ -4,38 +4,34 @@ namespace CSharpInteractive.Tests.UsageScenarios; -using HostApi; - [CollectionDefinition("Integration", DisableParallelization = true)] -[Trait("Integration", "true")] -public class DotNetTestWithDotCoverScenario : BaseScenario +[Trait("Integration", "True")] +public class DotNetTestWithDotCoverScenario(ITestOutputHelper output) : BaseScenario(output) { [Fact] public void Run() { + new DotNetNew() + .WithTemplateName("mstest") + .WithName("MyTests") + .WithForce(true) + .Run().EnsureSuccess(); + + new DotNetNew() + .WithTemplateName("tool-manifest") + .Run().EnsureSuccess(); + // $visible=true // $tag=07 .NET CLI // $priority=01 // $description=Run tests under dotCover // { - // Adds the namespace "HostApi" to use .NET build API // ## 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(); - - // 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 DotNetCustom("tool", "install", "--local", "JetBrains.dotCover.GlobalTool") - .Run() - .EnsureSuccess(); + new DotNetToolInstall() + .WithLocal(true) + .WithPackage("JetBrains.dotCover.GlobalTool") + .Run().EnsureSuccess(); // Creates a test command var test = new DotNetTest() @@ -54,21 +50,20 @@ public void Run() + "--dcFilters=+:module=TeamCity.CSharpInteractive.HostApi;+:module=dotnet-csi" + "--dcAttributeFilters=System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage"); - // Runs tests under dotCover via a command like: "dotnet dotcover test ..." + // Runs tests under dotCover var result = testUnderDotCover - .Build() - .EnsureSuccess(); + .Build().EnsureSuccess(); // The "result" variable provides details about a build - result.ExitCode.ShouldBe(0); - result.Tests.Count(i => i.State == TestState.Finished).ShouldBe(1); + result.ExitCode.ShouldBe(0, result.ToString()); + result.Tests.Count(i => i.State == TestState.Finished).ShouldBe(1, result.ToString()); // Generates a HTML code coverage report. new DotNetCustom("dotCover", "report", $"--source={dotCoverSnapshot}", $"--output={dotCoverReport}", "--reportType=HTML") .Run().EnsureSuccess(); + // } // Check for a dotCover report File.Exists(dotCoverReport).ShouldBeTrue(); - // } } } \ No newline at end of file diff --git a/CSharpInteractive.Tests/UsageScenarios/DotNetToolInstallScenario.cs b/CSharpInteractive.Tests/UsageScenarios/DotNetToolInstallScenario.cs new file mode 100644 index 00000000..393001e6 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/DotNetToolInstallScenario.cs @@ -0,0 +1,32 @@ +// ReSharper disable StringLiteralTypo +// ReSharper disable ObjectCreationAsStatement +// ReSharper disable ReturnValueOfPureMethodIsNotUsed +// ReSharper disable CommentTypo + +namespace CSharpInteractive.Tests.UsageScenarios; + +[CollectionDefinition("Integration", DisableParallelization = true)] +[Trait("Integration", "True")] +public class DotNetToolInstallScenario(ITestOutputHelper output) : BaseScenario(output) +{ + [Fact] + public void Run() + { + new DotNetNew() + .WithTemplateName("tool-manifest") + .Run().EnsureSuccess(); + + // $visible=true + // $tag=07 .NET CLI + // $priority=01 + // $description=Installing the specified .NET tool + // { + // ## using HostApi; + + new DotNetToolInstall() + .WithLocal(true) + .WithPackage("dotnet-csi") + .Run().EnsureSuccess(); + // } + } +} \ No newline at end of file diff --git a/CSharpInteractive.Tests/UsageScenarios/DotNetToolListScenario.cs b/CSharpInteractive.Tests/UsageScenarios/DotNetToolListScenario.cs new file mode 100644 index 00000000..8342f2a9 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/DotNetToolListScenario.cs @@ -0,0 +1,31 @@ +// ReSharper disable StringLiteralTypo +// ReSharper disable ObjectCreationAsStatement +// ReSharper disable ReturnValueOfPureMethodIsNotUsed +// ReSharper disable CommentTypo + +namespace CSharpInteractive.Tests.UsageScenarios; + +[CollectionDefinition("Integration", DisableParallelization = true)] +[Trait("Integration", "True")] +public class DotNetToolListScenario(ITestOutputHelper output) : BaseScenario(output) +{ + [Fact] + public void Run() + { + // $visible=true + // $tag=07 .NET CLI + // $priority=01 + // $description=Printing all .NET tools of the specified type currently installed + // { + // ## using HostApi; + + new DotNetToolList() + .WithLocal(true) + .Run().EnsureSuccess(); + + new DotNetToolList() + .WithGlobal(true) + .Run().EnsureSuccess(); + // } + } +} \ No newline at end of file diff --git a/CSharpInteractive.Tests/UsageScenarios/DotNetToolRestoreScenario.cs b/CSharpInteractive.Tests/UsageScenarios/DotNetToolRestoreScenario.cs index 54870bb1..3879e15f 100644 --- a/CSharpInteractive.Tests/UsageScenarios/DotNetToolRestoreScenario.cs +++ b/CSharpInteractive.Tests/UsageScenarios/DotNetToolRestoreScenario.cs @@ -5,11 +5,9 @@ namespace CSharpInteractive.Tests.UsageScenarios; -using HostApi; - [CollectionDefinition("Integration", DisableParallelization = true)] -[Trait("Integration", "true")] -public class DotNetToolRestoreScenario : BaseScenario +[Trait("Integration", "True")] +public class DotNetToolRestoreScenario(ITestOutputHelper output) : BaseScenario(output) { [Fact] public void Run() @@ -17,27 +15,17 @@ public void Run() // $visible=true // $tag=07 .NET CLI // $priority=01 - // $description=Restore local tools + // $description=Installing the .NET local tools that are in scope for the current directory // { - // Adds the namespace "HostApi" to use .NET build API // ## using HostApi; - var projectDir = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()[..4]); - Directory.CreateDirectory(projectDir); - // Creates a local tool manifest - new DotNetNew("tool-manifest") - .WithWorkingDirectory(projectDir) - .Run() - .EnsureSuccess(); + new DotNetNew() + .WithTemplateName("tool-manifest") + .Run().EnsureSuccess(); - // Restore local tools new DotNetToolRestore() - .WithWorkingDirectory(projectDir) - .Run() - .EnsureSuccess(); + .Run().EnsureSuccess(); // } - - Directory.Delete(projectDir, true); } } \ No newline at end of file diff --git a/CSharpInteractive.Tests/UsageScenarios/DotNetToolRunScenario.cs b/CSharpInteractive.Tests/UsageScenarios/DotNetToolRunScenario.cs new file mode 100644 index 00000000..4714369d --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/DotNetToolRunScenario.cs @@ -0,0 +1,46 @@ +// ReSharper disable StringLiteralTypo +// ReSharper disable ObjectCreationAsStatement +// ReSharper disable ReturnValueOfPureMethodIsNotUsed +// ReSharper disable CommentTypo + +namespace CSharpInteractive.Tests.UsageScenarios; + +[CollectionDefinition("Integration", DisableParallelization = true)] +[Trait("Integration", "True")] +public class DotNetToolRunScenario(ITestOutputHelper output) : BaseScenario(output) +{ + [Fact] + public void Run() + { + new DotNetNew() + .WithTemplateName("tool-manifest") + .Run().EnsureSuccess(); + + new DotNetToolInstall() + .WithLocal(true) + .WithPackage("dotnet-csi") + .Run().EnsureSuccess(); + + // $visible=true + // $tag=07 .NET CLI + // $priority=01 + // $description=Invoking a local tool + // { + // ## using HostApi; + + var script = Path.GetTempFileName(); + File.WriteAllText(script, "Console.WriteLine($\"Hello, {Args[0]}!\");"); + + var stdOut = new List(); + new DotNetToolRun() + .WithCommandName("dotnet-csi") + .AddArgs(script) + .AddArgs("World") + .Run(output => stdOut.Add(output.Line)) + .EnsureSuccess(); + + // Checks stdOut + stdOut.Contains("Hello, World!").ShouldBeTrue(); + // } + } +} \ No newline at end of file diff --git a/CSharpInteractive.Tests/UsageScenarios/DotNetToolSearchScenario.cs b/CSharpInteractive.Tests/UsageScenarios/DotNetToolSearchScenario.cs new file mode 100644 index 00000000..410a93f2 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/DotNetToolSearchScenario.cs @@ -0,0 +1,28 @@ +// ReSharper disable StringLiteralTypo +// ReSharper disable ObjectCreationAsStatement +// ReSharper disable ReturnValueOfPureMethodIsNotUsed +// ReSharper disable CommentTypo + +namespace CSharpInteractive.Tests.UsageScenarios; + +[CollectionDefinition("Integration", DisableParallelization = true)] +[Trait("Integration", "True")] +public class DotNetToolSearchScenario(ITestOutputHelper output) : BaseScenario(output) +{ + [Fact] + public void Run() + { + // $visible=true + // $tag=07 .NET CLI + // $priority=01 + // $description=Searching all .NET tools that are published to NuGet + // { + // ## using HostApi; + + new DotNetToolSearch() + .WithPackage("dotnet-csi") + .WithDetail(true) + .Run().EnsureSuccess(); + // } + } +} \ No newline at end of file diff --git a/CSharpInteractive.Tests/UsageScenarios/DotNetToolUninstallScenario.cs b/CSharpInteractive.Tests/UsageScenarios/DotNetToolUninstallScenario.cs new file mode 100644 index 00000000..f2aeb49f --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/DotNetToolUninstallScenario.cs @@ -0,0 +1,36 @@ +// ReSharper disable StringLiteralTypo +// ReSharper disable ObjectCreationAsStatement +// ReSharper disable ReturnValueOfPureMethodIsNotUsed +// ReSharper disable CommentTypo + +namespace CSharpInteractive.Tests.UsageScenarios; + +[CollectionDefinition("Integration", DisableParallelization = true)] +[Trait("Integration", "True")] +public class DotNetToolUninstallScenario(ITestOutputHelper output) : BaseScenario(output) +{ + [Fact] + public void Run() + { + new DotNetNew() + .WithTemplateName("tool-manifest") + .Run().EnsureSuccess(); + + new DotNetToolInstall() + .WithLocal(true) + .WithPackage("dotnet-csi") + .Run().EnsureSuccess(); + + // $visible=true + // $tag=07 .NET CLI + // $priority=01 + // $description=Uninstalling the specified .NET tool + // { + // ## using HostApi; + + new DotNetToolUninstall() + .WithPackage("dotnet-csi") + .Run().EnsureSuccess(); + // } + } +} \ No newline at end of file diff --git a/CSharpInteractive.Tests/UsageScenarios/DotNetToolUpdateScenario.cs b/CSharpInteractive.Tests/UsageScenarios/DotNetToolUpdateScenario.cs new file mode 100644 index 00000000..0ec12e2f --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/DotNetToolUpdateScenario.cs @@ -0,0 +1,37 @@ +// ReSharper disable StringLiteralTypo +// ReSharper disable ObjectCreationAsStatement +// ReSharper disable ReturnValueOfPureMethodIsNotUsed +// ReSharper disable CommentTypo + +namespace CSharpInteractive.Tests.UsageScenarios; + +[CollectionDefinition("Integration", DisableParallelization = true)] +[Trait("Integration", "True")] +public class DotNetToolUpdateScenario(ITestOutputHelper output) : BaseScenario(output) +{ + [Fact] + public void Run() + { + new DotNetNew() + .WithTemplateName("tool-manifest") + .Run().EnsureSuccess(); + + new DotNetToolInstall() + .WithLocal(true) + .WithPackage("dotnet-csi") + .Run().EnsureSuccess(); + + // $visible=true + // $tag=07 .NET CLI + // $priority=01 + // $description=Installing the specified .NET tool + // { + // ## using HostApi; + + new DotNetToolUpdate() + .WithLocal(true) + .WithPackage("dotnet-csi") + .Run().EnsureSuccess(); + // } + } +} \ No newline at end of file diff --git a/CSharpInteractive.Tests/UsageScenarios/DotNetVSTestScenario.cs b/CSharpInteractive.Tests/UsageScenarios/DotNetVSTestScenario.cs index 1ec2c8de..06df67d0 100644 --- a/CSharpInteractive.Tests/UsageScenarios/DotNetVSTestScenario.cs +++ b/CSharpInteractive.Tests/UsageScenarios/DotNetVSTestScenario.cs @@ -5,51 +5,44 @@ namespace CSharpInteractive.Tests.UsageScenarios; -using HostApi; - [CollectionDefinition("Integration", DisableParallelization = true)] -[Trait("Integration", "true")] -public class DotNetVSTestScenario : BaseScenario +[Trait("Integration", "True")] +public class DotNetVSTestScenario(ITestOutputHelper output) : BaseScenario(output) { [Fact] public void Run() { + var path = "MyTests"; + + new DotNetNew() + .WithTemplateName("mstest") + .WithName(path) + .WithForce(true) + .Run().EnsureSuccess(); + + new DotNetBuild() + .WithWorkingDirectory(path) + .WithConfiguration("Release") + .WithOutput("bin") + .Build().EnsureSuccess(); + // $visible=true // $tag=07 .NET CLI // $priority=01 - // $description=Test an assembly + // $description=Running tests from the specified assemblies // { - // Adds the namespace "HostApi" to use .NET build API // ## 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(); - - result.ExitCode.ShouldBe(0); + // Runs tests + var result = new VSTest() + .AddTestFileNames(Path.Combine("bin", "MyTests.dll")) + .WithWorkingDirectory(path) + .Build().EnsureSuccess(); - // Builds the test project, running a command like: "dotnet build -c Release" from the directory "MyTests" - result = new DotNetBuild() - .WithWorkingDirectory("MyTests") - .WithConfiguration("Release") - .WithOutput("MyOutput") - .Build() - .EnsureSuccess(); - - result.ExitCode.ShouldBe(0); - - // Runs tests via a command like: "dotnet vstest" from the directory "MyTests" - result = new VSTest() - .AddTestFileNames(Path.Combine("MyOutput", "MyTests.dll")) - .WithWorkingDirectory("MyTests") - .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); + // The "result" variable provides details about build and tests + 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()); // } } @@ -57,21 +50,18 @@ public void Run() public void RunAsCommandLine() { // 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(); - - result.ExitCode.ShouldBe(0); + new DotNetNew() + .WithTemplateName("mstest") + .WithName("MyTests") + .WithForce(true) + .Build().EnsureSuccess(); // Builds the test project, running a command like: "dotnet build -c Release" from the directory "MyTests" - result = new DotNetBuild() + new DotNetBuild() .WithWorkingDirectory("MyTests") .WithConfiguration("Release") .WithOutput("MyOutput") - .Build() - .EnsureSuccess(); - - result.ExitCode.ShouldBe(0); + .Build().EnsureSuccess(); // Runs tests via a command like: "dotnet vstest" from the directory "MyTests" var lines = new List(); diff --git a/CSharpInteractive.Tests/UsageScenarios/DotNetWorkloadConfigScenario.cs b/CSharpInteractive.Tests/UsageScenarios/DotNetWorkloadConfigScenario.cs new file mode 100644 index 00000000..a83e3bfd --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/DotNetWorkloadConfigScenario.cs @@ -0,0 +1,29 @@ +// ReSharper disable StringLiteralTypo +// ReSharper disable ObjectCreationAsStatement +// ReSharper disable ReturnValueOfPureMethodIsNotUsed +// ReSharper disable CommentTypo + +namespace CSharpInteractive.Tests.UsageScenarios; + +[CollectionDefinition("Integration", DisableParallelization = true)] +[Trait("Integration", "True")] +public class DotNetWorkloadConfigScenario(ITestOutputHelper output) : BaseScenario(output) +{ + [SkippableFact] + public void Run() + { + Skip.IfNot(HasSdk("8.0.10")); + + // $visible=true + // $tag=07 .NET CLI + // $priority=01 + // $description=Enabling or disabling workload-set update mode + // { + // ## using HostApi; + + new DotNetWorkloadConfig() + .WithUpdateMode(DotNetWorkloadUpdateMode.WorkloadSet) + .Run().EnsureSuccess(); + // } + } +} \ No newline at end of file diff --git a/CSharpInteractive.Tests/UsageScenarios/DotNetWorkloadInstallScenario.cs b/CSharpInteractive.Tests/UsageScenarios/DotNetWorkloadInstallScenario.cs new file mode 100644 index 00000000..4a50ecf3 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/DotNetWorkloadInstallScenario.cs @@ -0,0 +1,27 @@ +// ReSharper disable StringLiteralTypo +// ReSharper disable ObjectCreationAsStatement +// ReSharper disable ReturnValueOfPureMethodIsNotUsed +// ReSharper disable CommentTypo + +namespace CSharpInteractive.Tests.UsageScenarios; + +[CollectionDefinition("Integration", DisableParallelization = true)] +[Trait("Integration", "True")] +public class DotNetWorkloadInstallScenario(ITestOutputHelper output) : BaseScenario(output) +{ + [Fact(Skip = "Inadequate permissions. Run the command with elevated privileges.")] + public void Run() + { + // $visible=true + // $tag=07 .NET CLI + // $priority=01 + // $description=Installing optional workloads + // { + // ## using HostApi; + + new DotNetWorkloadInstall() + .AddWorkloads("aspire") + .Run().EnsureSuccess(); + // } + } +} \ No newline at end of file diff --git a/CSharpInteractive.Tests/UsageScenarios/DotNetWorkloadListScenario.cs b/CSharpInteractive.Tests/UsageScenarios/DotNetWorkloadListScenario.cs new file mode 100644 index 00000000..08e2fe5c --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/DotNetWorkloadListScenario.cs @@ -0,0 +1,26 @@ +// ReSharper disable StringLiteralTypo +// ReSharper disable ObjectCreationAsStatement +// ReSharper disable ReturnValueOfPureMethodIsNotUsed +// ReSharper disable CommentTypo + +namespace CSharpInteractive.Tests.UsageScenarios; + +[CollectionDefinition("Integration", DisableParallelization = true)] +[Trait("Integration", "True")] +public class DotNetWorkloadListScenario(ITestOutputHelper output) : BaseScenario(output) +{ + [Fact] + public void Run() + { + // $visible=true + // $tag=07 .NET CLI + // $priority=01 + // $description=Printing installed workloads + // { + // ## using HostApi; + + new DotNetWorkloadList() + .Run().EnsureSuccess(); + // } + } +} \ No newline at end of file diff --git a/CSharpInteractive.Tests/UsageScenarios/DotNetWorkloadRepairScenario.cs b/CSharpInteractive.Tests/UsageScenarios/DotNetWorkloadRepairScenario.cs new file mode 100644 index 00000000..1a36c603 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/DotNetWorkloadRepairScenario.cs @@ -0,0 +1,26 @@ +// ReSharper disable StringLiteralTypo +// ReSharper disable ObjectCreationAsStatement +// ReSharper disable ReturnValueOfPureMethodIsNotUsed +// ReSharper disable CommentTypo + +namespace CSharpInteractive.Tests.UsageScenarios; + +[CollectionDefinition("Integration", DisableParallelization = true)] +[Trait("Integration", "True")] +public class DotNetWorkloadRepairScenario(ITestOutputHelper output) : BaseScenario(output) +{ + [Fact(Skip = "Works too slow")] + public void Run() + { + // $visible=true + // $tag=07 .NET CLI + // $priority=01 + // $description=Repairing workloads installations + // { + // ## using HostApi; + + new DotNetWorkloadRepair() + .Run().EnsureSuccess(); + // } + } +} \ No newline at end of file diff --git a/CSharpInteractive.Tests/UsageScenarios/DotNetWorkloadRestoreScenario.cs b/CSharpInteractive.Tests/UsageScenarios/DotNetWorkloadRestoreScenario.cs new file mode 100644 index 00000000..8dbd0264 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/DotNetWorkloadRestoreScenario.cs @@ -0,0 +1,33 @@ +// ReSharper disable StringLiteralTypo +// ReSharper disable ObjectCreationAsStatement +// ReSharper disable ReturnValueOfPureMethodIsNotUsed +// ReSharper disable CommentTypo + +namespace CSharpInteractive.Tests.UsageScenarios; + +[CollectionDefinition("Integration", DisableParallelization = true)] +[Trait("Integration", "True")] +public class DotNetWorkloadRestoreScenario(ITestOutputHelper output) : BaseScenario(output) +{ + [Fact(Skip = "Inadequate permissions. Run the command with elevated privileges.")] + public void Run() + { + new DotNetNew() + .WithTemplateName("classlib") + .WithName("MyLib") + .WithForce(true) + .Run().EnsureSuccess(); + + // $visible=true + // $tag=07 .NET CLI + // $priority=01 + // $description=Installing workloads needed for a project or a solution + // { + // ## using HostApi; + + new DotNetWorkloadRestore() + .WithProject(Path.Combine("MyLib", "MyLib.csproj")) + .Run().EnsureSuccess(); + // } + } +} \ No newline at end of file diff --git a/CSharpInteractive.Tests/UsageScenarios/DotNetWorkloadSearchScenario.cs b/CSharpInteractive.Tests/UsageScenarios/DotNetWorkloadSearchScenario.cs new file mode 100644 index 00000000..ff8661f1 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/DotNetWorkloadSearchScenario.cs @@ -0,0 +1,27 @@ +// ReSharper disable StringLiteralTypo +// ReSharper disable ObjectCreationAsStatement +// ReSharper disable ReturnValueOfPureMethodIsNotUsed +// ReSharper disable CommentTypo + +namespace CSharpInteractive.Tests.UsageScenarios; + +[CollectionDefinition("Integration", DisableParallelization = true)] +[Trait("Integration", "True")] +public class DotNetWorkloadSearchScenario(ITestOutputHelper output) : BaseScenario(output) +{ + [Fact] + public void Run() + { + // $visible=true + // $tag=07 .NET CLI + // $priority=01 + // $description=Searching for optional workloads + // { + // ## using HostApi; + + new DotNetWorkloadSearch() + .WithSearchString("maui") + .Run().EnsureSuccess(); + // } + } +} \ No newline at end of file diff --git a/CSharpInteractive.Tests/UsageScenarios/DotNetWorkloadUninstallScenario.cs b/CSharpInteractive.Tests/UsageScenarios/DotNetWorkloadUninstallScenario.cs new file mode 100644 index 00000000..63b18d77 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/DotNetWorkloadUninstallScenario.cs @@ -0,0 +1,31 @@ +// ReSharper disable StringLiteralTypo +// ReSharper disable ObjectCreationAsStatement +// ReSharper disable ReturnValueOfPureMethodIsNotUsed +// ReSharper disable CommentTypo + +namespace CSharpInteractive.Tests.UsageScenarios; + +[CollectionDefinition("Integration", DisableParallelization = true)] +[Trait("Integration", "True")] +public class DotNetWorkloadUninstallScenario(ITestOutputHelper output) : BaseScenario(output) +{ + [Fact(Skip = "Inadequate permissions. Run the command with elevated privileges.")] + public void Run() + { + new DotNetWorkloadInstall() + .AddWorkloads("aspire") + .Run().EnsureSuccess(); + + // $visible=true + // $tag=07 .NET CLI + // $priority=01 + // $description=Uninstalling a specified workload + // { + // ## using HostApi; + + new DotNetWorkloadUninstall() + .AddWorkloads("aspire") + .Run().EnsureSuccess(); + // } + } +} \ No newline at end of file diff --git a/CSharpInteractive.Tests/UsageScenarios/DotNetWorkloadUpdateScenario.cs b/CSharpInteractive.Tests/UsageScenarios/DotNetWorkloadUpdateScenario.cs new file mode 100644 index 00000000..5e211bc8 --- /dev/null +++ b/CSharpInteractive.Tests/UsageScenarios/DotNetWorkloadUpdateScenario.cs @@ -0,0 +1,26 @@ +// ReSharper disable StringLiteralTypo +// ReSharper disable ObjectCreationAsStatement +// ReSharper disable ReturnValueOfPureMethodIsNotUsed +// ReSharper disable CommentTypo + +namespace CSharpInteractive.Tests.UsageScenarios; + +[CollectionDefinition("Integration", DisableParallelization = true)] +[Trait("Integration", "True")] +public class DotNetWorkloadUpdateScenario(ITestOutputHelper output) : BaseScenario(output) +{ + [Fact(Skip = "Inadequate permissions. Run the command with elevated privileges.")] + public void Run() + { + // $visible=true + // $tag=07 .NET CLI + // $priority=01 + // $description=Updating installed workloads + // { + // ## using HostApi; + + new DotNetWorkloadUpdate() + .Run().EnsureSuccess(); + // } + } +} \ No newline at end of file diff --git a/CSharpInteractive.Tests/UsageScenarios/GetServiceScenario.cs b/CSharpInteractive.Tests/UsageScenarios/GetServiceScenario.cs index 064b4797..89cad44c 100644 --- a/CSharpInteractive.Tests/UsageScenarios/GetServiceScenario.cs +++ b/CSharpInteractive.Tests/UsageScenarios/GetServiceScenario.cs @@ -4,9 +4,7 @@ namespace CSharpInteractive.Tests.UsageScenarios; -using HostApi; - -public class GetServiceScenario : BaseScenario +public class GetServiceScenario(ITestOutputHelper output) : BaseScenario(output) { [Fact] public void Run() diff --git a/CSharpInteractive.Tests/UsageScenarios/HostScenario.cs b/CSharpInteractive.Tests/UsageScenarios/HostScenario.cs index bdf1edd3..7827cef0 100644 --- a/CSharpInteractive.Tests/UsageScenarios/HostScenario.cs +++ b/CSharpInteractive.Tests/UsageScenarios/HostScenario.cs @@ -4,9 +4,7 @@ namespace CSharpInteractive.Tests.UsageScenarios; -using HostApi; - -public class HostScenario : BaseScenario +public class HostScenario(ITestOutputHelper output) : BaseScenario(output) { [Fact] public void Run() diff --git a/CSharpInteractive.Tests/UsageScenarios/LogErrorScenario.cs b/CSharpInteractive.Tests/UsageScenarios/LogErrorScenario.cs index c01a0d56..0a9f21d8 100644 --- a/CSharpInteractive.Tests/UsageScenarios/LogErrorScenario.cs +++ b/CSharpInteractive.Tests/UsageScenarios/LogErrorScenario.cs @@ -5,7 +5,7 @@ namespace CSharpInteractive.Tests.UsageScenarios; using System; -public class LogErrorScenario : BaseScenario +public class LogErrorScenario(ITestOutputHelper output) : BaseScenario(output) { [SkippableFact] public void Run() diff --git a/CSharpInteractive.Tests/UsageScenarios/LogInfoScenario.cs b/CSharpInteractive.Tests/UsageScenarios/LogInfoScenario.cs index 286b7bda..096a3250 100644 --- a/CSharpInteractive.Tests/UsageScenarios/LogInfoScenario.cs +++ b/CSharpInteractive.Tests/UsageScenarios/LogInfoScenario.cs @@ -5,7 +5,7 @@ namespace CSharpInteractive.Tests.UsageScenarios; using System; -public class LogInfoScenario : BaseScenario +public class LogInfoScenario(ITestOutputHelper output) : BaseScenario(output) { [SkippableFact] public void Run() diff --git a/CSharpInteractive.Tests/UsageScenarios/LogTraceScenario.cs b/CSharpInteractive.Tests/UsageScenarios/LogTraceScenario.cs index d8ab9e52..4ac6e525 100644 --- a/CSharpInteractive.Tests/UsageScenarios/LogTraceScenario.cs +++ b/CSharpInteractive.Tests/UsageScenarios/LogTraceScenario.cs @@ -5,7 +5,7 @@ namespace CSharpInteractive.Tests.UsageScenarios; using System; -public class LogTraceScenario : BaseScenario +public class LogTraceScenario(ITestOutputHelper output) : BaseScenario(output) { [SkippableFact] public void Run() diff --git a/CSharpInteractive.Tests/UsageScenarios/LogWarningScenario.cs b/CSharpInteractive.Tests/UsageScenarios/LogWarningScenario.cs index 6dd45aa3..1a36fdf3 100644 --- a/CSharpInteractive.Tests/UsageScenarios/LogWarningScenario.cs +++ b/CSharpInteractive.Tests/UsageScenarios/LogWarningScenario.cs @@ -5,7 +5,7 @@ namespace CSharpInteractive.Tests.UsageScenarios; using System; -public class LogWarningScenario : BaseScenario +public class LogWarningScenario(ITestOutputHelper output) : BaseScenario(output) { [SkippableFact] public void Run() diff --git a/CSharpInteractive.Tests/UsageScenarios/MSBuildScenario.cs b/CSharpInteractive.Tests/UsageScenarios/MSBuildScenario.cs index da4c8042..a9d86985 100644 --- a/CSharpInteractive.Tests/UsageScenarios/MSBuildScenario.cs +++ b/CSharpInteractive.Tests/UsageScenarios/MSBuildScenario.cs @@ -6,11 +6,9 @@ namespace CSharpInteractive.Tests.UsageScenarios; -using HostApi; - [CollectionDefinition("Integration", DisableParallelization = true)] -[Trait("Integration", "true")] -public class MSBuildScenario : BaseScenario +[Trait("Integration", "True")] +public class MSBuildScenario(ITestOutputHelper output) : BaseScenario(output) { [Fact] public void Run() @@ -20,29 +18,27 @@ public void Run() // $priority=01 // $description=Build a project using MSBuild // { - // Adds the namespace "HostApi" to use .NET build API // ## 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(); - - result.ExitCode.ShouldBe(0); + new DotNetNew() + .WithTemplateName("classlib") + .WithName("MyLib") + .WithForce(true) + .Build().EnsureSuccess(); // Builds the library project, running a command like: "dotnet msbuild /t:Build -restore /p:configuration=Release -verbosity=detailed" from the directory "MyLib" - result = new MSBuild() + var result = new MSBuild() .WithWorkingDirectory("MyLib") .WithTarget("Build") .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(); - result.ExitCode.ShouldBe(0); + result.Errors.Any(message => message.State == BuildMessageState.StdError).ShouldBeFalse(result.ToString()); + result.ExitCode.ShouldBe(0, result.ToString()); // } } } \ No newline at end of file diff --git a/CSharpInteractive.Tests/UsageScenarios/NuGetRestoreAdvanced.cs b/CSharpInteractive.Tests/UsageScenarios/NuGetRestoreAdvanced.cs index 807fdf55..ccc8b2f0 100644 --- a/CSharpInteractive.Tests/UsageScenarios/NuGetRestoreAdvanced.cs +++ b/CSharpInteractive.Tests/UsageScenarios/NuGetRestoreAdvanced.cs @@ -3,12 +3,11 @@ namespace CSharpInteractive.Tests.UsageScenarios; -using HostApi; using NuGet.Versioning; [CollectionDefinition("Integration", DisableParallelization = true)] -[Trait("Integration", "true")] -public class NuGetRestoreAdvanced : BaseScenario +[Trait("Integration", "True")] +public class NuGetRestoreAdvanced(ITestOutputHelper output) : BaseScenario(output) { [SkippableFact] public void Run() @@ -18,7 +17,6 @@ public void Run() // $priority=01 // $description=Restore a NuGet package by a version range for the specified .NET and path // { - // Adds the namespace "HostApi" to use INuGet // ## using HostApi; var packagesPath = Path.Combine( diff --git a/CSharpInteractive.Tests/UsageScenarios/NuGetRestoreScenario.cs b/CSharpInteractive.Tests/UsageScenarios/NuGetRestoreScenario.cs index 2a396995..42f1478d 100644 --- a/CSharpInteractive.Tests/UsageScenarios/NuGetRestoreScenario.cs +++ b/CSharpInteractive.Tests/UsageScenarios/NuGetRestoreScenario.cs @@ -3,12 +3,11 @@ namespace CSharpInteractive.Tests.UsageScenarios; -using HostApi; using NuGet.Versioning; [CollectionDefinition("Integration", DisableParallelization = true)] -[Trait("Integration", "true")] -public class NuGetRestoreScenario : BaseScenario +[Trait("Integration", "True")] +public class NuGetRestoreScenario(ITestOutputHelper output) : BaseScenario(output) { [SkippableFact] public void Run() @@ -18,7 +17,6 @@ public void Run() // $priority=00 // $description=Restore NuGet a package of newest version // { - // Adds the namespace "HostApi" to use INuGet // ## using HostApi; IEnumerable packages = GetService() diff --git a/CSharpInteractive.Tests/UsageScenarios/PropsScenario.cs b/CSharpInteractive.Tests/UsageScenarios/PropsScenario.cs index 9279faff..d090e5eb 100644 --- a/CSharpInteractive.Tests/UsageScenarios/PropsScenario.cs +++ b/CSharpInteractive.Tests/UsageScenarios/PropsScenario.cs @@ -3,7 +3,7 @@ namespace CSharpInteractive.Tests.UsageScenarios; -public class PropsScenario : BaseScenario +public class PropsScenario(ITestOutputHelper output) : BaseScenario(output) { [Fact] public void Run() diff --git a/CSharpInteractive.Tests/UsageScenarios/ServiceCollectionScenario.cs b/CSharpInteractive.Tests/UsageScenarios/ServiceCollectionScenario.cs index 6d602641..869b9451 100644 --- a/CSharpInteractive.Tests/UsageScenarios/ServiceCollectionScenario.cs +++ b/CSharpInteractive.Tests/UsageScenarios/ServiceCollectionScenario.cs @@ -3,10 +3,9 @@ namespace CSharpInteractive.Tests.UsageScenarios; -using HostApi; using Microsoft.Extensions.DependencyInjection; -public class ServiceCollectionScenario : BaseScenario +public class ServiceCollectionScenario(ITestOutputHelper output) : BaseScenario(output) { [Fact] // $visible=true diff --git a/CSharpInteractive.Tests/UsageScenarios/TeamCityServiceMessagesScenario.cs b/CSharpInteractive.Tests/UsageScenarios/TeamCityServiceMessagesScenario.cs index 0c9fab16..f64eca0d 100644 --- a/CSharpInteractive.Tests/UsageScenarios/TeamCityServiceMessagesScenario.cs +++ b/CSharpInteractive.Tests/UsageScenarios/TeamCityServiceMessagesScenario.cs @@ -6,7 +6,7 @@ namespace CSharpInteractive.Tests.UsageScenarios; using System; using JetBrains.TeamCity.ServiceMessages.Write.Special; -public class TeamCityServiceMessagesScenario : BaseScenario +public class TeamCityServiceMessagesScenario(ITestOutputHelper output) : BaseScenario(output) { [SkippableFact] public void Run() diff --git a/CSharpInteractive.Tests/UsageScenarios/WriteEmptyLineScenario.cs b/CSharpInteractive.Tests/UsageScenarios/WriteEmptyLineScenario.cs index 05967710..9934f5b0 100644 --- a/CSharpInteractive.Tests/UsageScenarios/WriteEmptyLineScenario.cs +++ b/CSharpInteractive.Tests/UsageScenarios/WriteEmptyLineScenario.cs @@ -3,7 +3,7 @@ namespace CSharpInteractive.Tests.UsageScenarios; -public class WriteEmptyLineScenario : BaseScenario +public class WriteEmptyLineScenario(ITestOutputHelper output) : BaseScenario(output) { [Fact] public void Run() diff --git a/CSharpInteractive.Tests/UsageScenarios/WriteLineScenario.cs b/CSharpInteractive.Tests/UsageScenarios/WriteLineScenario.cs index 3dbd5a11..ddb49eab 100644 --- a/CSharpInteractive.Tests/UsageScenarios/WriteLineScenario.cs +++ b/CSharpInteractive.Tests/UsageScenarios/WriteLineScenario.cs @@ -3,7 +3,7 @@ namespace CSharpInteractive.Tests.UsageScenarios; -public class WriteLineScenario : BaseScenario +public class WriteLineScenario(ITestOutputHelper output) : BaseScenario(output) { [Fact] public void Run() diff --git a/CSharpInteractive.Tests/UsageScenarios/WriteLineWithColourScenario.cs b/CSharpInteractive.Tests/UsageScenarios/WriteLineWithColourScenario.cs index 49d23433..55e233ff 100644 --- a/CSharpInteractive.Tests/UsageScenarios/WriteLineWithColourScenario.cs +++ b/CSharpInteractive.Tests/UsageScenarios/WriteLineWithColourScenario.cs @@ -5,8 +5,9 @@ namespace CSharpInteractive.Tests.UsageScenarios; using static HostApi.Color; -public class WriteLineWithColourScenario : BaseScenario +public class WriteLineWithColourScenario(ITestOutputHelper output) : BaseScenario(output) { + [Fact] public void Run() { diff --git a/CSharpInteractive.sln b/CSharpInteractive.sln index fe16dd53..52d35c72 100644 --- a/CSharpInteractive.sln +++ b/CSharpInteractive.sln @@ -16,6 +16,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution", "Solution", "{12 LICENSE = LICENSE README_BODY.md = README_BODY.md README.md = README.md + .github\workflows\main.yml = .github\workflows\main.yml EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Samples", "Samples", "{CE315710-ACE8-4CAC-B030-4778257652DB}" diff --git a/CSharpInteractive.sln.DotSettings b/CSharpInteractive.sln.DotSettings index 4693855f..dab50d27 100644 --- a/CSharpInteractive.sln.DotSettings +++ b/CSharpInteractive.sln.DotSettings @@ -294,15 +294,20 @@ } } C:\Users\Nikolay.Pianikov\AppData\Local\JetBrains\Shared\vAny\Sessions + True + True True True True + True True True True True True + True True + True True True True @@ -316,15 +321,20 @@ True True True + True True + True True True True True True + True + True True True True + True True True True \ No newline at end of file diff --git a/CSharpInteractive/CSharpInteractive.Tool.csproj b/CSharpInteractive/CSharpInteractive.Tool.csproj index 8e9d661d..a2ff4a51 100644 --- a/CSharpInteractive/CSharpInteractive.Tool.csproj +++ b/CSharpInteractive/CSharpInteractive.Tool.csproj @@ -48,15 +48,15 @@ - + - + - + diff --git a/CSharpInteractive/CSharpInteractive.csproj b/CSharpInteractive/CSharpInteractive.csproj index baff6e5f..1be78c54 100644 --- a/CSharpInteractive/CSharpInteractive.csproj +++ b/CSharpInteractive/CSharpInteractive.csproj @@ -42,15 +42,15 @@ - + - + - + diff --git a/CSharpInteractive/Core/Console.cs b/CSharpInteractive/Core/Console.cs index 65771b97..fb4b259c 100644 --- a/CSharpInteractive/Core/Console.cs +++ b/CSharpInteractive/Core/Console.cs @@ -4,10 +4,13 @@ // ReSharper disable once ClassNeverInstantiated.Global [ExcludeFromCodeCoverage] -internal class Console(IColorTheme colorTheme) : IConsole +internal class Console(IColorTheme colorTheme) : IConsole, IConsoleHandler { private readonly object _lockObject = new(); private readonly ConsoleColor _errorColor = colorTheme.GetConsoleColor(Color.Error); + + public event EventHandler? OutputHandler; + public event EventHandler? ErrorHandler; public void WriteToOut(params (ConsoleColor? color, string output)[] text) { @@ -23,6 +26,11 @@ public void WriteToOut(params (ConsoleColor? color, string output)[] text) System.Console.ForegroundColor = color.Value; } + if (OutputHandler is { } outputHandler) + { + outputHandler(this, output); + } + System.Console.Out.Write(output); } } @@ -41,9 +49,14 @@ public void WriteToErr(params string[] text) try { System.Console.ForegroundColor = _errorColor; - foreach (var item in text) + foreach (var error in text) { - System.Console.Error.Write(item); + if (ErrorHandler is { } errorHandler) + { + errorHandler(this, error); + } + + System.Console.Error.Write(error); } } finally diff --git a/CSharpInteractive/Core/IConsoleHandler.cs b/CSharpInteractive/Core/IConsoleHandler.cs new file mode 100644 index 00000000..2cacea8e --- /dev/null +++ b/CSharpInteractive/Core/IConsoleHandler.cs @@ -0,0 +1,8 @@ +namespace CSharpInteractive.Core; + +internal interface IConsoleHandler +{ + event EventHandler OutputHandler; + + event EventHandler ErrorHandler; +} \ No newline at end of file diff --git a/CSharpInteractive/Core/Settings.cs b/CSharpInteractive/Core/Settings.cs index 1def7f7d..f9125e29 100644 --- a/CSharpInteractive/Core/Settings.cs +++ b/CSharpInteractive/Core/Settings.cs @@ -125,6 +125,8 @@ private void EnsureLoaded() props[key] = value; } + _showHelpAndExit = args.Any(i => i.ArgumentType == CommandLineArgumentType.Help); + _showVersionAndExit = args.Any(i => i.ArgumentType == CommandLineArgumentType.Version); _nuGetSources = args.Where(i => i.ArgumentType == CommandLineArgumentType.NuGetSource).Select(i => i.Value); if (runningMode == RunningMode.Application || args.Any(i => i.ArgumentType == CommandLineArgumentType.ScriptFile) @@ -132,8 +134,6 @@ private void EnsureLoaded() { _interactionMode = InteractionMode.NonInteractive; _verbosityLevel = VerbosityLevel.Normal; - _showHelpAndExit = args.Any(i => i.ArgumentType == CommandLineArgumentType.Help); - _showVersionAndExit = args.Any(i => i.ArgumentType == CommandLineArgumentType.Version); _scriptArguments = args.Where(i => i.ArgumentType == CommandLineArgumentType.ScriptArgument).Select(i => i.Value).ToImmutableArray(); _codeSources = args.Where(i => i.ArgumentType == CommandLineArgumentType.ScriptFile).Select(i => fileCodeSourceFactory(i.Value)); } diff --git a/CSharpInteractive/Root.cs b/CSharpInteractive/Root.cs index 1c0995ee..26064a03 100644 --- a/CSharpInteractive/Root.cs +++ b/CSharpInteractive/Root.cs @@ -28,14 +28,14 @@ internal record Root( IDotNetEnvironment DotNetEnvironment, INuGet NuGet, IServiceMessageParser ServiceMessageParser, - ITeamCityWriter TeamCityWriter) : IServiceProvider + ITeamCityWriter TeamCityWriter, + IConsoleHandler ConsoleHandler) : IServiceProvider { private readonly Lazy _serviceProvider = new(() => { var serviceCollection = new ServiceCollection(); serviceCollection.AddTransient(_ => serviceCollection); serviceCollection.AddTransient(_ => Host); - serviceCollection.AddTransient(_ => Host); serviceCollection.AddTransient(_ => HostComponents); serviceCollection.AddTransient(_ => NuGet); serviceCollection.AddTransient(_ => CommandLineRunner); diff --git a/README.md b/README.md index 0d9fec10..28526dff 100644 --- a/README.md +++ b/README.md @@ -150,19 +150,75 @@ The created project contains 2 entry points: - [Build a project in a docker container](#build-a-project-in-a-docker-container) - [Running in docker](#running-in-docker) - .NET CLI + - [Adding a NuGet package](#adding-a-nuget-package) + - [Adding a NuGet package](#adding-a-nuget-package) + - [Adding a NuGet source](#adding-a-nuget-source) + - [Adding a project reference](#adding-a-project-reference) + - [Adding projects to the solution file](#adding-projects-to-the-solution-file) + - [Adding projects to the solution file](#adding-projects-to-the-solution-file) - [Build a project](#build-a-project) - [Build a project using MSBuild](#build-a-project-using-msbuild) - [Clean a project](#clean-a-project) - - [Pack a project](#pack-a-project) - - [Publish a project](#publish-a-project) - - [Restore a project](#restore-a-project) - - [Restore local tools](#restore-local-tools) + - [Clearing the specified NuGet cache type](#clearing-the-specified-nuget-cache-type) + - [Creating a new project from template](#creating-a-new-project-from-template) + - [Deleting a NuGet package to the server](#deleting-a-nuget-package-to-the-server) + - [Disabling a NuGet source](#disabling-a-nuget-source) + - [Display template package metadata](#display-template-package-metadata) + - [Enabling a NuGet source](#enabling-a-nuget-source) + - [Enabling or disabling workload-set update mode](#enabling-or-disabling-workload-set-update-mode) + - [Execute a dotnet application](#execute-a-dotnet-application) + - [Fix (non code style) analyzer issues](#fix-(non-code-style)-analyzer-issues) + - [Fix code style issues](#fix-code-style-issues) + - [Format a code](#format-a-code) + - [Gets the value of a specified NuGet configuration setting](#gets-the-value-of-a-specified-nuget-configuration-setting) + - [Installing a template package](#installing-a-template-package) + - [Installing optional workloads](#installing-optional-workloads) + - [Installing the .NET local tools that are in scope for the current directory](#installing-the-.net-local-tools-that-are-in-scope-for-the-current-directory) + - [Installing the specified .NET tool](#installing-the-specified-.net-tool) + - [Installing the specified .NET tool](#installing-the-specified-.net-tool) + - [Installing workloads needed for a project or a solution](#installing-workloads-needed-for-a-project-or-a-solution) + - [Invoking a local tool](#invoking-a-local-tool) + - [List available templates](#list-available-templates) + - [NuGet package listing](#nuget-package-listing) + - [Packing the code into a NuGet package](#packing-the-code-into-a-nuget-package) + - [Printing all .NET tools of the specified type currently installed](#printing-all-.net-tools-of-the-specified-type-currently-installed) + - [Printing all configured NuGet sources](#printing-all-configured-nuget-sources) + - [Printing all projects in a solution file](#printing-all-projects-in-a-solution-file) + - [Printing installed workloads](#printing-installed-workloads) + - [Printing nuget configuration files currently being applied to a directory](#printing-nuget-configuration-files-currently-being-applied-to-a-directory) + - [Printing the latest available version of the .NET SDK and .NET Runtime, for each feature band](#printing-the-latest-available-version-of-the-.net-sdk-and-.net-runtime,-for-each-feature-band) + - [Printing the location of the specified NuGet cache type](#printing-the-location-of-the-specified-nuget-cache-type) + - [Project reference listing](#project-reference-listing) + - [Publishing the application and its dependencies to a folder for deployment to a hosting system](#publishing-the-application-and-its-dependencies-to-a-folder-for-deployment-to-a-hosting-system) + - [Pushing a NuGet package to the server](#pushing-a-nuget-package-to-the-server) + - [Removing a NuGet package](#removing-a-nuget-package) + - [Removing a NuGet source.](#removing-a-nuget-source.) + - [Repairing workloads installations](#repairing-workloads-installations) + - [Restoring the dependencies and tools of a project](#restoring-the-dependencies-and-tools-of-a-project) - [Run a custom .NET command](#run-a-custom-.net-command) - - [Run a project](#run-a-project) + - [Run a dotnet application](#run-a-dotnet-application) - [Run tests under dotCover](#run-tests-under-dotcover) + - [Running source code without any explicit compile or launch commands](#running-source-code-without-any-explicit-compile-or-launch-commands) + - [Running tests from the specified assemblies](#running-tests-from-the-specified-assemblies) + - [Searche for the templates](#searche-for-the-templates) + - [Searching all .NET tools that are published to NuGet](#searching-all-.net-tools-that-are-published-to-nuget) + - [Searching for a NuGet package](#searching-for-a-nuget-package) + - [Searching for optional workloads](#searching-for-optional-workloads) + - [Sets the value of a specified NuGet configuration setting](#sets-the-value-of-a-specified-nuget-configuration-setting) + - [Show the dependency graph for NuGet package](#show-the-dependency-graph-for-nuget-package) + - [Signing with certificate](#signing-with-certificate) + - [Storing the specified assemblies in the runtime package store.](#storing-the-specified-assemblies-in-the-runtime-package-store.) - [Test a project](#test-a-project) - [Test a project using the MSBuild VSTest target](#test-a-project-using-the-msbuild-vstest-target) - - [Test an assembly](#test-an-assembly) + - [Uninstalling a specified workload](#uninstalling-a-specified-workload) + - [Uninstalling a template package](#uninstalling-a-template-package) + - [Uninstalling the specified .NET tool](#uninstalling-the-specified-.net-tool) + - [Unsets the value of a specified NuGet configuration setting](#unsets-the-value-of-a-specified-nuget-configuration-setting) + - [Updating a NuGet source](#updating-a-nuget-source) + - [Updating installed template packages](#updating-installed-template-packages) + - [Updating installed workloads](#updating-installed-workloads) + - [Working with development certificates](#working-with-development-certificates) + - [Run C# script](#run-c#-script) - [Shuts down build servers](#shuts-down-build-servers) - TeamCity API - [TeamCity integration via service messages](#teamcity-integration-via-service-messages) @@ -328,7 +384,6 @@ private class MyTask(ICommandLineRunner runner) ``` CSharp -// Adds the namespace "HostApi" to use INuGet using HostApi; IEnumerable packages = GetService() @@ -342,7 +397,6 @@ IEnumerable packages = GetService() ``` CSharp -// Adds the namespace "HostApi" to use INuGet using HostApi; var packagesPath = Path.Combine( @@ -364,7 +418,6 @@ IEnumerable packages = GetService().Restore(settings); ``` CSharp -// Adds the namespace "Script.Cmd" to use Command Line API using HostApi; // Creates and run a simple command line @@ -379,20 +432,16 @@ new CommandLine("cmd", "/c", "echo", "Hello").Run(); // Same as previous statement new CommandLine("cmd", "/c") .AddArgs("echo", "Hello") - .Run() - .EnsureSuccess(); + .Run().EnsureSuccess(); (new CommandLine("cmd") + "/c" + "echo" + "Hello") - .Run() - .EnsureSuccess(); + .Run().EnsureSuccess(); "cmd".AsCommandLine("/c", "echo", "Hello") - .Run() - .EnsureSuccess(); + .Run().EnsureSuccess(); ("cmd".AsCommandLine() + "/c" + "echo" + "Hello") - .Run() - .EnsureSuccess(); + .Run().EnsureSuccess(); // Just builds a command line with multiple environment variables var cmd = new CommandLine("cmd", "/c", "echo", "Hello") @@ -417,17 +466,14 @@ cmd = new CommandLine("cmd", "/c", "echo", "Hello") ``` CSharp -// Adds the namespace "HostApi" to use Command Line API using HostApi; GetService() - .Run(new CommandLine("cmd", "/c", "DIR")) - .EnsureSuccess(); + .Run(new CommandLine("cmd", "/c", "DIR")).EnsureSuccess(); // or the same thing using the extension method new CommandLine("cmd", "/c", "DIR") - .Run() - .EnsureSuccess(); + .Run().EnsureSuccess(); // using operator '+' var cmd = new CommandLine("cmd") + "/c" + "DIR"; @@ -445,17 +491,14 @@ cmd.Run().EnsureSuccess(); ``` CSharp -// Adds the namespace "HostApi" to use Command Line API using HostApi; await GetService() - .RunAsync(new CommandLine("cmd", "/C", "DIR")) - .EnsureSuccess(); + .RunAsync(new CommandLine("cmd", "/C", "DIR")).EnsureSuccess(); // or the same thing using the extension method var result = await new CommandLine("cmd", "/c", "DIR") - .RunAsync() - .EnsureSuccess(); + .RunAsync().EnsureSuccess(); ``` @@ -465,14 +508,12 @@ var result = await new CommandLine("cmd", "/c", "DIR") ``` CSharp -// Adds the namespace "HostApi" to use Command Line API using HostApi; var lines = new List(); var result = new CommandLine("cmd", "/c", "SET") .AddVars(("MyEnv", "MyVal")) - .Run(output => lines.Add(output.Line)) - .EnsureSuccess(); + .Run(output => lines.Add(output.Line)).EnsureSuccess(); lines.ShouldContain("MyEnv=MyVal"); ``` @@ -484,16 +525,13 @@ lines.ShouldContain("MyEnv=MyVal"); ``` CSharp -// Adds the namespace "HostApi" to use Command Line API using HostApi; var task = new CommandLine("cmd", "/c", "DIR") - .RunAsync() - .EnsureSuccess(); + .RunAsync().EnsureSuccess(); var result = new CommandLine("cmd", "/c", "SET") - .Run() - .EnsureSuccess(); + .Run().EnsureSuccess(); await task; ``` @@ -505,7 +543,6 @@ await task; Cancellation will destroy the process and its child processes. ``` CSharp -// Adds the namespace "HostApi" to use Command Line API using HostApi; var cancellationTokenSource = new CancellationTokenSource(); @@ -523,15 +560,11 @@ task.IsCompleted.ShouldBeFalse(); If timeout expired a process will be killed. ``` CSharp -// Adds the namespace "HostApi" to use Command Line API using HostApi; -int? exitCode = new CommandLine("cmd", "/c", "TIMEOUT", "/T", "120") +var exitCode = new CommandLine("cmd", "/c", "TIMEOUT", "/T", "120") .Run(default, TimeSpan.FromMilliseconds(1)) - .EnsureSuccess() .ExitCode; - -exitCode.HasValue.ShouldBeFalse(); ``` @@ -541,7 +574,6 @@ exitCode.HasValue.ShouldBeFalse(); ``` CSharp -// Adds the namespace "HostApi" to use .NET build API and Docker API using HostApi; // Creates a base docker command line @@ -553,22 +585,15 @@ var dockerRun = new DockerRun() .WithContainerWorkingDirectory("/MyProjects") .AddVolumes((ToAbsoluteLinuxPath(Environment.CurrentDirectory), "/MyProjects")); - // Creates a new library project in a docker container dockerRun .WithCommandLine(new DotNetCustom("new", "classlib", "-n", "MyLib", "--force")) - .Run() - .EnsureSuccess(); + .Run().EnsureSuccess(); // Builds the library project in a docker container var result = dockerRun .WithCommandLine(new DotNetBuild().WithProject("MyLib/MyLib.csproj")) - .Build() - .EnsureSuccess(); - -// The "result" variable provides details about a build -result.Errors.Any(message => message.State == BuildMessageState.StdError).ShouldBeFalse(); -result.ExitCode.ShouldBe(0); + .Build().EnsureSuccess(); string ToAbsoluteLinuxPath(string path) => "/" + path.Replace(":", "").Replace('\\', '/'); @@ -581,7 +606,6 @@ string ToAbsoluteLinuxPath(string path) => ``` CSharp -// Adds the namespace "HostApi" to use Command Line API and Docker API using HostApi; // Creates some command line to run in a docker container @@ -590,79 +614,71 @@ var cmd = new CommandLine("whoami"); // Runs the command line in a docker container var result = new DockerRun(cmd, "mcr.microsoft.com/dotnet/sdk") .WithAutoRemove(true) - .Run() - .EnsureSuccess(); + .Run().EnsureSuccess(); ``` -### Build a project +### Adding a NuGet package ``` CSharp -// Adds the namespace "HostApi" to use .NET build API 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(); - -// Builds the library project, running a command like: "dotnet build" from the directory "MyLib" -var result = new DotNetBuild() +var result = new DotNetAddPackage() .WithWorkingDirectory("MyLib") - .Build() - .EnsureSuccess(); + .WithPackage("Pure.DI") + .Run().EnsureSuccess(); +``` -// The "result" variable provides details about a build -result.Errors.Any(message => message.State == BuildMessageState.StdError).ShouldBeFalse(); -result.ExitCode.ShouldBe(0); -// Runs tests in docker -result = new DotNetTest() - .WithWorkingDirectory("MyLib") - .Build() - .EnsureSuccess(); -result.ExitCode.ShouldBe(0); -result.Summary.Tests.ShouldBe(1); -result.Tests.Count(test => test.State == TestState.Finished).ShouldBe(1); +### Adding a NuGet package + + + +``` CSharp +using HostApi; + +var result = new DotNetAddReference() + .WithProject(Path.Combine("MyTests", "MyTests.csproj")) + .WithReferences(Path.Combine("MyLib", "MyLib.csproj")) + .Run().EnsureSuccess(); + ``` -### Clean a project +### Build a project ``` CSharp -// Adds the namespace "HostApi" to use .NET build API 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 messages = new List(); +var result = new DotNetBuild() + .WithWorkingDirectory("MyTests") + .Build(message => messages.Add(message)).EnsureSuccess(); -result.ExitCode.ShouldBe(0); +result.Errors.Any(message => message.State == BuildMessageState.StdError).ShouldBeFalse(result.ToString()); +result.ExitCode.ShouldBe(0, result.ToString()); +``` -// Builds the library project, running a command like: "dotnet build" from the directory "MyLib" -result = new DotNetBuild() - .WithWorkingDirectory("MyLib") - .Build() - .EnsureSuccess(); -result.ExitCode.ShouldBe(0); + +### Clean a project + + + +``` CSharp +using HostApi; // Clean the project, running a command like: "dotnet clean" from the directory "MyLib" -result = new DotNetClean() +new DotNetClean() .WithWorkingDirectory("MyLib") - .Build() - .EnsureSuccess(); - -// The "result" variable provides details about a build -result.ExitCode.ShouldBe(0); + .Build().EnsureSuccess(); ``` @@ -672,7 +688,6 @@ result.ExitCode.ShouldBe(0); ``` CSharp -// Adds the namespace "HostApi" to use .NET build API using HostApi; // Gets the dotnet version, running a command like: "dotnet --version" @@ -686,344 +701,1131 @@ version.ShouldNotBeNull(); -### Test a project using the MSBuild VSTest target +### Working with development certificates ``` CSharp -// Adds the namespace "HostApi" to use .NET build API 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(); +// Create a certificate, trust it, and export it to a PEM file. +new DotNetDevCertsHttps() + .WithExportPath("certificate.pem") + .WithTrust(true) + .WithFormat(DotNetCertificateFormat.Pem) + .WithPassword("Abc") + .Run().EnsureSuccess(); +``` -result.ExitCode.ShouldBe(0); -// Runs tests via a command like: "dotnet msbuild /t:VSTest" from the directory "MyTests" -result = new MSBuild() - .WithTarget("VSTest") - .WithWorkingDirectory("MyTests") - .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); +### Execute a dotnet application + + + +``` CSharp +using HostApi; +new DotNetExec() + .WithPathToApplication(Path.Combine(path, "MyApp.dll")) + .Run().EnsureSuccess(); ``` -### Pack a project +### Fix (non code style) analyzer issues ``` CSharp -// Adds the namespace "HostApi" to use .NET build API 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(); +new DotNetFormatAnalyzers() + .WithWorkingDirectory("MyLib") + .WithProject("MyLib.csproj") + .AddDiagnostics("CA1831", "CA1832") + .WithSeverity(DotNetFormatSeverity.Warning) + .Run().EnsureSuccess(); +``` -result.ExitCode.ShouldBe(0); -// Creates a NuGet package of version 1.2.3 for the project, running a command like: "dotnet pack /p:version=1.2.3" from the directory "MyLib" -result = new DotNetPack() - .WithWorkingDirectory("MyLib") - .AddProps(("version", "1.2.3")) - .Build() - .EnsureSuccess(); -result.ExitCode.ShouldBe(0); +### Format a code + + + +``` CSharp +using HostApi; + +new DotNetFormat() + .WithWorkingDirectory("MyLib") + .WithProject("MyLib.csproj") + .AddDiagnostics("IDE0005", "IDE0006") + .AddIncludes(".", "./tests") + .AddExcludes("./obj") + .WithSeverity(DotNetFormatSeverity.Information) + .Run().EnsureSuccess(); ``` -### Publish a project +### Fix code style issues ``` CSharp -// Adds the namespace "HostApi" to use .NET build API 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(); +new DotNetFormatStyle() + .WithWorkingDirectory("MyLib") + .WithProject("MyLib.csproj") + .AddDiagnostics("IDE0005", "IDE0006") + .WithSeverity(DotNetFormatSeverity.Information) + .Run().EnsureSuccess(); +``` + + + +### NuGet package listing + + + +``` CSharp +using HostApi; -result.ExitCode.ShouldBe(0); +new DotNetAddPackage() + .WithWorkingDirectory("MyLib") + .WithPackage("Pure.DI") + .Run().EnsureSuccess(); -// Publish the project, running a command like: "dotnet publish --framework net6.0" from the directory "MyLib" -result = new DotNetPublish() +var lines = new List(); +new DotNetListPackage() .WithWorkingDirectory("MyLib") - .WithFramework("net8.0") - .Build() - .EnsureSuccess(); + .WithVerbosity(DotNetVerbosity.Minimal) + .Run(output => lines.Add(output.Line)); -result.ExitCode.ShouldBe(0); +lines.Any(i => i.Contains("Pure.DI")).ShouldBeTrue(); ``` -### Restore a project +### Project reference listing ``` CSharp -// Adds the namespace "HostApi" to use .NET build API 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(); - -result.ExitCode.ShouldBe(0); +new DotNetAddReference() + .WithProject(Path.Combine("MyTests", "MyTests.csproj")) + .WithReferences(Path.Combine("MyLib", "MyLib.csproj")) + .Run().EnsureSuccess(); -// Restore the project, running a command like: "dotnet restore" from the directory "MyLib" -result = new DotNetRestore() - .WithWorkingDirectory("MyLib") - .Build() - .EnsureSuccess(); +var lines = new List(); +new DotNetListReference() + .WithProject(Path.Combine("MyTests", "MyTests.csproj")) + .Run(output => lines.Add(output.Line)); -result.ExitCode.ShouldBe(0); +lines.Any(i => i.Contains("MyLib.csproj")).ShouldBeTrue(); ``` -### Run a project +### Test a project using the MSBuild VSTest target ``` CSharp -// Adds the namespace "HostApi" to use .NET build API 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(); +// Runs tests via a command +var result = new MSBuild() + .WithTarget("VSTest") + .WithWorkingDirectory("MyTests") + .Build().EnsureSuccess(); -result.ExitCode.ShouldBe(0); +// The "result" variable provides details about a build +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()); +``` -// Runs the console project using a command like: "dotnet run" from the directory "MyApp" -var stdOut = new List(); -result = new DotNetRun().WithWorkingDirectory("MyApp") - .Build(message => stdOut.Add(message.Text)) - .EnsureSuccess(); -result.ExitCode.ShouldBe(0); -// Checks StdOut -stdOut.ShouldBe(new[] {"Hello, World!"}); +### Display template package metadata + + + +``` CSharp +using HostApi; + +new DotNetNewDetails() + .WithTemplateName("CSharpInteractive.Templates") + .Run().EnsureSuccess(); ``` -### Test a project +### Installing a template package ``` CSharp -// Adds the namespace "HostApi" to use .NET build API 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(); +new DotNetNewInstall() + .WithPackage("Pure.DI.Templates") + .Run().EnsureSuccess(); +``` -result.ExitCode.ShouldBe(0); -// Runs tests via a command like: "dotnet test" from the directory "MyTests" -result = new DotNetTest() - .WithWorkingDirectory("MyTests") - .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); +### Creating a new project from template + + + +``` CSharp +using HostApi; + +new DotNetNewList() + .Run().EnsureSuccess(); ``` -### Run tests under dotCover +### List available templates ``` CSharp -// Adds the namespace "HostApi" to use .NET build API 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("classlib") + .WithName("MyLib") + .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 DotNetCustom("tool", "install", "--local", "JetBrains.dotCover.GlobalTool") - .Run() - .EnsureSuccess(); -// Creates a test command -var test = new DotNetTest() - .WithProject("MyTests"); +### Searche for the templates -var dotCoverSnapshot = Path.Combine("MyTests", "dotCover.dcvr"); -var dotCoverReport = Path.Combine("MyTests", "dotCover.html"); -// Modifies the test command by putting "dotCover" in front of all arguments -// to have something like "dotnet dotcover test ..." -// and adding few specific arguments to the end -var testUnderDotCover = test.Customize(cmd => - cmd.ClearArgs() - + "dotcover" - + cmd.Args - + $"--dcOutput={dotCoverSnapshot}" - + "--dcFilters=+:module=TeamCity.CSharpInteractive.HostApi;+:module=dotnet-csi" - + "--dcAttributeFilters=System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage"); -// Runs tests under dotCover via a command like: "dotnet dotcover test ..." -var result = testUnderDotCover - .Build() - .EnsureSuccess(); -// The "result" variable provides details about a build -result.ExitCode.ShouldBe(0); -result.Tests.Count(i => i.State == TestState.Finished).ShouldBe(1); +``` CSharp +using HostApi; -// Generates a HTML code coverage report. -new DotNetCustom("dotCover", "report", $"--source={dotCoverSnapshot}", $"--output={dotCoverReport}", "--reportType=HTML") +new DotNetNewSearch() + .WithTemplateName("build") .Run().EnsureSuccess(); +``` + + -// Check for a dotCover report -File.Exists(dotCoverReport).ShouldBeTrue(); +### Uninstalling a template package + + + +``` CSharp +using HostApi; + +new DotNetNewUninstall() + .WithPackage("Pure.DI.Templates") + .Run(); ``` -### Restore local tools +### Updating installed template packages ``` CSharp -// Adds the namespace "HostApi" to use .NET build API using HostApi; -var projectDir = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()[..4]); -Directory.CreateDirectory(projectDir); +new DotNetNewUpdate() + .Run().EnsureSuccess(); +``` + -// Creates a local tool manifest -new DotNetNew("tool-manifest") - .WithWorkingDirectory(projectDir) - .Run() - .EnsureSuccess(); -// Restore local tools -new DotNetToolRestore() - .WithWorkingDirectory(projectDir) - .Run() - .EnsureSuccess(); +### Adding a NuGet source + + + +``` CSharp +using HostApi; + +new DotNetNuGetAddSource() + .WithName("TestSource") + .WithSource(source) + .Run().EnsureSuccess(); ``` -### Test an assembly +### Gets the value of a specified NuGet configuration setting ``` CSharp -// Adds the namespace "HostApi" to use .NET build API 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(); +string? repositoryPath = default; +new DotNetNuGetConfigGet() + .WithConfigKey("repositoryPath") + .Run(output => repositoryPath = output.Line).EnsureSuccess(); +``` -result.ExitCode.ShouldBe(0); -// Builds the test project, running a command like: "dotnet build -c Release" from the directory "MyTests" -result = new DotNetBuild() - .WithWorkingDirectory("MyTests") - .WithConfiguration("Release") - .WithOutput("MyOutput") - .Build() - .EnsureSuccess(); -result.ExitCode.ShouldBe(0); +### Printing nuget configuration files currently being applied to a directory -// Runs tests via a command like: "dotnet vstest" from the directory "MyTests" -result = new VSTest() - .AddTestFileNames(Path.Combine("MyOutput", "MyTests.dll")) - .WithWorkingDirectory("MyTests") - .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); + +``` CSharp +using HostApi; + +var configPaths = new List(); +new DotNetNuGetConfigPaths() + .Run(output => configPaths.Add(output.Line)).EnsureSuccess(); ``` -### Build a project using MSBuild +### Sets the value of a specified NuGet configuration setting ``` CSharp -// Adds the namespace "HostApi" to use .NET build API 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(); +new DotNetNuGetConfigSet() + .WithConfigFile(configFile) + .WithConfigKey("repositoryPath") + .WithConfigValue("MyValue") + .Run().EnsureSuccess(); +``` -result.ExitCode.ShouldBe(0); -// Builds the library project, running a command like: "dotnet msbuild /t:Build -restore /p:configuration=Release -verbosity=detailed" from the directory "MyLib" -result = new MSBuild() - .WithWorkingDirectory("MyLib") - .WithTarget("Build") - .WithRestore(true) - .AddProps(("configuration", "Release")) - .WithVerbosity(DotNetVerbosity.Detailed) - .Build() - .EnsureSuccess(); -// The "result" variable provides details about a build -result.Errors.Any(message => message.State == BuildMessageState.StdError).ShouldBeFalse(); -result.ExitCode.ShouldBe(0); +### Unsets the value of a specified NuGet configuration setting + + + +``` CSharp +using HostApi; + +new DotNetNuGetConfigUnset() + .WithConfigKey("repositoryPath") + .Run().EnsureSuccess(); ``` -### Shuts down build servers +### Deleting a NuGet package to the server ``` CSharp -// Adds the namespace "HostApi" to use .NET build API using HostApi; -// Shuts down all build servers that are started from dotnet. -new DotNetBuildServerShutdown() - .Run() - .EnsureSuccess(); +new DotNetNuGetDelete() + .WithPackage("MyLib") + .WithPackageVersion("1.0.0") + .WithSource(repoUrl) + .Run().EnsureSuccess(); +``` + + + +### Disabling a NuGet source + + + +``` CSharp +using HostApi; + +new DotNetNuGetDisableSource() + .WithName("TestSource") + .Run().EnsureSuccess(); +``` + + + +### Enabling a NuGet source + + + +``` CSharp +using HostApi; + +new DotNetNuGetEnableSource() + .WithName("TestSource") + .Run().EnsureSuccess(); +``` + + + +### Printing all configured NuGet sources + + + +``` CSharp +using HostApi; + +new DotNetNuGetListSource() + .WithFormat(NuGetListFormat.Short) + .Run().EnsureSuccess(); +``` + + + +### Clearing the specified NuGet cache type + + + +``` CSharp +using HostApi; + +new DotNetNuGetLocalsClear() + .WithCacheLocation(NuGetCacheLocation.Temp) + .Run().EnsureSuccess(); +``` + + + +### Printing the location of the specified NuGet cache type + + + +``` CSharp +using HostApi; + +new DotNetNuGetLocalsList() + .WithCacheLocation(NuGetCacheLocation.GlobalPackages) + .Run().EnsureSuccess(); +``` + + + +### Pushing a NuGet package to the server + + + +``` CSharp +using HostApi; + +new DotNetNuGetPush() + .WithWorkingDirectory("MyLib") + .WithPackage(Path.Combine("packages", "MyLib.1.0.0.nupkg")) + .WithSource(repoUrl) + .Run().EnsureSuccess(); +``` + + + +### Removing a NuGet source. + + + +``` CSharp +using HostApi; + +new DotNetNuGetRemoveSource() + .WithName("TestSource") + .Run().EnsureSuccess(); +``` + + + +### Signing with certificate + + + +``` CSharp +using HostApi; + +new DotNetNuGetSign() + .AddPackages("MyLib.1.2.3.nupkg") + .WithCertificatePath("certificate.pfx") + .WithCertificatePassword("Abc") + .WithTimestampingServer("http://timestamp.digicert.com/") + .Run().EnsureSuccess(); +``` + + + +### Updating a NuGet source + + + +``` CSharp +using HostApi; + +new DotNetNuGetUpdateSource() + .WithName("TestSource") + .WithSource(newSource) + .Run().EnsureSuccess(); +``` + + + +### Show the dependency graph for NuGet package + + + +``` CSharp +using HostApi; + +new DotNetNuGetWhy() + .WithProject(Path.Combine("MyLib", "MyLib.csproj")) + .WithPackage("MyLib.1.2.3.nupkg") + .Run().EnsureSuccess(); +``` + + + +### Searching for a NuGet package + + + +``` CSharp +using System.Text; +using System.Text.Json; +using HostApi; + +var packagesJson = new StringBuilder(); +new DotNetPackageSearch() + .WithSearchTerm("Pure.DI") + .WithFormat(DotNetPackageSearchResultFormat.Json) + .Run(output => packagesJson.AppendLine(output.Line)).EnsureSuccess(); + +var result = JsonSerializer.Deserialize( + packagesJson.ToString(), + new JsonSerializerOptions { PropertyNameCaseInsensitive = true }); + +result.ShouldNotBeNull(); +result.SearchResult.SelectMany(i => i.Packages).Count(i => i.Id == "Pure.DI").ShouldBe(1); + +record Result(int Version, IReadOnlyCollection SearchResult); + +record Source(string SourceName, IReadOnlyCollection Packages); + +record Package( + string Id, + string LatestVersion, + int TotalDownloads, + string Owners); +``` + + + +### Packing the code into a NuGet package + + + +``` CSharp +using HostApi; + +// Creates a NuGet package of version 1.2.3 for the project +new DotNetPack() + .WithWorkingDirectory("MyLib") + .WithOutput(path) + .AddProps(("version", "1.2.3")) + .Build().EnsureSuccess(); +``` + + + +### Publishing the application and its dependencies to a folder for deployment to a hosting system + + + +``` CSharp +using HostApi; + +new DotNetPublish() + .WithWorkingDirectory("MyLib") + .WithFramework("net8.0") + .WithOutput("bin") + .Build().EnsureSuccess(); +``` + + + +### Removing a NuGet package + + + +``` CSharp +using HostApi; + +new DotNetAddPackage() + .WithWorkingDirectory("MyLib") + .WithPackage("Pure.DI") + .Run().EnsureSuccess(); + +new DotNetRemovePackage() + .WithWorkingDirectory("MyLib") + .WithPackage("Pure.DI") + .Run().EnsureSuccess(); +``` + + + +### Adding a project reference + + + +``` CSharp +using HostApi; + +new DotNetAddReference() + .WithProject(Path.Combine("MyTests", "MyTests.csproj")) + .WithReferences(Path.Combine("MyLib", "MyLib.csproj")) + .Run().EnsureSuccess(); + +new DotNetRemoveReference() + .WithProject(Path.Combine("MyTests", "MyTests.csproj")) + .WithReferences(Path.Combine("MyLib", "MyLib.csproj")) + .Run().EnsureSuccess(); + +var lines = new List(); +new DotNetListReference() + .WithProject(Path.Combine("MyTests", "MyTests.csproj")) + .Run(output => lines.Add(output.Line)); + +lines.Any(i => i.Contains("MyLib.csproj")).ShouldBeFalse(); +``` + + + +### Restoring the dependencies and tools of a project + + + +``` CSharp +using HostApi; + +new DotNetRestore() + .WithProject(Path.Combine("MyLib", "MyLib.csproj")) + .Build().EnsureSuccess(); +``` + + + +### Running source code without any explicit compile or launch commands + + + +``` CSharp +using HostApi; + +var stdOut = new List(); +new DotNetRun() + .WithProject(Path.Combine("MyApp", "MyApp.csproj")) + .Build(message => stdOut.Add(message.Text)) + .EnsureSuccess(); + +// Checks stdOut +stdOut.ShouldBe(new[] {"Hello, World!"}); +``` + + + +### Run a dotnet application + + + +``` CSharp +// Adds the namespace "HostApi" to use .NET build API +using HostApi; + +new DotNet() + .WithPathToApplication(Path.Combine(path, "MyApp.dll")) + .Run().EnsureSuccess(); +``` + + + +### Printing the latest available version of the .NET SDK and .NET Runtime, for each feature band + + + +``` CSharp +using HostApi; + +var sdks = new List(); +new DotNetSdkCheck() + .Run(output => + { + if (output.Line.StartsWith("Microsoft.")) + { + var data = output.Line.Split(' ', StringSplitOptions.RemoveEmptyEntries); + if (data.Length >= 2) + { + sdks.Add(new Sdk(data[0], NuGetVersion.Parse(data[1]))); + } + } + }) + .EnsureSuccess(); + +sdks.Count.ShouldBeGreaterThan(0); + +record Sdk(string Name, NuGetVersion Version); +``` + + + +### Adding projects to the solution file + + + +``` CSharp +using HostApi; + +new DotNetNew() + .WithTemplateName("sln") + .WithName("NySolution") + .WithForce(true) + .Run().EnsureSuccess(); + +new DotNetSlnAdd() + .WithSolution("NySolution.sln") + .AddProjects( + Path.Combine("MyLib", "MyLib.csproj"), + Path.Combine("MyTests", "MyTests.csproj")) + .Run().EnsureSuccess(); +``` + + + +### Printing all projects in a solution file + + + +``` CSharp +using HostApi; + +var lines = new List(); +new DotNetSlnList() + .WithSolution("NySolution.sln") + .Run(output => lines.Add(output.Line)) + .EnsureSuccess(); +``` + + + +### Adding projects to the solution file + + + +``` CSharp +using HostApi; + +new DotNetSlnRemove() + .WithSolution("NySolution.sln") + .AddProjects( + Path.Combine("MyLib", "MyLib.csproj")) + .Run().EnsureSuccess(); +``` + + + +### Storing the specified assemblies in the runtime package store. + + + +``` CSharp +using HostApi; + +new DotNetStore() + .AddManifests(Path.Combine("MyLib", "MyLib.csproj")) + .WithFramework("net8.0") + .WithRuntime("win-x64") + .Build(); + +``` + + + +### Test a project + + + +``` CSharp +using HostApi; + +// Runs tests +var result = new DotNetTest() + .WithWorkingDirectory("MyTests") + .Build().EnsureSuccess(); + +// The "result" variable provides details about build and tests +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()); +``` + + + +### Run tests under dotCover + + + +``` CSharp +using HostApi; + +new DotNetToolInstall() + .WithLocal(true) + .WithPackage("JetBrains.dotCover.GlobalTool") + .Run().EnsureSuccess(); + +// Creates a test command +var test = new DotNetTest() + .WithProject("MyTests"); + +var dotCoverSnapshot = Path.Combine("MyTests", "dotCover.dcvr"); +var dotCoverReport = Path.Combine("MyTests", "dotCover.html"); +// Modifies the test command by putting "dotCover" in front of all arguments +// to have something like "dotnet dotcover test ..." +// and adding few specific arguments to the end +var testUnderDotCover = test.Customize(cmd => + cmd.ClearArgs() + + "dotcover" + + cmd.Args + + $"--dcOutput={dotCoverSnapshot}" + + "--dcFilters=+:module=TeamCity.CSharpInteractive.HostApi;+:module=dotnet-csi" + + "--dcAttributeFilters=System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage"); + +// Runs tests under dotCover +var result = testUnderDotCover + .Build().EnsureSuccess(); + +// The "result" variable provides details about a build +result.ExitCode.ShouldBe(0, result.ToString()); +result.Tests.Count(i => i.State == TestState.Finished).ShouldBe(1, result.ToString()); + +// Generates a HTML code coverage report. +new DotNetCustom("dotCover", "report", $"--source={dotCoverSnapshot}", $"--output={dotCoverReport}", "--reportType=HTML") + .Run().EnsureSuccess(); +``` + + + +### Installing the specified .NET tool + + + +``` CSharp +using HostApi; + +new DotNetToolInstall() + .WithLocal(true) + .WithPackage("dotnet-csi") + .Run().EnsureSuccess(); +``` + + + +### Printing all .NET tools of the specified type currently installed + + + +``` CSharp +using HostApi; + +new DotNetToolList() + .WithLocal(true) + .Run().EnsureSuccess(); + +new DotNetToolList() + .WithGlobal(true) + .Run().EnsureSuccess(); +``` + + + +### Installing the .NET local tools that are in scope for the current directory + + + +``` CSharp +using HostApi; + +// Creates a local tool manifest +new DotNetNew() + .WithTemplateName("tool-manifest") + .Run().EnsureSuccess(); + +new DotNetToolRestore() + .Run().EnsureSuccess(); +``` + + + +### Invoking a local tool + + + +``` CSharp +using HostApi; + +var script = Path.GetTempFileName(); +File.WriteAllText(script, "Console.WriteLine($\"Hello, {Args[0]}!\");"); + +var stdOut = new List(); +new DotNetToolRun() + .WithCommandName("dotnet-csi") + .AddArgs(script) + .AddArgs("World") + .Run(output => stdOut.Add(output.Line)) + .EnsureSuccess(); + +// Checks stdOut +stdOut.Contains("Hello, World!").ShouldBeTrue(); +``` + + + +### Searching all .NET tools that are published to NuGet + + + +``` CSharp +using HostApi; + +new DotNetToolSearch() + .WithPackage("dotnet-csi") + .WithDetail(true) + .Run().EnsureSuccess(); +``` + + + +### Uninstalling the specified .NET tool + + + +``` CSharp +using HostApi; + +new DotNetToolUninstall() + .WithPackage("dotnet-csi") + .Run().EnsureSuccess(); +``` + + + +### Installing the specified .NET tool + + + +``` CSharp +using HostApi; + +new DotNetToolUpdate() + .WithLocal(true) + .WithPackage("dotnet-csi") + .Run().EnsureSuccess(); +``` + + + +### Running tests from the specified assemblies + + + +``` CSharp +using HostApi; + +// Runs tests +var result = new VSTest() + .AddTestFileNames(Path.Combine("bin", "MyTests.dll")) + .WithWorkingDirectory(path) + .Build().EnsureSuccess(); + +// The "result" variable provides details about build and tests +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()); +``` + + + +### Enabling or disabling workload-set update mode + + + +``` CSharp +using HostApi; + +new DotNetWorkloadConfig() + .WithUpdateMode(DotNetWorkloadUpdateMode.WorkloadSet) + .Run().EnsureSuccess(); +``` + + + +### Installing optional workloads + + + +``` CSharp +using HostApi; + +new DotNetWorkloadInstall() + .AddWorkloads("aspire") + .Run().EnsureSuccess(); +``` + + + +### Printing installed workloads + + + +``` CSharp +using HostApi; + +new DotNetWorkloadList() + .Run().EnsureSuccess(); +``` + + + +### Repairing workloads installations + + + +``` CSharp +using HostApi; + +new DotNetWorkloadRepair() + .Run().EnsureSuccess(); +``` + + + +### Installing workloads needed for a project or a solution + + + +``` CSharp +using HostApi; + +new DotNetWorkloadRestore() + .WithProject(Path.Combine("MyLib", "MyLib.csproj")) + .Run().EnsureSuccess(); +``` + + + +### Searching for optional workloads + + + +``` CSharp +using HostApi; + +new DotNetWorkloadSearch() + .WithSearchString("maui") + .Run().EnsureSuccess(); +``` + + + +### Uninstalling a specified workload + + + +``` CSharp +using HostApi; + +new DotNetWorkloadUninstall() + .AddWorkloads("aspire") + .Run().EnsureSuccess(); +``` + + + +### Updating installed workloads + + + +``` CSharp +using HostApi; + +new DotNetWorkloadUpdate() + .Run().EnsureSuccess(); +``` + + + +### Build a project using MSBuild + + + +``` CSharp +using HostApi; + +// Creates a new library project, running a command like: "dotnet new classlib -n MyLib --force" +new DotNetNew() + .WithTemplateName("classlib") + .WithName("MyLib") + .WithForce(true) + .Build().EnsureSuccess(); + +// Builds the library project, running a command like: "dotnet msbuild /t:Build -restore /p:configuration=Release -verbosity=detailed" from the directory "MyLib" +var result = new MSBuild() + .WithWorkingDirectory("MyLib") + .WithTarget("Build") + .WithRestore(true) + .AddProps(("configuration", "Release")) + .WithVerbosity(DotNetVerbosity.Detailed) + .Build().EnsureSuccess(); + +// The "result" variable provides details about a build +result.Errors.Any(message => message.State == BuildMessageState.StdError).ShouldBeFalse(result.ToString()); +result.ExitCode.ShouldBe(0, result.ToString()); +``` + + + +### Shuts down build servers + + + +``` CSharp +using HostApi; + +// Shuts down all build servers that are started from dotnet. +new DotNetBuildServerShutdown() + .Run().EnsureSuccess(); +``` + + + +### Run C# script + + + +``` CSharp +using HostApi; + +var script = Path.GetTempFileName(); +File.WriteAllText(script, "Console.WriteLine($\"Hello, {Args[0]}!\");"); + +var stdOut = new List(); +new DotNetCsi() + .WithScript(script) + .AddArgs("World") + .Run(output => stdOut.Add(output.Line)) + .EnsureSuccess(); + +// Checks stdOut +stdOut.Contains("Hello, World!").ShouldBeTrue(); ``` diff --git a/Samples/MySampleLib/MySampleLib.Tests/MySampleLib.Tests.csproj b/Samples/MySampleLib/MySampleLib.Tests/MySampleLib.Tests.csproj index 228189c3..efd3acad 100644 --- a/Samples/MySampleLib/MySampleLib.Tests/MySampleLib.Tests.csproj +++ b/Samples/MySampleLib/MySampleLib.Tests/MySampleLib.Tests.csproj @@ -7,7 +7,7 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive all