Table of Contents

Interface IDotnetPackHelper

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

Provides helper methods for packing .NET projects into NuGet packages and staging them for publishing.

public interface IDotnetPackHelper : IDotnetCliHelper, IBuildInfo, IBuildAccessor
Inherited Members

Remarks

This interface extends IDotnetCliHelper to utilize the .NET CLI for packing operations and IBuildInfo to leverage build version information.

Methods

DotnetPackAndStage(RootedPath, DotnetPackAndStageOptions?, CancellationToken)

Packs a .NET project specified by its path and stages the resulting NuGet package.

Task DotnetPackAndStage(RootedPath projectPath, DotnetPackAndStageOptions? options = null, CancellationToken cancellationToken = default)

Parameters

projectPath RootedPath

The full path to the project file (e.g., "src/MyProject/MyProject.csproj").

options DotnetPackAndStageOptions

Optional. Configuration options for the packing and staging process.

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 performs the following steps:

  1. Determines the output directory for the NuGet package.
  2. Cleans up existing package directories if specified.
  3. Applies version transformations to project files if SetVersionsFromProviders is true.
  4. Executes the `dotnet pack` command using Pack(RootedPath, DotnetPackOptions?, ProcessRunOptions?, CancellationToken).
  5. Locates the generated `.nupkg` file.
  6. Moves the `.nupkg` file to the Atom publish directory for the project.

The BuildVersion is used for naming the NuGet package and for version transformation.

Exceptions

StepFailedException

Thrown if the packed NuGet package is not found after the operation.

DotnetPackAndStage(string, DotnetPackAndStageOptions?, CancellationToken)

Packs a .NET project by its name and stages the resulting NuGet package.

Task DotnetPackAndStage(string projectName, DotnetPackAndStageOptions? options = null, CancellationToken cancellationToken = default)

Parameters

projectName string

The name of the project to pack (e.g., "MyProject.Core").

options DotnetPackAndStageOptions

Optional. Configuration options for the packing and staging process.

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 locates the project file based on its name, then calls DotnetPackAndStage(RootedPath, DotnetPackAndStageOptions?, CancellationToken) with the resolved path.

Exceptions

StepFailedException

Thrown if the project file cannot be located.