githubEdit

.NET

The DecSm.Atom.Module.Dotnet module provides comprehensive integration with the .NET CLI, offering a powerful and type-safe way to interact with dotnet commands within your DecSm.Atom build definitions. This module simplifies common .NET development tasks such as building, testing, publishing, packing NuGet packages, and managing .NET tools.

Features

  • Type-Safe .NET CLI Interaction: Execute dotnet commands (e.g., build, test, publish, pack) with strongly-typed options, reducing errors and improving readability.

  • Automated Tool Installation: Automatically installs or updates .NET CLI tools (e.g., dotnet-reportgenerator-globaltool) as needed.

  • Project Versioning: Seamlessly injects build version information into project files before compilation, packing, or publishing.

  • Artifact Staging: Automatically stages build outputs (binaries, test results, NuGet packages) into designated Atom directories for further processing or publishing.

  • NuGet Helper: Provides utilities for pushing NuGet packages to feeds and managing NuGet.Config files.

  • Detailed Reporting: Generates comprehensive test and code coverage reports, integrating them into the build's outcome summary.

  • Flexible Configuration: Offers extensive options for customizing command execution, including working directories, logging levels, environment variables, and output transformations.

Getting Started

To use the .NET module, you typically implement the IDotnetCliHelper interface in your build definition. This provides access to the DotnetCli service, which is the entry point for most .NET CLI operations. For more specific tasks, you can implement additional helper interfaces like IDotnetPackHelper, IDotnetPublishHelper, IDotnetTestHelper, and INugetHelper.

Implementation

Add the IDotnetCliHelper interface to your Build.cs file:

using DecSm.Atom.Build.Definition;
using DecSm.Atom.Module.Dotnet.Helpers;

namespace Atom;

[BuildDefinition]
internal partial class Build : IDotnetCliHelper
{
    // Your build targets and other definitions
}

.NET CLI Commands

The IDotnetCli service (accessed via DotnetCli property) provides methods for various dotnet commands. These methods are generated and offer strongly-typed options for each command.

Example: Building a Project

Packing and Staging NuGet Packages

The IDotnetPackHelper interface provides methods to pack .NET projects into NuGet packages and stage them in the Atom artifacts directory.

Testing and Staging Results

The IDotnetTestHelper interface allows you to run tests, collect results, and optionally generate code coverage reports.

Publishing and Staging Applications

The IDotnetPublishHelper interface helps publish .NET applications and stage their output.

NuGet Operations

The INugetHelper interface provides methods for interacting with NuGet feeds.

Tool Installation

The IDotnetToolInstallHelper interface simplifies the installation and management of .NET CLI tools.

Last updated

Was this helpful?