Skip to content

Latest commit

 

History

History
473 lines (351 loc) · 51.6 KB

defs.md

File metadata and controls

473 lines (351 loc) · 51.6 KB

Public API surface is re-exported here.

Users should not load files under "/dotnet"

csharp_binary

load("@rules_dotnet//dotnet:defs.bzl", "csharp_binary")

csharp_binary(name, deps, srcs, data, resources, out, additionalfiles, allow_unsafe_blocks,
              analyzer_configs, appsetting_files, compile_data, compiler_options, defines, envs,
              generate_documentation_file, include_host_model_dll, internals_visible_to, keyfile,
              langversion, nowarn, nullable, project_sdk, roll_forward_behavior, run_analyzers,
              target_frameworks, treat_warnings_as_errors, warning_level, warnings_as_errors,
              warnings_not_as_errors, winexe)

Compile a C# exe

ATTRIBUTES

Name Description Type Mandatory Default
name A unique name for this target. Name required
deps Other libraries, binaries, or imported DLLs List of labels optional []
srcs The source files used in the compilation. List of labels optional []
data Runtime files. It is recommended to use the @rules_dotnet//tools/runfiles library to read the runtime files. List of labels optional []
resources A list of files to embed in the DLL as resources. List of labels optional []
out File name, without extension, of the built assembly. String optional ""
additionalfiles Extra files to configure analyzers. List of labels optional []
allow_unsafe_blocks Allow compiling unsafe code. It true, /unsafe is passed to the compiler. Boolean optional False
analyzer_configs A list of analyzer configuration files. See: https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/configuration-files List of labels optional []
appsetting_files A list of appsettings files to include in the output directory. List of labels optional []
compile_data Additional compile time files. List of labels optional []
compiler_options Additional options to pass to the compiler. This attribute should only be used if the compiler flag has not already been exposed as an attribute. List of strings optional []
defines A list of preprocessor directive symbols to define. List of strings optional []
envs A dictionary of environment variables to set when the binary is run. Supports make variable expansion Dictionary: String -> String optional {}
generate_documentation_file Whether or not to generate a documentation file. Boolean optional True
include_host_model_dll Whether to include Microsoft.NET.HostModel from the toolchain. This is only required to build tha apphost shimmer. Boolean optional False
internals_visible_to Other libraries that can see the assembly's internal symbols. Using this rather than the InternalsVisibleTo assembly attribute will improve build caching. List of strings optional []
keyfile The key file used to sign the assembly with a strong name. Label optional None
langversion The version string for the language. String optional ""
nowarn List of warnings that should be ignored List of strings optional ["CS1701", "CS1702"]
nullable Enable nullable context, or nullable warnings. String optional "disable"
project_sdk The project SDK that is being targeted. See https://learn.microsoft.com/en-us/dotnet/core/project-sdk/overview String optional "default"
roll_forward_behavior The roll forward behavior that should be used: https://learn.microsoft.com/en-us/dotnet/core/versions/selection#control-roll-forward-behavior String optional "Major"
run_analyzers Controls whether analyzers run at build time. Boolean optional True
target_frameworks A list of target framework monikers to buildSee https://docs.microsoft.com/en-us/dotnet/standard/frameworks List of strings required
treat_warnings_as_errors Treat all compiler warnings as errors. Note that this attribute can not be used in conjunction with warnings_as_errors. Boolean optional False
warning_level The warning level that should be used by the compiler. Integer optional 3
warnings_as_errors List of compiler warning codes that should be considered as errors. Note that this attribute can not be used in conjunction with treat_warning_as_errors. List of strings optional []
warnings_not_as_errors List of compiler warning codes that should not be considered as errors. Note that this attribute can only be used in conjunction with treat_warning_as_errors. List of strings optional []
winexe If true, output a winexe-style executable, otherwiseoutput a console-style executable. Boolean optional False

csharp_library

load("@rules_dotnet//dotnet:defs.bzl", "csharp_library")

