core_download_sdk
core_download_sdk(name, arch, os, repo_mapping, runtimeVersion, sdkVersion, sdks, strip_prefix)
This downloads .NET Core SDK for given version. It usually is not used directly. Use dotnet_repositories instead.
ATTRIBUTES
Name | Description | Type | Mandatory | Default |
---|---|---|---|---|
name | A unique name for this repository. | Name | required | |
arch | Architecture for the SDK. | String | required | |
os | Operating system for the SDK. | String | required | |
repo_mapping | A dictionary from local repository name to global repository name. This allows controls over workspace dependency resolution for dependencies of this repository.<p>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 ). |
Dictionary: String -> String | required | |
runtimeVersion | Runtime version to use. It's bound to sdkVersion. | String | required | |
sdkVersion | SDK version to use. | String | required | |
sdks | Map of URLs. See CORE_SDK_REPOSITORIES in dotnet/private/toolchain/toolchains.bzl for the expected shape of the parameter. | Dictionary: String -> List of strings | required | |
strip_prefix | If present then provided prefix is stripped when extracting SDK. | String | optional | "" |
core_import_binary
core_import_binary(name, data, data_with_dirs, deps, ref, src, version)
This imports an external assembly and transforms it into .NET Core binary.
ATTRIBUTES
Name | Description | Type | Mandatory | Default |
---|---|---|---|---|
name | A unique name for this target. | Name | required | |
data | Additional files to copy with the target assembly. | List of labels | optional | [] |
data_with_dirs | Dictionary of {label:folder}. Files specified by <label> will be put in subdirectory <folder>. | Dictionary: Label -> String | optional | {} |
deps | The direct dependencies of this dll. These may be rules or compatible rules with the DotnetLibraryInfo provider. | List of labels | optional | [] |
ref | Reference assembly for given library. | Label | optional | None |
src | The file to be transformed into DotnetLibraryInfo provider. | Label | required | |
version | Version of the imported assembly. | String | required |
core_import_library
core_import_library(name, data, deps, ref, src, version)
This imports an external dll and transforms it into DotnetLibraryInfo so it can be referenced as dependency by other rules.
ATTRIBUTES
Name | Description | Type | Mandatory | Default |
---|---|---|---|---|
name | A unique name for this target. | Name | required | |
data | Additional files to copy with the target assembly. | List of labels | optional | [] |
deps | The direct dependencies of this dll. These may be compatible with the DotnetLibraryInfo provider. | List of labels | optional | [] |
ref | Reference assembly for given library. | Label | optional | None |
src | The file to be transformed into DotnetLibraryInfo provider. | Label | required | |
version | Version of the imported assembly. | String | required |
core_libraryset
core_libraryset(name, data, deps)
Groups libraries into sets which may be used as dependency.
ATTRIBUTES
Name | Description | Type | Mandatory | Default |
---|---|---|---|---|
name | A unique name for this target. | Name | required | |
data | The list of additional files to include in the list of runfiles for compiled assembly. | List of labels | optional | [] |
deps | The list of dependencies. | List of labels | optional | [] |
core_resource
core_resource(name, identifier, src)
This wraps a resource so it can be embeded into an assembly.
ATTRIBUTES
Name | Description | Type | Mandatory | Default |
---|---|---|---|---|
name | A unique name for this target. | Name | required | |
identifier | The logical name for the resource; the name is used to load the resource. The default is the basename of the file name (no subfolder). | String | optional | "" |
src | The source to be embeded. | Label | required |
core_resource_multi
core_resource_multi(name, fixedIdentifierBase, identifierBase, srcs)
This wraps multiple resource files so they can be embeded into an assembly.
ATTRIBUTES
Name | Description | Type | Mandatory | Default |
---|---|---|---|---|
name | A unique name for this target. | Name | required | |
fixedIdentifierBase | The logical name for given resource is constructred from fixedIdentiferBase + "." + filename. The resulting name that is used to load the resource. Either identifierBase of fixedIdentifierBase must be specified. | String | optional | "" |
identifierBase | The logical name for given resource is constructred from identiferBase + "." + directory.repalce('/','.') + "." + filename. The resulting name is used to load the resource. Either identifierBase of fixedIdentifierBase must be specified. | String | optional | "" |
srcs | The source files to be embeded. | List of labels | required |
core_resx
core_resx(name, identifier, out, simpleresgen, src)
This builds a dotnet .resources file from a single .resx file. Uses a custom tool to convert text .resx file to .resources files because no standard tool is provided.
ATTRIBUTES
Name | Description | Type | Mandatory | Default |
---|---|---|---|---|
name | A unique name for this target. | Name | required | |
identifier | The logical name for the resource; the name that is used to load the resource. The default is the basename of the file name (no subfolder). | String | optional | "" |
out | An alternative name of the output file | String | optional | "" |
simpleresgen | An alternative tool for generating resources file. | Label | optional | @io_bazel_rules_dotnet//tools/simpleresgen:simpleresgen.exe |
src | The .resx source file that is transformed into .resources file. | Label | required |
core_stdlib
core_stdlib(name, data, deps, dll, dotnet_context_data, ref, stdlib_path, version)
It imports a framework dll and transforms it into DotnetLibraryInfo so it can be referenced as dependency by other rules.
ATTRIBUTES
Name | Description | Type | Mandatory | Default |
---|---|---|---|---|
name | A unique name for this target. | Name | required | |
data | Additional files to copy with the target assembly. | List of labels | optional | [] |
deps | The direct dependencies of this dll. These may be rules or compatible rules with the DotnetLibraryInfo provider. | List of labels | optional | [] |
dll | - | String | optional | "" |
dotnet_context_data | - | Label | optional | @io_bazel_rules_dotnet//:core_context_data |
ref | Reference assembly for given library. | Label | optional | None |
stdlib_path | The stdlib_path to be used instead of looking for one in sdk by name speeds up the rule execution because the proper file needs not to be searched for within sdk. | Label | optional | None |
version | Version of the assembly. | String | required |
core_stdlib_internal
core_stdlib_internal(name, data, deps, dll, ref, stdlib_path, version)
Internal. Do not use. It imports a framework dll and transforms it into DotnetLibraryInfo so it can be referenced as dependency by other rules. Used by //dotnet/stdlib... packages. It doesn't use dotnet_context_data.
ATTRIBUTES
Name | Description | Type | Mandatory | Default |
---|---|---|---|---|
name | A unique name for this target. | Name | required | |
data | - | List of labels | optional | [] |
deps | - | List of labels | optional | [] |
dll | - | String | optional | "" |
ref | - | Label | optional | None |
stdlib_path | - | Label | required | |
version | - | String | required |
csharp_binary
csharp_binary(name, data, data_with_dirs, defines, deps, keyfile, langversion, nowarn, out, resources, srcs, target_framework, unsafe, version)
This builds an executable from a set of source files.
You can run the binary with ``bazel run``, or you can build it with ``bazel build`` and run it directly.
Providers
^^^^^^^^^
* [DotnetLibraryInfo](api.md#dotnetlibraryinfo)
* [DotnetResourceInfo](api.md#dotnetresourceinfo)
Example:
^^^^^^^^
```python
csharp_binary(
name = "Program.exe",
srcs = [
"Program.cs",
],
deps = [
"@io_bazel_rules_dotnet//dotnet/stdlib.core:libraryset",
],
)
```
ATTRIBUTES
Name | Description | Type | Mandatory | Default |
---|---|---|---|---|
name | A unique name for this target. | Name | required | |
data | The list of additional files to include in the list of runfiles for the assembly. | List of labels | optional | [] |
data_with_dirs | Dictionary of {label:folder}. Files specified by <label> will be put in subdirectory <folder>. | Dictionary: Label -> String | optional | {} |
defines | The list of defines passed via /define compiler option. | List of strings | optional | [] |
deps | The direct dependencies of this library. These may be dotnet_library rules or compatible rules with the DotnetLibraryInfo provider. | List of labels | optional | [] |
keyfile | The key to sign the assembly with. | Label | optional | None |
langversion | Version of the language to use. See this page. | String | optional | "latest" |
nowarn | The list of warnings to be ignored. The warnings are passed to -nowarn compiler opion. | List of strings | optional | [] |
out | An alternative name of the output file. | String | optional | "" |
resources | The list of resources to compile with. Usually provided via reference to core_resx or the rules compatible with DotnetResourceInfo provider. | List of labels | optional | [] |
srcs | The list of .cs source files that are compiled to create the assembly. | List of labels | optional | [] |
target_framework | Target framework. | String | optional | "" |
unsafe | If true passes /unsafe flag to the compiler. | Boolean | optional | False |
version | Version to be set for the assembly. The version is set by compiling in AssemblyVersion attribute. | String | optional | "" |
csharp_library
csharp_library(name, data, defines, deps, keyfile, langversion, nowarn, out, resources, srcs, target_framework, unsafe, version)
This builds a dotnet assembly from a set of source files.
Providers
^^^^^^^^^
* [DotnetLibraryInfo](api.md#dotnetlibraryinfo)
* [DotnetResourceInfo](api.md#dotnetresourceinfo)
Example:
^^^^^^^^
```python
[csharp_library(
name = "{}_TransitiveClass-core.dll".format(framework),
srcs = [
"TransitiveClass.cs",
],
dotnet_context_data = "@io_bazel_rules_dotnet//:core_context_data_{}".format(framework),
visibility = ["//visibility:public"],
deps = [
"@io_bazel_rules_dotnet//dotnet/stdlib.core/{}:libraryset".format(framework),
],
) for framework in DOTNET_CORE_FRAMEWORKS]
```
ATTRIBUTES
Name | Description | Type | Mandatory | Default |
---|---|---|---|---|
name | A unique name for this target. | Name | required | |
data | The list of additional files to include in the list of runfiles for the assembly. | List of labels | optional | [] |
defines | The list of defines passed via /define compiler option. | List of strings | optional | [] |
deps | The direct dependencies of this library. These may be dotnet_library rules or compatible rules with the DotnetLibraryInfo provider. | List of labels | optional | [] |
keyfile | The key to sign the assembly with. | Label | optional | None |
langversion | Version of the language to use. See this page. | String | optional | "latest" |
nowarn | The list of warnings to be ignored. The warnings are passed to -nowarn compiler opion. | List of strings | optional | [] |
out | An alternative name of the output file. | String | optional | "" |
resources | The list of resources to compile with. Usually provided via reference to core_resx or the rules compatible with DotnetResourceInfo provider. | List of labels | optional | [] |
srcs | The list of .cs source files that are compiled to create the assembly. | List of labels | optional | [] |
target_framework | Target framework. | String | optional | "" |
unsafe | If true passes /unsafe flag to the compiler. | Boolean | optional | False |
version | Version to be set for the assembly. The version is set by compiling in AssemblyVersion attribute. | String | optional | "" |
csharp_nunit3_test
csharp_nunit3_test(name, data, data_with_dirs, defines, deps, keyfile, langversion, nowarn, out, resources, srcs, testlauncher, unsafe, version)
This builds a set of tests that can be run with bazel test
.
To run all tests in the workspace, and print output on failure, run
```bash
bazel test --test_output=errors //...
```
You can run specific tests by passing the `--test_filter=pattern <test_filter_>` argument to Bazel.
You can pass arguments to tests by passing `--test_arg=arg <test_arg_>`_ arguments to Bazel.
ATTRIBUTES
Name | Description | Type | Mandatory | Default |
---|---|---|---|---|
name | A unique name for this target. | Name | required | |
data | The list of additional files to include in the list of runfiles for the assembly. | List of labels | optional | [] |
data_with_dirs | Dictionary of {label:folder}. Files specified by <label> will be put in subdirectory <folder>. | Dictionary: Label -> String | optional | {"@vstest//:Microsoft.TestPlatform.TestHostRuntimeProvider.dll": "Extensions", "@NUnit3TestAdapter//:extension": ".", "@JunitXml.TestLogger//:extension": "."} |
defines | The list of defines passed via /define compiler option. | List of strings | optional | [] |
deps | The direct dependencies of this library. These may be dotnet_library rules or compatible rules with the DotnetLibraryInfo provider. | List of labels | optional | [] |
keyfile | The key to sign the assembly with. | Label | optional | None |
langversion | Version of the language to use. See this page. | String | optional | "latest" |
nowarn | The list of warnings to be ignored. The warnings are passed to -nowarn compiler opion. | List of strings | optional | [] |
out | An alternative name of the output file. | String | optional | "" |
resources | The list of resources to compile with. Usually provided via reference to core_resx or the rules compatible with DotnetResourceInfo provider. | List of labels | optional | [] |
srcs | The list of .cs source files that are compiled to create the assembly. | List of labels | optional | [] |
testlauncher | Test launcher to use. | Label | optional | @vstest//:vstest.console.exe |
unsafe | If true passes /unsafe flag to the compiler. | Boolean | optional | False |
version | Version to be set for the assembly. The version is set by compiling in AssemblyVersion attribute. | String | optional | "" |
csharp_xunit_test
csharp_xunit_test(name, data, data_with_dirs, defines, deps, keyfile, langversion, nowarn, out, resources, srcs, testlauncher, unsafe, version)
This builds a set of tests that can be run with bazel test
.
To run all tests in the workspace, and print output on failure, run
```bash
bazel test --test_output=errors //...
```
You can run specific tests by passing the `--test_filter=pattern <test_filter_>` argument to Bazel.
You can pass arguments to tests by passing `--test_arg=arg <test_arg_>`_ arguments to Bazel.
ATTRIBUTES
Name | Description | Type | Mandatory | Default |
---|---|---|---|---|
name | A unique name for this target. | Name | required | |
data | The list of additional files to include in the list of runfiles for the assembly. | List of labels | optional | [] |
data_with_dirs | Dictionary of {label:folder}. Files specified by <label> will be put in subdirectory <folder>. | Dictionary: Label -> String | optional | {} |
defines | The list of defines passed via /define compiler option. | List of strings | optional | [] |
deps | The direct dependencies of this library. These may be dotnet_library rules or compatible rules with the DotnetLibraryInfo provider. | List of labels | optional | [] |
keyfile | The key to sign the assembly with. | Label | optional | None |
langversion | Version of the language to use. See this page. | String | optional | "latest" |
nowarn | The list of warnings to be ignored. The warnings are passed to -nowarn compiler opion. | List of strings | optional | [] |
out | An alternative name of the output file. | String | optional | "" |
resources | The list of resources to compile with. Usually provided via reference to core_resx or the rules compatible with DotnetResourceInfo provider. | List of labels | optional | [] |
srcs | The list of .cs source files that are compiled to create the assembly. | List of labels | optional | [] |
testlauncher | Test launcher to use. | Label | optional | @xunit.runner.console//:tool |
unsafe | If true passes /unsafe flag to the compiler. | Boolean | optional | False |
version | Version to be set for the assembly. The version is set by compiling in AssemblyVersion attribute. | String | optional | "" |
dotnet_nuget_new
dotnet_nuget_new(name, build_file, build_file_content, package, repo_mapping, sha256, source, version)
Repository rule to download and extract nuget package. Usually nuget_package is a better choice.
Usually used with [dotnet_import_library](#dotnet_import_library).
Example:
```python
dotnet_nuget_new(
name = "npgsql",
package="Npgsql",
version="3.2.7",
sha256="fa3e0cfbb2caa9946d2ce3d8174031a06320aad2c9e69a60f7739b9ddf19f172",
build_file_content = """
package(default_visibility = [ "//visibility:public" ])
load("@io_bazel_rules_dotnet//dotnet:defs.bzl", "dotnet_import_library")
dotnet_import_library(
name = "npgsqllib",
src = "lib/net451/Npgsql.dll"
)
"""
)
```
ATTRIBUTES
Name | Description | Type | Mandatory | Default |
---|---|---|---|---|
name | A unique name for this repository. | Name | required | |
build_file | The file to use as the BUILD file for this repository. This attribute is an absolute label (use '@//' for the main repo). The file does not need to be named BUILD, but can be (something like BUILD.new-repo-name may work well for distinguishing it from the repository's actual BUILD files. Either build_file or build_file_content can be specified, but not both. | Label | optional | None |
build_file_content | The content for the BUILD file for this repository. Either build_file or build_file_content can be specified, but not both. | String | optional | "" |
package | The name of the nuget package. | String | required | |
repo_mapping | A dictionary from local repository name to global repository name. This allows controls over workspace dependency resolution for dependencies of this repository.<p>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 ). |
Dictionary: String -> String | required | |
sha256 | Sha256 digest of the downloaded package. | String | optional | "" |
source | Nuget repository to download the nuget package from. The final url is in the format shape {source}/{package}/{version}. | String | optional | "https://www.nuget.org/api/v2/package" |
version | The version of the nuget package. | String | required |
fsharp_binary
fsharp_binary(name, data, data_with_dirs, defines, deps, keyfile, langversion, nowarn, out, resources, srcs, target_framework, version)
This builds an executable from a set of source files.
You can run the binary with ``bazel run``, or you can build it with ``bazel build`` and run it directly.
Providers
^^^^^^^^^
* [DotnetLibraryInfo](api.md#dotnetlibraryinfo)
* [DotnetResourceInfo](api.md#dotnetresourceinfo)
Example:
^^^^^^^^
```python
fsharp_binary(
name = "Program.exe",
srcs = [
"Program.fs",
],
deps = [
"@io_bazel_rules_dotnet//dotnet/stdlib.core:libraryset",
],
)
```
ATTRIBUTES
Name | Description | Type | Mandatory | Default |
---|---|---|---|---|
name | A unique name for this target. | Name | required | |
data | The list of additional files to include in the list of runfiles for the assembly. | List of labels | optional | [] |
data_with_dirs | Dictionary of {label:folder}. Files specified by <label> will be put in subdirectory <folder>. | Dictionary: Label -> String | optional | {} |
defines | The list of defines passed via /define compiler option. | List of strings | optional | [] |
deps | The direct dependencies of this library. These may be dotnet_library rules or compatible rules with the DotnetLibraryInfo provider. | List of labels | optional | [] |
keyfile | The key to sign the assembly with. | Label | optional | None |
langversion | Version of the language to use. See this page. | String | optional | "latest" |
nowarn | The list of warnings to be ignored. The warnings are passed to -nowarn compiler opion. | List of strings | optional | [] |
out | An alternative name of the output file. | String | optional | "" |
resources | The list of resources to compile with. Usually provided via reference to core_resx or the rules compatible with DotnetResourceInfo provider. | List of labels | optional | [] |
srcs | The list of .fs source files that are compiled to create the assembly. | List of labels | optional | [] |
target_framework | Target framework. | String | optional | "" |
version | Version to be set for the assembly. The version is set by compiling in AssemblyVersion attribute. | String | optional | "" |
fsharp_library
fsharp_library(name, data, defines, deps, keyfile, langversion, nowarn, out, resources, srcs, target_framework, version)
This builds a dotnet assembly from a set of source files.
Providers
^^^^^^^^^
* [DotnetLibraryInfo](api.md#dotnetlibraryinfo)
* [DotnetResourceInfo](api.md#dotnetresourceinfo)
Example:
^^^^^^^^
```python
[fsharp_library(
name = "{}_TransitiveClass-core.dll".format(framework),
srcs = [
"TransitiveClass.fs",
],
visibility = ["//visibility:public"],
deps = [
"@io_bazel_rules_dotnet//dotnet/stdlib.core/{}:libraryset".format(framework),
],
) for framework in DOTNET_CORE_FRAMEWORKS]
```
ATTRIBUTES
Name | Description | Type | Mandatory | Default |
---|---|---|---|---|
name | A unique name for this target. | Name | required | |
data | The list of additional files to include in the list of runfiles for the assembly. | List of labels | optional | [] |
defines | The list of defines passed via /define compiler option. | List of strings | optional | [] |
deps | The direct dependencies of this library. These may be dotnet_library rules or compatible rules with the DotnetLibraryInfo provider. | List of labels | optional | [] |
keyfile | The key to sign the assembly with. | Label | optional | None |
langversion | Version of the language to use. | String | optional | "latest" |
nowarn | The list of warnings to be ignored. The warnings are passed to -nowarn compiler opion. | List of strings | optional | [] |
out | An alternative name of the output file. | String | optional | "" |
resources | The list of resources to compile with. Usually provided via reference to core_resx or the rules compatible with DotnetResourceInfo provider. | List of labels | optional | [] |
srcs | The list of .fs source files that are compiled to create the assembly. | List of labels | optional | [] |
target_framework | Target framework. | String | optional | "" |
version | Version to be set for the assembly. The version is set by compiling in AssemblyVersion attribute. | String | optional | "" |
fsharp_nunit3_test
fsharp_nunit3_test(name, data, data_with_dirs, defines, deps, keyfile, langversion, nowarn, out, resources, srcs, testlauncher, version)
This builds a set of tests that can be run with bazel test
.
To run all tests in the workspace, and print output on failure, run
```bash
bazel test --test_output=errors //...
```
You can run specific tests by passing the `--test_filter=pattern <test_filter_>` argument to Bazel.
You can pass arguments to tests by passing `--test_arg=arg <test_arg_>`_ arguments to Bazel.
ATTRIBUTES
Name | Description | Type | Mandatory | Default |
---|---|---|---|---|
name | A unique name for this target. | Name | required | |
data | The list of additional files to include in the list of runfiles for the assembly. | List of labels | optional | [] |
data_with_dirs | Dictionary of {label:folder}. Files specified by <label> will be put in subdirectory <folder>. | Dictionary: Label -> String | optional | {"@vstest//:Microsoft.TestPlatform.TestHostRuntimeProvider.dll": "Extensions", "@NUnit3TestAdapter//:extension": ".", "@JunitXml.TestLogger//:extension": "."} |
defines | The list of defines passed via /define compiler option. | List of strings | optional | [] |
deps | The direct dependencies of this library. These may be dotnet_library rules or compatible rules with the DotnetLibraryInfo provider. | List of labels | optional | [] |
keyfile | The key to sign the assembly with. | Label | optional | None |
langversion | Version of the language to use. See this page. | String | optional | "latest" |
nowarn | The list of warnings to be ignored. The warnings are passed to -nowarn compiler opion. | List of strings | optional | [] |
out | An alternative name of the output file. | String | optional | "" |
resources | The list of resources to compile with. Usually provided via reference to core_resx or the rules compatible with DotnetResourceInfo provider. | List of labels | optional | [] |
srcs | The list of .fs source files that are compiled to create the assembly. | List of labels | optional | [] |
testlauncher | Test launcher to use. | Label | optional | @vstest//:vstest.console.exe |
version | Version to be set for the assembly. The version is set by compiling in AssemblyVersion attribute. | String | optional | "" |
fsharp_xunit_test
fsharp_xunit_test(name, data, data_with_dirs, defines, deps, keyfile, langversion, nowarn, out, resources, srcs, testlauncher, version)
This builds a set of tests that can be run with bazel test
.
To run all tests in the workspace, and print output on failure, run
```bash
bazel test --test_output=errors //...
```
You can run specific tests by passing the `--test_filter=pattern <test_filter_>` argument to Bazel.
You can pass arguments to tests by passing `--test_arg=arg <test_arg_>`_ arguments to Bazel.
ATTRIBUTES
Name | Description | Type | Mandatory | Default |
---|---|---|---|---|
name | A unique name for this target. | Name | required | |
data | The list of additional files to include in the list of runfiles for the assembly. | List of labels | optional | [] |
data_with_dirs | Dictionary of {label:folder}. Files specified by <label> will be put in subdirectory <folder>. | Dictionary: Label -> String | optional | {} |
defines | The list of defines passed via /define compiler option. | List of strings | optional | [] |
deps | The direct dependencies of this library. These may be dotnet_library rules or compatible rules with the DotnetLibraryInfo provider. | List of labels | optional | [] |
keyfile | The key to sign the assembly with. | Label | optional | None |
langversion | Version of the language to use. See this page. | String | optional | "latest" |
nowarn | The list of warnings to be ignored. The warnings are passed to -nowarn compiler opion. | List of strings | optional | [] |
out | An alternative name of the output file. | String | optional | "" |
resources | The list of resources to compile with. Usually provided via reference to core_resx or the rules compatible with DotnetResourceInfo provider. | List of labels | optional | [] |
srcs | The list of .fs source files that are compiled to create the assembly. | List of labels | optional | [] |
testlauncher | Test launcher to use. | Label | optional | @xunit.runner.console//:tool |
version | Version to be set for the assembly. The version is set by compiling in AssemblyVersion attribute. | String | optional | "" |
nuget_package
nuget_package(name, core_deps, core_files, core_lib, core_ref, core_tool, mono_deps, mono_files, mono_lib, mono_ref, mono_tool, net_deps, net_files, net_lib, net_ref, net_tool, package, repo_mapping, sha256, source, version)
Repository rule to download and extract nuget package. The rule is usually generated by nuget2bazel tool.
Example
^^^^^^^
```python
nuget_package(
name = "commandlineparser",
package = "commandlineparser",
sha256 = "09e60ff23e6953b4fe7d267ef552d8ece76404acf44842012f84430e8b877b13",
core_lib = "lib/netstandard1.5/CommandLine.dll",
core_deps = [
"@io_bazel_rules_dotnet//dotnet/stdlib.core:system.collections.dll",
"@io_bazel_rules_dotnet//dotnet/stdlib.core:system.console.dll",
"@io_bazel_rules_dotnet//dotnet/stdlib.core:system.diagnostics.debug.dll",
"@io_bazel_rules_dotnet//dotnet/stdlib.core:system.globalization.dll",
"@io_bazel_rules_dotnet//dotnet/stdlib.core:system.io.dll",
"@io_bazel_rules_dotnet//dotnet/stdlib.core:system.linq.dll",
"@io_bazel_rules_dotnet//dotnet/stdlib.core:system.linq.expressions.dll",
"@io_bazel_rules_dotnet//dotnet/stdlib.core:system.reflection.dll",
"@io_bazel_rules_dotnet//dotnet/stdlib.core:system.reflection.extensions.dll",
"@io_bazel_rules_dotnet//dotnet/stdlib.core:system.reflection.typeextensions.dll",
"@io_bazel_rules_dotnet//dotnet/stdlib.core:system.resources.resourcemanager.dll",
"@io_bazel_rules_dotnet//dotnet/stdlib.core:system.runtime.dll",
"@io_bazel_rules_dotnet//dotnet/stdlib.core:system.runtime.extensions.dll",
],
core_files = [
"lib/netstandard1.5/CommandLine.dll",
"lib/netstandard1.5/CommandLine.xml",
],
)
```
ATTRIBUTES
Name | Description | Type | Mandatory | Default |
---|---|---|---|---|
name | A unique name for this repository. | Name | required | |
core_deps | The list of the dependencies of the package (core). | Dictionary: String -> List of strings | optional | {} |
core_files | The list of additional files within the package to be used as runfiles (necessary to run). | Dictionary: String -> List of strings | optional | {} |
core_lib | The path to .net core assembly within the nuget package. | Dictionary: String -> String | optional | {} |
core_ref | The path to .net core reference assembly within the nuget package. | Dictionary: String -> String | optional | {} |
core_tool | The path to .net core assembly within the nuget package (tools subdirectory). | Dictionary: String -> String | optional | {} |
mono_deps | - | List of labels | optional | [] |
mono_files | - | List of strings | optional | [] |
mono_lib | - | String | optional | "" |
mono_ref | - | String | optional | "" |
mono_tool | - | String | optional | "" |
net_deps | - | Dictionary: String -> List of strings | optional | {} |
net_files | - | Dictionary: String -> List of strings | optional | {} |
net_lib | - | Dictionary: String -> String | optional | {} |
net_ref | - | Dictionary: String -> String | optional | {} |
net_tool | - | Dictionary: String -> String | optional | {} |
package | The nuget package name. | String | required | |
repo_mapping | A dictionary from local repository name to global repository name. This allows controls over workspace dependency resolution for dependencies of this repository.<p>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 ). |
Dictionary: String -> String | required | |
sha256 | The nuget package sha256 digest. | String | optional | "" |
source | The nuget base url for downloading the package. The final url is in the format {source}/{package}/{version}. | List of strings | optional | ["https://www.nuget.org/api/v2/package"] |
version | The nuget package version. | String | required |
DotnetContextInfo
DotnetContextInfo(label, toolchain, actions, assembly, resx, stdlib_byname, exe_extension, runner, mcs, workspace_name, libVersion, framework, lib, shared, debug, _ctx)
Enriches standard context with additional fields used by rules.
DotnetContextInfo is never returned by a rule, instead you build one using
[dotnet_context(ctx)](api.md#dotnet_context) in the top of any custom skylark rule that wants
to interact with the dotnet rules.
It provides all the information needed to create dotnet actions, and create or interact with the
other dotnet providers.
When you get a DotnetContextInfo from a context it exposes a number of fields and methods.
All methods take the DotnetContextInfo as the only positional argument, all other arguments even if
mandatory must be specified by name, to allow us to re-order and deprecate individual parameters
over time.
FIELDS
Name | Description |
---|---|
label | Rule's label. |
toolchain | Toolchain selected for the rule. |
actions | Copy of ctx.actions (legacy). |
assembly | Toolchain's assembly function. See emit_assembly_core for the function signature. |
resx | Toolchain's resx function. See emit_resx_core for the function signature. |
stdlib_byname | Helper function for locating stdlib by name. |
exe_extension | The suffix to use for all executables in this build mode. Mostly used when generating the output filenames of binary rules. |
runner | An executable to be used by SDK to launch .NET Core programs (dotnet(.exe)). |
mcs | C# compiler. |
workspace_name | Workspace name. |
libVersion | Should not be used. |
framework | Framework version as specified in dotnet/platform/list.bzl. |
lib | Lib folder as declared in context_data. |
shared | Shared folder as declared in context_data. |
debug | True if debug compilation is requested. |
_ctx | Original context. |
DotnetLibraryInfo
DotnetLibraryInfo(label, name, version, ref, deps, result, pdb, runfiles, transitive)
DotnetLibraryInfo is a provider that exposes a compiled assembly along with it's full transitive dependencies.
FIELDS
Name | Description |
---|---|
label | Label of the rule used to create this DotnetLibraryInfo. |
name | Name of the assembly (label.name if not provided). |
version | Version number of the library. Tuple with 5 elements. |
ref | Reference assembly for this DotnetLibraryInfo. Must be set to ctx.attr.ref or result if not provided. See reference assembly. |
deps | The direct dependencies of this library. |
result | The assembly file. |
pdb | The pdb file (with compilation mode dbg). |
runfiles | The depset of direct runfiles (File). |
transitive | The full set of transitive dependencies. This does not include this assembly. List of DotnetLibraryInfo |
DotnetResourceInfo
DotnetResourceInfo(label, name, result, identifier)
Represents a resource file.
FIELDS
Name | Description |
---|---|
label | Label of the rule used to create this provider. |
name | Name of the resource. |
result | The file to be embeded into assembly. |
identifier | Identifier used when loading the resource. |
DotnetResourceListInfo
DotnetResourceListInfo(result)
Represents resource files.
FIELDS
Name | Description |
---|---|
result | Array of DotnetResourceInfo. |
dotnet_context
dotnet_context(ctx, lang)
Converts rule's context to DotnetContextInfo
It uses the attrbutes and the toolchains.
It can only be used in the implementation of a rule that has the dotnet toolchain attached and the dotnet context data as an attribute.
If you are writing a new rule that wants to use the Dotnet toolchain, you need to do a couple of things. First, you have to declare that you want to consume the toolchain on the rule declaration.
my_rule_core = rule(
_my_rule_impl,
attrs = {
...
"dotnet_context_data": attr.label(default = Label("@io_bazel_rules_dotnet//:core_context_data"))
},
toolchains = ["@io_bazel_rules_dotnet//dotnet:toolchain_type_csharp_core"],
)
And then in the rule body, you need to get the toolchain itself and use it's action generators.
def _my_rule_impl(ctx):
dotnet = dotnet_context(ctx)
PARAMETERS
Name | Description | Default Value |
---|---|---|
ctx | The Bazel ctx object for the current rule. | none |
lang | The proramming languge for the current rule. | none |
dotnet_register_toolchains
dotnet_register_toolchains(name)
The macro registers all toolchains.
PARAMETERS
Name | Description | Default Value |
---|---|---|
name | - |
None |
dotnet_repositories
dotnet_repositories()
Fetches remote repositories required before loading other rules_dotnet files.
It fetches basic dependencies. For example: bazel_skylib is loaded.
dotnet_repositories_nugets
dotnet_repositories_nugets()
Loads nugets used by dotnet_rules itself.
emit_assembly_core_csharp
emit_assembly_core_csharp(dotnet, name, srcs, deps, out, resources, executable, defines, unsafe, data, keyfile, subdir, target_framework, nowarn, langversion, version)
See dotnet/toolchains.rst#binary for full documentation. Emits actions for assembly build.
The function is used by all frameworks.
PARAMETERS
Name | Description | Default Value |
---|---|---|
dotnet | DotnetContextInfo provider | none |
name | name of the assembly | none |
srcs | source files (as passed from rules: list of lables/targets) | none |
deps | list of DotnetLibraryInfo. Dependencies as passed from rules) | None |
out | output file name if provided. Otherwise name is used | None |
resources | list of DotnetResourceListInfo provider | None |
executable | bool. True for executable assembly, False otherwise | True |
defines | list of string. Defines to pass to a compiler | None |
unsafe | /unsafe flag (False - default - /unsafe-, otherwise /unsafe+) | False |
data | list of targets (as passed from rules). Additional depdendencies of the target | None |
keyfile | File to be used for signing if provided | None |
subdir | specific subdirectory to be used for target location. Default ./ | "./" |
target_framework | target framework to define via System.Runtime.Versioning.TargetFramework | "" |
nowarn | list of warnings to ignore | None |
langversion | version of the language to use (see https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/configure-language-version) | "latest" |
version | version of the file to be compiled | (0, 0, 0, 0, "") |
emit_assembly_core_fsharp
emit_assembly_core_fsharp(dotnet, name, srcs, deps, out, resources, executable, defines, data, keyfile, subdir, target_framework, nowarn, langversion, version)
See dotnet/toolchains.rst#binary for full documentation. Emits actions for assembly build.
The function is used by all frameworks.
PARAMETERS
Name | Description | Default Value |
---|---|---|
dotnet | DotnetContextInfo provider | none |
name | name of the assembly | none |
srcs | source files (as passed from rules: list of lables/targets) | none |
deps | list of DotnetLibraryInfo. Dependencies as passed from rules) | None |
out | output file name if provided. Otherwise name is used | None |
resources | list of DotnetResourceListInfo provider | None |
executable | bool. True for executable assembly, False otherwise | True |
defines | list of string. Defines to pass to a compiler | None |
data | list of targets (as passed from rules). Additional depdendencies of the target | None |
keyfile | File to be used for signing if provided | None |
subdir | specific subdirectory to be used for target location. Default ./ | "./" |
target_framework | target framework to define via System.Runtime.Versioning.TargetFramework | "" |
nowarn | list of warnings to ignore | None |
langversion | version of the language to use (see https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/configure-language-version) | "latest" |
version | version of the file to be compiled | (0, 0, 0, 0, "") |
emit_resx_core
emit_resx_core(dotnet, name, src, identifier, out, customresgen)
The function adds an action that compiles a single .resx file into .resources file.
Returns DotnetResourceInfo.
PARAMETERS
Name | Description | Default Value |
---|---|---|
dotnet | DotnetContextInfo. | none |
name | name of the file to generate. | "" |
src | The .resx source file that is transformed into .resources file. Only .resx files are permitted. |
None |
identifier | The logical name for the resource; the name that is used to load the resource. The default is the basename of the file name (no subfolder). | None |
out | An alternative name of the output file (if name should not be used). | None |
customresgen | custom resgen program to use. | None |