Table of Contents

NuGet CLI

Run the host-owned NuGet CLI through typed immutable commands.

Tools.NuGet provides typed immutable commands for the host-owned nuget executable. Commands return raw ExecResult output and can be customized with record with expressions.

await Tools.NuGet.EnsureAvailable;

await Tools.NuGet.Pack with
{
    InputPath = Do.RootDirectory / "package.nuspec",
    OutputDirectory = Do.RootDirectory / "artifacts",
};

The suite includes Add, Config, Delete, Init, Install, List, Locals, Pack, Push, Restore, Search, SetApiKey, Sign, Sources, Spec, TrustedSigners, Update, and Verify. It intentionally omits help commands and executable self-update.

The executable and version are owned by the host. EnsureAvailable uses an existing nuget from PATH, or installs NuGet through Scoop on Windows. Existing Mono-based installations may work on other platforms, but DotNetDo does not install them or promise cross-platform compatibility. Commands never install implicitly.

Use Secret for API keys and passwords:

await Tools.NuGet.Push with
{
    Package = "artifacts/*.nupkg",
    Source = "https://api.nuget.org/v3/index.json",
    ApiKey = new Secret(apiKey),
};

Typed properties follow the current official nuget.exe reference. DotNetDo validates only inputs needed to render a command; NuGet remains responsible for conflicting, dependent, version-specific, and mode-specific options. AdditionalArguments is appended last and remains available for unmodeled future syntax.

Entry points

Tools.NuGet.ToolName

The canonical workspace tool-requirement name.

public const string ToolName = "nuget"

Field Value

string

Tools.NuGet.EnsureAvailable

Makes nuget available, installing it through Scoop when missing on Windows.

public static ToolInstall EnsureAvailable { get; }

Property Value

ToolInstall

Tools.NuGet.Add

Adds a package to a folder source.

public static NuGetAdd Add { get; }

Property Value

NuGetAdd

Tools.NuGet.Config

Reads or changes NuGet configuration.

public static NuGetConfig Config { get; }

Property Value

NuGetConfig

Tools.NuGet.Delete

Deletes or unlists a package.

public static NuGetDelete Delete { get; }

Property Value

NuGetDelete

Tools.NuGet.Init

Initializes a folder source.

public static NuGetInit Init { get; }

Property Value

NuGetInit

Tools.NuGet.Install

Downloads packages.

public static NuGetInstall Install { get; }

Property Value

NuGetInstall

Tools.NuGet.List

Lists packages.

public static NuGetList List { get; }

Property Value

NuGetList

Tools.NuGet.Locals

Manages local caches.

public static NuGetLocals Locals { get; }

Property Value

NuGetLocals

Tools.NuGet.Pack

Creates packages.

public static NuGetPack Pack { get; }

Property Value

NuGetPack

Tools.NuGet.Push

Publishes packages.

public static NuGetPush Push { get; }

Property Value

NuGetPush

Tools.NuGet.Restore

Restores packages.

public static NuGetRestore Restore { get; }

Property Value

NuGetRestore

Searches package sources.

public static NuGetSearch Search { get; }

Property Value

NuGetSearch

Tools.NuGet.SetApiKey

Stores a package-source API key.

public static NuGetSetApiKey SetApiKey { get; }

Property Value

NuGetSetApiKey

Tools.NuGet.Sign

Signs packages.

public static NuGetSign Sign { get; }

Property Value

NuGetSign

Tools.NuGet.Sources

Manages package sources.

public static NuGetSources Sources { get; }

Property Value

NuGetSources

Tools.NuGet.Spec

Creates package specifications.

public static NuGetSpec Spec { get; }

Property Value

NuGetSpec

Tools.NuGet.TrustedSigners

Manages trusted signers.

public static NuGetTrustedSigners TrustedSigners { get; }

Property Value

NuGetTrustedSigners

Tools.NuGet.Update

Updates legacy package references.

public static NuGetUpdate Update { get; }

Property Value

NuGetUpdate

Tools.NuGet.Verify

Verifies package signatures.

public static NuGetVerify Verify { get; }

Property Value

NuGetVerify

Related types