csharp_library(name, deps, srcs, data, resources, out, additionalfiles, allow_unsafe_blocks,
               analyzer_configs, compile_data, compiler_options, defines, exports,
               generate_documentation_file, internals_visible_to, is_analyzer,
               is_language_specific_analyzer, keyfile, langversion, nowarn, nullable, project_sdk,
               run_analyzers, target_frameworks, treat_warnings_as_errors, warning_level,
               warnings_as_errors, warnings_not_as_errors)

Compile a C# DLL

ATTRIBUTES

Name Description Type Mandatory Default
name A unique name for this target. Name required
deps Other libraries, binaries, or imported DLLs List of labels optional []
srcs The source files used in the compilation. List of labels optional []
data Runtime files. It is recommended to use the @rules_dotnet//tools/runfiles library to read the runtime files. List of labels optional []
resources A list of files to embed in the DLL as resources. List of labels optional []
out File name, without extension, of the built assembly. String optional ""
additionalfiles Extra files to configure analyzers. List of labels optional []
allow_unsafe_blocks Allow compiling unsafe code. It true, /unsafe is passed to the compiler. Boolean optional False
analyzer_configs A list of analyzer configuration files. See: https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/configuration-files List of labels optional []
compile_data Additional compile time files. List of labels optional []
compiler_options Additional options to pass to the compiler. This attribute should only be used if the compiler flag has not already been exposed as an attribute. List of strings optional []
defines A list of preprocessor directive symbols to define. List of strings optional []
exports List of targets to add to the dependencies of those that depend on this target. Use this sparingly as it weakens the precision of the build graph.

This attribute does nothing if you don't have strict dependencies enabled.
List of labels optional []
generate_documentation_file Whether or not to generate a documentation file. Boolean optional True
internals_visible_to Other libraries that can see the assembly's internal symbols. Using this rather than the InternalsVisibleTo assembly attribute will improve build caching. List of strings optional []
is_analyzer Whether this library is an analyzer or not. This flag is needs to be set to true if the library is an analyzer or a source generator. Boolean optional False
is_language_specific_analyzer Whether this library is a language specific analyzer/source generator or not. This flag is needs to be set to true if the library is a analyzer that is specific to a language or if the library is a source generator. Boolean optional False
keyfile The key file used to sign the assembly with a strong name. Label optional None
langversion The version string for the language. String optional ""
nowarn List of warnings that should be ignored List of strings optional ["CS1701", "CS1702"]
nullable Enable nullable context, or nullable warnings. String optional "disable"
project_sdk The project SDK that is being targeted. See https://learn.microsoft.com/en-us/dotnet/core/project-sdk/overview String optional "default"
run_analyzers Controls whether analyzers run at build time. Boolean optional True
target_frameworks A list of target framework monikers to buildSee https://docs.microsoft.com/en-us/dotnet/standard/frameworks List of strings required
treat_warnings_as_errors Treat all compiler warnings as errors. Note that this attribute can not be used in conjunction with warnings_as_errors. Boolean optional False
warning_level The warning level that should be used by the compiler. Integer optional 3
warnings_as_errors List of compiler warning codes that should be considered as errors. Note that this attribute can not be used in conjunction with treat_warning_as_errors. List of strings optional []
warnings_not_as_errors List of compiler warning codes that should not be considered as errors. Note that this attribute can only be used in conjunction with treat_warning_as_errors. List of strings optional []

csharp_test

load("@rules_dotnet//dotnet:defs.bzl", "csharp_test")

csharp_test(name, deps, srcs, data, resources, out, additionalfiles, allow_unsafe_blocks,
            analyzer_configs, appsetting_files, compile_data, compiler_options, defines, envs,
            generate_documentation_file, internals_visible_to, keyfile, langversion, nowarn, nullable,
            project_sdk, roll_forward_behavior, run_analyzers, target_frameworks,
            treat_warnings_as_errors, warning_level, warnings_as_errors, warnings_not_as_errors,
            winexe)

