craft_parts.plugins.dotnet_plugin module

The Dotnet plugin.

class craft_parts.plugins.dotnet_plugin.DotPluginEnvironmentValidator(*, part_name, env, properties)

Bases: PluginEnvironmentValidator

Check the execution environment for the Dotnet 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)

Ensure the environment contains dependencies needed by the plugin.

Parameters:

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

Return type:

None

class craft_parts.plugins.dotnet_plugin.DotnetPlugin(*, properties, part_info)

Bases: Plugin

A plugin for dotnet projects.

The dotnet plugin requires dotnet installed on your system. This can be achieved by adding the appropriate dotnet snap package to build-snaps, or to have it installed or built in a different part. In this case, the name of the part supplying the dotnet compiler must be “dotnet”.

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

  • dotnet-build-configuration (string) The dotnet build configuration to use. The default is “Release”.

  • dotnet-self-contained-runtime-identifier (string) Create a self contained dotnet application using the specified RuntimeIdentifier.

Parameters:
get_build_commands()

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

Return type:

list[str]

get_build_environment()

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

Return type:

dict[str, str]

get_build_packages()

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

Return type:

set[str]

get_build_snaps()

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

Return type:

set[str]

properties_class

alias of DotnetPluginProperties

validator_class

alias of DotPluginEnvironmentValidator

class craft_parts.plugins.dotnet_plugin.DotnetPluginProperties(**data)

Bases: PluginProperties

The part properties used by the Dotnet plugin.

Parameters:

data (Any)

dotnet_build_configuration: str

The .NET build configuration to use.

Defaults to Release.

dotnet_self_contained_runtime_identifier: str | None

The Runtime Identifier of the .NET project.

If set to a valid identifier, the part will be self-contained.

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