craft_parts.plugins.dotnet_v2_plugin module

The new .NET plugin.

class craft_parts.plugins.dotnet_v2_plugin.DotnetConfiguration(value)[source]

Bases: str, Enum

The .NET build configuration.

DEBUG = 'Debug'
RELEASE = 'Release'
class craft_parts.plugins.dotnet_v2_plugin.DotnetV2Plugin(*, properties, part_info)[source]

Bases: Plugin

A plugin for .NET projects.

The .NET plugin uses the common plugin keywords as well as those for “sources”. Additionally, the following plugin-specific keywords can be used:

Global Flags:

  • dotnet-configuration (string) The .NET build configuration to use. (Default: “Release”).

  • dotnet-project (string) The .NET proj or solution file to build. (Default: omitted).

  • dotnet-properties (dictionary of strings to strings) The list of MSBuild properties to be used by the restore, build, and publish commands. (Default: empty).

  • dotnet-self-contained (bool) Build and publish the project as a self-contained application. (Default: False).

  • dotnet-verbosity (string) The verbosity level of the build output. Possible values are q[uiet], m[inimal], n[ormal], d[etailed], and diag[nostic]. (Default: “normal”).

  • dotnet-version (string) The version of the .NET SDK to download and use. This parameter is optional, so if no value is specified, the plugin will assume a .NET SDK is being provided and will not attempt to download one.

Restore-specific Flags:

  • dotnet-restore-sources (string) The URI of the NuGet package sources to use during the restore operation. Multiple values can be specified. This setting overrides all of the sources specified in the nuget.config files. (Default: omitted).

  • dotnet-restore-properties (dictionary of strings to strings) The list of MSBuild properties to be used by the restore command. (Default: empty).

  • dotnet-restore-configfile (string) The NuGet configuration file (nuget.config) to use. (Default: omitted).

Build-specific Flags:

  • dotnet-build-framework (string) The target framework to build for. (Default: omitted).

  • dotnet-build-properties (dictionary of strings to strings) The list of MSBuild properties to be used by the build command. (Default: empty).

Publish-specific Flags:

  • dotnet-publish-properties (dictionary of strings to strings) The list of MSBuild properties to be used by the publish command. (Default: empty).

Parameters:
get_build_commands()[source]

Return a list of commands to run during the build step.

Return type:

list[str]

get_build_environment()[source]

Return a dictionary with the environment to use in the build step.

Return type:

dict[str, str]

get_build_packages()[source]

Return a set of required packages to install in the build environment.

Return type:

set[str]

get_build_snaps()[source]

Return a set of required snaps to install in the build environment.

Return type:

set[str]

properties_class

alias of DotnetV2PluginProperties

validator_class

alias of DotnetV2PluginEnvironmentValidator

class craft_parts.plugins.dotnet_v2_plugin.DotnetV2PluginEnvironmentValidator(*, part_name, env, properties)[source]

Bases: PluginEnvironmentValidator

Check the execution environment for the .NET plugin.

Parameters:
  • part_name (str) – The part whose build environment is being validated.

  • env (str) – A string containing the build step environment setup.

  • properties (PluginProperties)

validate_environment(*, part_dependencies=None)[source]

Ensure the environment contains dependencies needed by the plugin.

Parameters:

part_dependencies (Optional[list[str]]) – A list of the parts this part depends on.

Return type:

None

class craft_parts.plugins.dotnet_v2_plugin.DotnetV2PluginProperties(**data)[source]

Bases: PluginProperties

The part properties used by the .NET plugin.

Parameters:

data (Any)

dotnet_build_framework: str | None
dotnet_build_properties: dict[str, str]
dotnet_configuration: DotnetConfiguration
dotnet_project: str | None
dotnet_properties: dict[str, str]
dotnet_publish_properties: dict[str, str]
dotnet_restore_configfile: str | None
dotnet_restore_properties: dict[str, str]
dotnet_restore_sources: list[str]
dotnet_self_contained: bool
dotnet_verbosity: DotnetVerbosity
dotnet_version: str | None
model_config: ClassVar[ConfigDict] = {'alias_generator': <function PluginProperties.<lambda>>, 'extra': 'forbid', 'frozen': True, 'validate_assignment': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

plugin: Literal['dotnet']
source: str
classmethod validate_dotnet_version(value)[source]

Validate the dotnet-version property.

Parameters:

value (str | None) – The value to validate.

Return type:

str | None

Returns:

The validated value.

class craft_parts.plugins.dotnet_v2_plugin.DotnetVerbosity(value)[source]

Bases: str, Enum

The .NET build verbosity level.

DETAILED = 'detailed'
DETAILED_SHORT = 'd'
DIAGNOSTIC = 'diagnostic'
DIAGNOSTIC_SHORT = 'diag'
MINIMAL = 'minimal'
MINIMAL_SHORT = 'm'
NORMAL = 'normal'
NORMAL_SHORT = 'n'
QUIET = 'quiet'
QUIET_SHORT = 'q'