Compiles a C# executable and runs it as a test

ATTRIBUTES

Name Description Type Mandatory Default
name A unique name for this target. Name required
deps Other libraries, binaries, or imported DLLs List of labels optional []
srcs The source files used in the compilation. List of labels optional []
data Runtime files. It is recommended to use the @rules_dotnet//tools/runfiles library to read the runtime files. List of labels optional []
resources A list of files to embed in the DLL as resources. List of labels optional []
out File name, without extension, of the built assembly. String optional ""
additionalfiles Extra files to configure analyzers. List of labels optional []
allow_unsafe_blocks Allow compiling unsafe code. It true, /unsafe is passed to the compiler. Boolean optional False
analyzer_configs A list of analyzer configuration files. See: https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/configuration-files List of labels optional []
appsetting_files A list of appsettings files to include in the output directory. List of labels optional []
compile_data Additional compile time files. List of labels optional []
compiler_options Additional options to pass to the compiler. This attribute should only be used if the compiler flag has not already been exposed as an attribute. List of strings optional []
defines A list of preprocessor directive symbols to define. List of strings optional []
envs A dictionary of environment variables to set when the binary is run. Supports make variable expansion Dictionary: String -> String optional {}
generate_documentation_file Whether or not to generate a documentation file. Boolean optional True
internals_visible_to Other libraries that can see the assembly's internal symbols. Using this rather than the InternalsVisibleTo assembly attribute will improve build caching. List of strings optional []
keyfile The key file used to sign the assembly with a strong name. Label optional None
langversion The version string for the language. String optional ""
nowarn List of warnings that should be ignored List of strings optional ["CS1701", "CS1702"]
nullable Enable nullable context, or nullable warnings. String optional "disable"
project_sdk The project SDK that is being targeted. See https://learn.microsoft.com/en-us/dotnet/core/project-sdk/overview String optional "default"
roll_forward_behavior The roll forward behavior that should be used: https://learn.microsoft.com/en-us/dotnet/core/versions/selection#control-roll-forward-behavior String optional "Major"
run_analyzers Controls whether analyzers run at build time. Boolean optional True
target_frameworks A list of target framework monikers to buildSee https://docs.microsoft.com/en-us/dotnet/standard/frameworks List of strings required
treat_warnings_as_errors Treat all compiler warnings as errors. Note that this attribute can not be used in conjunction with warnings_as_errors. Boolean optional False
warning_level The warning level that should be used by the compiler. Integer optional 3
warnings_as_errors List of compiler warning codes that should be considered as errors. Note that this attribute can not be used in conjunction with treat_warning_as_errors. List of strings optional []
warnings_not_as_errors List of compiler warning codes that should not be considered as errors. Note that this attribute can only be used in conjunction with treat_warning_as_errors. List of strings optional []
winexe If true, output a winexe-style executable, otherwiseoutput a console-style executable. Boolean optional False

fsharp_binary

load("@rules_dotnet//dotnet:defs.bzl", "fsharp_binary")

fsharp_binary(name, deps, srcs, data, resources, out, appsetting_files, compile_data,
              compiler_options, defines, envs, generate_documentation_file, internals_visible_to,
              keyfile, langversion, nowarn, project_sdk, roll_forward_behavior, target_frameworks,
              treat_warnings_as_errors, warning_level, warnings_as_errors, warnings_not_as_errors,
              winexe)

Compile a F# exe

ATTRIBUTES

