Table of Contents

Interface IDotnetToolInstallHelper

Namespace
Invex.Atom.Module.Dotnet.Helpers
Assembly
Invex.Atom.Module.Dotnet.dll

Provides helper methods for installing and managing .NET CLI tools.

public interface IDotnetToolInstallHelper : IBuildAccessor
Inherited Members

Remarks

This interface extends IBuildAccessor to gain access to core build services like Invex.Process.IProcessRunner and Invex.FileSystem.IRootedFileSystem.

Methods

InstallTool(string, string?, bool, bool)

Installs or updates a .NET CLI tool.

void InstallTool(string toolName, string? version = null, bool global = true, bool forceReinstall = false)

Parameters

toolName string

The name of the tool to install (e.g., "dotnet-format").

version string

Optional. The specific version of the tool to install. If not specified, the latest stable version is used. When specified, a newer installed version is downgraded to it.

global bool

If true, the tool is installed globally. If false, it's installed locally to the current directory.

forceReinstall bool

If true, the tool will be reinstalled even if already present.

Remarks

This method first checks if the tool is already installed (unless forceReinstall is true or running in headless mode). If not installed or reinstallation is forced, it executes `dotnet tool update`.

If installing locally (global is false) and a tool manifest (`.config/dotnet-tools.json`) does not exist, it will be created.

InstallToolAsync(string, string?, bool, bool, CancellationToken)

Asynchronously installs or updates a .NET CLI tool.

Task InstallToolAsync(string toolName, string? version = null, bool global = true, bool forceReinstall = false, CancellationToken cancellationToken = default)

Parameters

toolName string

The name of the tool to install (e.g., "dotnet-format").

version string

Optional. The specific version of the tool to install. If not specified, the latest stable version is used. When specified, a newer installed version is downgraded to it.

global bool

If true, the tool is installed globally. If false, it's installed locally to the current directory.

forceReinstall bool

If true, the tool will be reinstalled even if already present.

cancellationToken CancellationToken

A cancellation token to observe while waiting for the task to complete.

Returns

Task

A System.Threading.Tasks.Task representing the asynchronous operation.

Remarks

This method first checks if the tool is already installed (unless forceReinstall is true or running in headless mode). If not installed or reinstallation is forced, it executes `dotnet tool update`.

If installing locally (global is false) and a tool manifest (`.config/dotnet-tools.json`) does not exist, it will be created.