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
projectPathRootedPathThe full path to the project file (e.g., "src/MyProject/MyProject.csproj").
optionsDotnetPackAndStageOptionsOptional. Configuration options for the packing and staging process.
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 performs the following steps:
- Determines the output directory for the NuGet package.
- Cleans up existing package directories if specified.
-
Applies version transformations to project files if
SetVersionsFromProviders is
true. - Executes the `dotnet pack` command using Pack(RootedPath, DotnetPackOptions?, ProcessRunOptions?, CancellationToken).
- Locates the generated `.nupkg` file.
- 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
projectNamestringThe name of the project to pack (e.g., "MyProject.Core").
optionsDotnetPackAndStageOptionsOptional. Configuration options for the packing and staging process.
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 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.