DotNet Add

The DotNet Add action in Continua CI is a wrapper around the .NET command line tools. If you're having trouble using the DotNet Add action, please refer to the .NET CLI documentation.

The DotNet Add action can be used to add a package or reference to a .NET project, or add a project to a .NET solution file.

DotNet Add

DotNet Add action main tab

Name

A friendly name for this action (will be displayed in the actions workflow area).

Enabled

Determines if this action will be run within the relevant stage.

What To Add

Select what you want to add. You can choose one of the following:

  • Package to project - adds a NuGet package reference to a project file
  • Reference to project - adds one or more project references to a project file
  • Project to solution - adds one or more projects to a solution file

The properties displayed on this tab change depending on the selected option.


Package to project

This option uses the dotnet add package command to add a package reference to a project file. The command starts with a compatibility check to ensure the package is compatible with the frameworks in the project. If the check passes, a <PackageReference> element is added to the project file and dotnet restore is run.

DotNet Add - Package to project

The following fields are shown when this option is selected.

Project Path

Path to project file or folder to modify. If a folder is specified, the folder will be searched for a file that has a file extension that ends in proj. Defaults to the workspace folder.

Package Name

The name of the package reference to add.


Reference to project

This option uses the dotnet add reference command to add project references to a project file. The command adds one or more <ProjectReference> elements to the project file.

DotNet Add - Reference to project

The following fields are shown when this option is selected.

Project Path

Path to project file or folder to modify. If a folder is specified, the folder will be searched for a file that has a file extension that ends in proj. Defaults to the workspace folder.

Project References

One or more project references to add, one per line. These should generally be entered as relative paths, relative to the working folder.


Project to solution

This option uses the dotnet sln add command to add one or more projects to a solution file.

DotNet Add - Project to solution

The following fields are shown when this option is selected.

Solution Path

Path to the solution file to modify. If a folder is specified, the folder will be searched for a file that has a file extension sln or slnx. If there are multiple solution files in the folder, one must be specified. Defaults to the workspace folder.

Project Paths

Paths to one or more project files to add to the solution, one per line. Supports wildcard patterns. This is a required field.


Working Folder

Optional working folder for running the executable. Defaults to the project or solution folder.

Using

The Using drop down is populated with any property collector whose namespace matches the pattern defined by the DotNet CLI actions. The pattern for this action is ^NetCore\.App(?:\.|$)

If you create a property collector for this action, make sure you select the Path Finder PlugIn type and give it a name that will match the pattern above. Example names listed here, search the table's Plugin column for "DotNet Add".

For more in-depth explanations on property collectors see Property Collectors.

Alternatively, you can select the Custom option from the Using drop down list and specify a path in the resulting input field that will be displayed. Please read Why it's a good idea to use a property collector before using this option.

DotNet Bitness

The bitness of the DotNet executable. Options are Default, 32 Bit (X86), or 64 Bit (X64).

SDK Version

The SDK version to set in global.json file before running the DotNet executable.

Custom SDK Version

A custom SDK version string. This field is only visible when the SDK Version is set to 'Custom'.

Target Framework

Adds references only when targeting a specific framework. This field is visible when What To Add is set to Package to project or Reference to project. [--framework]

Settings

This tab contains additional settings that are visible depending on the What To Add selection.

DotNet Add action Settings tab

Package Version

The version of the package to add. This field is visible when What To Add is set to Package to project. [--version]

Package Source

The NuGet package source to use during the restore operation. This field is visible when What To Add is set to Package to project. [--source]

Package Directory

Directory to restore the package to. This field is visible when What To Add is set to Package to project. [--package-directory]

No restore

Tick to skip the restore preview and compatibility check. Skipping the restore speeds up the operation but risks adding an incompatible package. This field is visible when What To Add is set to Package to project. [--no-restore]

Additional Arguments

DotNet Add action Additional Arguments tab

Additional Arguments

Use this to specify additional command line arguments and properties. Note that these will be placed at the end of the command line and will override any other matching settings.

Options

DotNet Add action Options tab

Log standard output

Tick to log standard output.

Timeout (in seconds)

How long to wait for the action to finish running before timing out. Leaving this blank (or zero) will default to 86400 seconds (24 hours).

Treat failure as warning

Tick to continue build on failure, marking the action with a warning status.

Ignore warnings

If this is ticked, any warnings logged will not mark the action with a warning status.

Environment

DotNet Add action Environment tab

Environment Variables

Multiple environment variables can be defined - one per line. These are set before the command line is run.

Log environment variables

If this is ticked, environment variable values are written to the build log.

Generate system environment variables

Tick this checkbox to set up a list of new environment variables prefixed with 'ContinuaCI.' for all current system expression objects and variables.

Mask sensitive variable values in system environment variables

This checkbox is visible only if the 'Generate system environment variables' checkbox is ticked.

If this is ticked, the values of any variables marked as sensitive will be masked with **** when setting system environment variables. Clear this to expose the values.