Name Description Type Mandatory Default
name A unique name for this target. Name required
deps Other libraries, binaries, or imported DLLs List of labels optional []
srcs The source files used in the compilation. List of labels optional []
data Runtime files. It is recommended to use the @rules_dotnet//tools/runfiles library to read the runtime files. List of labels optional []
resources A list of files to embed in the DLL as resources. List of labels optional []
out File name, without extension, of the built assembly. String optional ""
appsetting_files A list of appsettings files to include in the output directory. List of labels optional []
compile_data Additional compile time files. List of labels optional []
compiler_options Additional options to pass to the compiler. This attribute should only be used if the compiler flag has not already been exposed as an attribute. List of strings optional []
defines A list of preprocessor directive symbols to define. List of strings optional []
envs A dictionary of environment variables to set when the binary is run. Supports make variable expansion Dictionary: String -> String optional {}
generate_documentation_file Whether or not to generate a documentation file. Boolean optional True
internals_visible_to Other libraries that can see the assembly's internal symbols. Using this rather than the InternalsVisibleTo assembly attribute will improve build caching. List of strings optional []
keyfile The key file used to sign the assembly with a strong name. Label optional None
langversion The version string for the language. String optional ""
nowarn List of warnings that should be ignored List of strings optional []
project_sdk The project SDK that is being targeted. See https://learn.microsoft.com/en-us/dotnet/core/project-sdk/overview String optional "default"
roll_forward_behavior The roll forward behavior that should be used: https://learn.microsoft.com/en-us/dotnet/core/versions/selection#control-roll-forward-behavior String optional "Major"
target_frameworks A list of target framework monikers to buildSee https://docs.microsoft.com/en-us/dotnet/standard/frameworks List of strings required
treat_warnings_as_errors Treat all compiler warnings as errors. Note that this attribute can not be used in conjunction with warnings_as_errors. Boolean optional False
warning_level The warning level that should be used by the compiler. Integer optional 3
warnings_as_errors List of compiler warning codes that should be considered as errors. Note that this attribute can not be used in conjunction with treat_warning_as_errors. List of strings optional []
warnings_not_as_errors List of compiler warning codes that should not be considered as errors. Note that this attribute can only be used in conjunction with treat_warning_as_errors. List of strings optional []
winexe If true, output a winexe-style executable, otherwiseoutput a console-style executable. Boolean optional False

fsharp_library

load("@rules_dotnet//dotnet:defs.bzl", "fsharp_library")

fsharp_library(name, deps, srcs, data, resources, out, compile_data, compiler_options, defines,
               exports, generate_documentation_file, internals_visible_to, keyfile, langversion,
               nowarn, project_sdk, target_frameworks, treat_warnings_as_errors, warning_level,
               warnings_as_errors, warnings_not_as_errors)

Compile a F# DLL

ATTRIBUTES

Name Description Type Mandatory Default
name A unique name for this target. Name required
deps Other libraries, binaries, or imported DLLs List of labels optional []
srcs The source files used in the compilation. List of labels optional []
data Runtime files. It is recommended to use the @rules_dotnet//tools/runfiles library to read the runtime files. List of labels optional []
resources A list of files to embed in the DLL as resources. List of labels optional []
out File name, without extension, of the built assembly. String optional ""
compile_data Additional compile time files. List of labels optional []
compiler_options Additional options to pass to the compiler. This attribute should only be used if the compiler flag has not already been exposed as an attribute. List of strings optional []
defines A list of preprocessor directive symbols to define. List of strings optional []
exports List of targets to add to the dependencies of those that depend on this target. Use this sparingly as it weakens the precision of the build graph.

This attribute does nothing if you don't have strict dependencies enabled.
List of labels optional []
generate_documentation_file Whether or not to generate a documentation file. Boolean optional True
internals_visible_to Other libraries that can see the assembly's internal symbols. Using this rather than the InternalsVisibleTo assembly attribute will improve build caching. List of strings optional []
keyfile The key file used to sign the assembly with a strong name. Label optional None
langversion The version string for the language. String optional ""
nowarn List of warnings that should be ignored List of strings optional []
project_sdk The project SDK that is being targeted. See https://learn.microsoft.com/en-us/dotnet/core/project-sdk/overview String optional "default"
target_frameworks A list of target framework monikers to buildSee https://docs.microsoft.com/en-us/dotnet/standard/frameworks List of strings required
treat_warnings_as_errors Treat all compiler warnings as errors. Note that this attribute can not be used in conjunction with warnings_as_errors. Boolean optional False
warning_level The warning level that should be used by the compiler. Integer optional 3
warnings_as_errors List of compiler warning codes that should be considered as errors. Note that this attribute can not be used in conjunction with treat_warning_as_errors. List of strings optional []
warnings_not_as_errors List of compiler warning codes that should not be considered as errors. Note that this attribute can only be used in conjunction with treat_warning_as_errors. List of strings optional []

