.NET
Provides helpers and targets for common .NET CLI operations — build, test, pack, publish, and NuGet push. Add it to any build that compiles, tests, or packages .NET projects.
Package: Invex.Atom.Module.Dotnet
Installation
dotnet add package Invex.Atom.Module.Dotnet
Usage
The module exposes several interfaces with pre-built helper methods for .NET CLI commands. Implement the relevant interfaces on your build class (or your own target interfaces) to gain access to the helpers and their parameters:
| Interface | Purpose |
|---|---|
IDotnetCli |
Strongly-typed wrappers for the full dotnet CLI surface. |
IDotnetCliHelper |
Base helper for invoking the .NET CLI. |
IDotnetPackHelper |
DotnetPackAndStage — packs a project and stages the .nupkg output. |
IDotnetPublishHelper |
Publishes a project and stages the output. |
IDotnetTestHelper |
Runs test projects and collects results/coverage (TRX models included). |
IDotnetToolInstallHelper |
Installs .NET tools. |
INugetHelper |
NuGet feed management and push operations. |
Calling the CLI directly
IDotnetCli has one method per documented dotnet command (noun-first forms such as PackageAdd and
ReferenceAdd; hidden and legacy commands are not generated). Each command's options are a Dotnet<Command>Options
record:
await DotnetCli.Build(RootedFileSystem.AtomRootDirectory / "My Project" / "MyProject.csproj",
new DotnetBuildOptions
{
Configuration = "Release",
NoLogo = true,
Verbosity = VerbosityOptions.Minimal,
Property = new Dictionary<string, string> { ["ContinuousIntegrationBuild"] = "true" },
},
cancellationToken: cancellationToken);
Every argument is passed to dotnet as a separate value, so paths and values containing spaces or quotes need no
manual quoting. Flags such as NoLogo are emitted only when true; options that take a boolean value, such as
SelfContained, are emitted as --self-contained true or --self-contained false when set. Use
ToArguments() on an options record to see the arguments it produces.
Features
- CLI wrappers: Strongly-typed wrappers around
dotnet build,dotnet test,dotnet pack,dotnet publish,dotnet nuget push, and the rest of thedotnetCLI. - Build helpers: Utility methods for common .NET build patterns (pack & stage, publish & stage, test with reporting, tool installation).
- Version transformation:
TransformProjectVersionScopetemporarily rewrites project versions from the build's version providers during packing.
Workflow Integration
Framework labels for matrix builds are provided by the Invex.Atom.Workflows package
(WorkflowLabels.Dotnet.Framework.*):
new MatrixDimension(nameof(ITestTargets.TestFramework))
{
Values = [
WorkflowLabels.Dotnet.Framework.Net_8_0,
WorkflowLabels.Dotnet.Framework.Net_9_0,
],
}
Setup steps ensure the required .NET SDK versions are installed on CI runners:
BuildOptions.Steps.SetupDotnet.Dotnet80X()
BuildOptions.Steps.SetupDotnet.Dotnet90X()
See also
- Process Runner: the runner the CLI wrappers use.
- Workflow Options: setup steps for CI runners.
- IDotnetCli
- IDotnetPackHelper
- IDotnetTestHelper
- TransformProjectVersionScope