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
toolNamestringThe name of the tool to install (e.g., "dotnet-format").
versionstringOptional. 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.
globalboolIf
true, the tool is installed globally. Iffalse, it's installed locally to the current directory.forceReinstallboolIf
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
toolNamestringThe name of the tool to install (e.g., "dotnet-format").
versionstringOptional. 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.
globalboolIf
true, the tool is installed globally. Iffalse, it's installed locally to the current directory.forceReinstallboolIf
true, the tool will be reinstalled even if already present.cancellationTokenCancellationTokenA 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.