fsharp_test

load("@rules_dotnet//dotnet:defs.bzl", "fsharp_test")

fsharp_test(name, deps, srcs, data, resources, out, appsetting_files, compile_data,
            compiler_options, defines, envs, generate_documentation_file, internals_visible_to,
            keyfile, langversion, nowarn, project_sdk, roll_forward_behavior, target_frameworks,
            treat_warnings_as_errors, warning_level, warnings_as_errors, warnings_not_as_errors,
            winexe)

Compile a F# executable and runs it as a test

ATTRIBUTES

Name Description Type Mandatory Default
name A unique name for this target. Name required
deps Other libraries, binaries, or imported DLLs List of labels optional []
srcs The source files used in the compilation. List of labels optional []
data Runtime files. It is recommended to use the @rules_dotnet//tools/runfiles library to read the runtime files. List of labels optional []
resources A list of files to embed in the DLL as resources. List of labels optional []
out File name, without extension, of the built assembly. String optional ""
appsetting_files A list of appsettings files to include in the output directory. List of labels optional []
compile_data Additional compile time files. List of labels optional []
compiler_options Additional options to pass to the compiler. This attribute should only be used if the compiler flag has not already been exposed as an attribute. List of strings optional []
defines A list of preprocessor directive symbols to define. List of strings optional []
envs A dictionary of environment variables to set when the binary is run. Supports make variable expansion Dictionary: String -> String optional {}
generate_documentation_file Whether or not to generate a documentation file. Boolean optional True
internals_visible_to Other libraries that can see the assembly's internal symbols. Using this rather than the InternalsVisibleTo assembly attribute will improve build caching. List of strings optional []
keyfile The key file used to sign the assembly with a strong name. Label optional None
langversion The version string for the language. String optional ""
nowarn List of warnings that should be ignored List of strings optional []
project_sdk The project SDK that is being targeted. See https://learn.microsoft.com/en-us/dotnet/core/project-sdk/overview String optional "default"
roll_forward_behavior The roll forward behavior that should be used: https://learn.microsoft.com/en-us/dotnet/core/versions/selection#control-roll-forward-behavior String optional "Major"
target_frameworks A list of target framework monikers to buildSee https://docs.microsoft.com/en-us/dotnet/standard/frameworks List of strings required
treat_warnings_as_errors Treat all compiler warnings as errors. Note that this attribute can not be used in conjunction with warnings_as_errors. Boolean optional False
warning_level The warning level that should be used by the compiler. Integer optional 3
warnings_as_errors List of compiler warning codes that should be considered as errors. Note that this attribute can not be used in conjunction with treat_warning_as_errors. List of strings optional []
warnings_not_as_errors List of compiler warning codes that should not be considered as errors. Note that this attribute can only be used in conjunction with treat_warning_as_errors. List of strings optional []
winexe If true, output a winexe-style executable, otherwiseoutput a console-style executable. Boolean optional False

import_dll

load("@rules_dotnet//dotnet:defs.bzl", "import_dll")

import_dll(name, data, dll, version)

Imports a DLL

ATTRIBUTES

Name Description Type Mandatory Default
name A unique name for this target. Name required
data Other files that this DLL depends on at runtime List of labels optional []
dll The name of the library Label required
version The version of the library String optional ""

import_library

load("@rules_dotnet//dotnet:defs.bzl", "import_library")

import_library(name, deps, data, analyzers, analyzers_csharp, analyzers_fsharp, analyzers_vb,
               framework_list, library_name, libs, native, nupkg, refs, sha512,
               targeting_pack_overrides, version)

Creates a target for a static DLL for a specific target framework

ATTRIBUTES

Name Description Type Mandatory Default
name A unique name for this target. Name required
deps Other DLLs that this DLL depends on. List of labels optional []
data Other files that this DLL depends on at runtime List of labels optional []
analyzers Static analyzer DLLs List of labels optional []
analyzers_csharp Static C# analyzer DLLs List of labels optional []
analyzers_fsharp Static F# analyzer DLLs List of labels optional []
analyzers_vb Static VB analyzer DLLs List of labels optional []
framework_list Targeting packs like e.g. Microsoft.NETCore.App.Ref have a PlatformManifest.txt that includes all the DLLs that are included in the targeting pack. This is used to determine which version of a DLL should be used during compilation or runtime. Dictionary: String -> String optional {}
library_name The name of the library String required
libs Static runtime DLLs List of labels optional []
native Native runtime DLLs List of labels optional []
nupkg The .nupkg file providing this import Label optional None
refs Compile time DLLs List of labels optional []
sha512 The SHA512 sum of the NuGet package String optional ""
targeting_pack_overrides Targeting packs like e.g. Microsoft.NETCore.App.Ref have a PackageOverride.txt that includes a list of NuGet packages that should be omitted in a compiliation because they are included in the targeting pack Dictionary: String -> String optional {}
version The version of the library String optional ""

publish_binary

load("@rules_dotnet//dotnet:defs.bzl", "publish_binary")

publish_binary(name, binary, roll_forward_behavior, runtime_identifier, self_contained,
               target_framework)

Publish a .Net binary

ATTRIBUTES

Name Description Type Mandatory Default
name A unique name for this target. Name required
binary The .Net binary that is being published Label required
roll_forward_behavior The roll forward behavior that should be used: https://learn.microsoft.com/en-us/dotnet/core/versions/selection#control-roll-forward-behavior String optional "Minor"
runtime_identifier The runtime identifier that is being targeted. See https://docs.microsoft.com/en-us/dotnet/core/rid-catalog String optional ""
self_contained Whether the binary should be self-contained.

If true, the binary will be published as a self-contained but you need to provide a runtime pack in the runtime_packs attribute. At some point the rules might resolve the runtime pack automatically.

If false, the binary will be published as a non-self-contained. That means that to be able to run the binary you need to have a .Net runtime installed on the host system.
Boolean optional False
target_framework The target framework that should be published String required

csharp_nunit_test

load("@rules_dotnet//dotnet:defs.bzl", "csharp_nunit_test")

csharp_nunit_test(kwargs)

PARAMETERS

Name Description Default Value
kwargs

-

none

fsharp_nunit_test

load("@rules_dotnet//dotnet:defs.bzl", "fsharp_nunit_test")

fsharp_nunit_test(kwargs)

PARAMETERS

Name Description Default Value
kwargs

-

none

nuget_repo

load("@rules_dotnet//dotnet:defs.bzl", "nuget_repo")

nuget_repo(name, packages)

PARAMETERS

Name Description Default Value
name

-

none
packages

-

none

nuget_archive

load("@rules_dotnet//dotnet:defs.bzl", "nuget_archive")

nuget_archive(name, id, netrc, repo_mapping, sha512, sources, version)

ATTRIBUTES

Name Description Type Mandatory Default
name A unique name for this repository. Name required
id - String optional ""
netrc - Label optional None
repo_mapping In WORKSPACE context only: a dictionary from local repository name to global repository name. This allows controls over workspace dependency resolution for dependencies of this repository.

For example, an entry "@foo": "@bar" declares that, for any time this repository depends on @foo (such as a dependency on @foo//some:target, it should actually resolve that dependency within globally-declared @bar (@bar//some:target).

This attribute is not supported in MODULE.bazel context (when invoking a repository rule inside a module extension's implementation function).
Dictionary: String -> String optional
sha512 - String optional ""
sources - List of strings optional []
version - String optional ""