These are the core dotnet rules, required for basic operation. The intent is that theses rules are sufficient to match the capabilities of the normal dotnet tools.
Contents
- API
- dotnet_library, core_library, net_library
- dotnet_binary, net_binary, core_binary
- dotnet_nunit_test, net_nunit_test, net_nunit3_test, core_xunit_test, net_xunit_test, dotnet_xunit_test
- dotnet_resx, net_resx, core_resx
- net_resx_multi
- net_resource, core_resource
- net_resource_multi
- dotnet_import_library, core_import_library, net_import_library, dotnet_import_binary, core_import_binary, net_import_binary
- dotnet_stdlib, core_stdlib, net_stdlib
This builds a dotnet assembly from a set of source files. The rule generates assebly respectively for Mono, .NET Core and .NET.
Name | Type | Default value |
name |
string | mandatory value |
A unique name for this rule. It must have .dll extension. | ||
deps |
label_list | None |
The direct dependencies of this library. These may be dotnet_library rules or compatible rules with the DotnetLibrary provider. | ||
resources |
label_list | None |
The list of resources to compile with. Usually provided via reference to dotnet_resx or the rules compatible with DotnetResource provider | ||
srcs |
label_list | None |
The list of .cs source files that are compiled to create the assembly.
Only .cs files are permitted |
||
out |
string | "" |
An alternative name of the output file | ||
defines |
string_list | None |
The list of defines passed via /define compiler option | ||
unsafe |
bool | False |
If true passes /unsafe flag to the compiler | ||
keyfile |
label | None |
The key to sign the assembly with. | ||
data |
label_list | None |
The list of additional files to include in the list of runfiles for compile assembly |
dotnet_library(
name = "foo_bar.dll",
srcs = [
"foo.cs",
"bar.cs",
],
deps = [
"//examples/example_lib:MyClass",
"@npgsql//:npgsqllib",
],
visibility = ["//visibility:public"],
)
[core_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/{}:system.private.corelib.dll".format(framework),
"@io_bazel_rules_dotnet//dotnet/stdlib.core/{}:system.runtime.dll".format(framework),
],
) for framework in DOTNET_CORE_FRAMEWORKS]
This builds an executable from a set of source files (respectively for Mono, .NET and .NET Core).
You can run the binary with bazel run
, or you can
build it with bazel build
and run it directly.
Name | Type | Default value |
name |
string | mandatory value |
A unique name for this rule. It must have .exe extension. | ||
deps |
label_list | None |
The direct dependencies of this library. These may be dotnet_library rules or compatible rules with the DotnetLibrary provider. | ||
resources |
label_list | None |
The list of resources to compile with. Usually provided via reference to dotnet_resx or the rules compatible with DotnetResource provider | ||
srcs |
label_list | None |
The list of .cs source files that are compiled to create the assembly.
Only .cs files are permitted |
||
out |
string | "" |
An alternative name of the output file | ||
defines |
string_list | None |
The list of defines passed via /define compiler option | ||
unsafe |
bool | False |
If true passes /unsafe flag to the compiler | ||
keyfile |
label | None |
The key to sign the assembly with. | ||
data |
label_list | None |
The list of additional files to be included as runfiles for the generated executable |
dotnet_binary(
name = "foo_bar.exe",
srcs = [
"foo.cs",
"bar.cs",
],
deps = [
"//examples/example_lib:MyClass",
"@npgsql//:npgsqllib",
],
visibility = ["//visibility:public"],
)
dotnet_nunit_test, net_nunit_test, net_nunit3_test, core_xunit_test, net_xunit_test, dotnet_xunit_test
This builds a set of tests that can be run with bazel test
.
'_nunit_' rules use NUnit2, '_nunit3_' rules use NUnit3, '_xunit_' rules use xunit.
To run all tests in the workspace, and print output on failure, run
bazel test --test_output=errors //...
You can run specific tests by passing the --test_filter=pattern argument to Bazel. You can pass arguments to tests by passing --test_arg=arg arguments to Bazel.
Name | Type | Default value |
name |
string | mandatory value |
A unique name for this rule. It must have .dll extension. | ||
deps |
label_list | None |
The direct dependencies of this library. These may be dotnet_library rules or compatible rules with the DotnetLibrary provider. | ||
resources |
label_list | None |
The list of resources to compile with. Usually provided via reference to dotnet_resx or the rules compatible with DotnetResource provider | ||
srcs |
label_list | None |
The list of .cs source files that are compiled to create the assembly.
Only .cs files are permitted |
||
out |
string | "" |
An alternative name of the output file | ||
defines |
string_list | None |
The list of defines passed via /define compiler option | ||
testlauncher |
Label | <as required by unit framework> |
The list of defines passed via /define compiler option |
dotnet_nunit_test(
name = "MyTest.dll",
srcs = [
"MyTest.cs",
],
deps = [
"//examples/example_lib:MyClass",
"@nunitv2//:netstandard1.0_net",
],
)
This builds a dotnet .resources file from a single .resx file.
.NET Core version uses a custom tool to convert text .resx file to .resources files because no standard tool is provided.
Name | Type | Default value |
name |
string | mandatory value |
A unique name for this rule. | ||
src |
label | mandatory value |
The .resx source file that is transformed into .resources file.
Only .resx files are permitted |
||
identifer |
string | "" |
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). | ||
out |
string | "" |
An alternative name of the output file | ||
simpleresgen |
Label | <as required> |
An alternative tool for generating resources file. It is used by .NET Core to use a custom //tools/simpleresgen tool |
dotnet_resx(
name = "Transform",
src = ":src/ClientUtilities/util/Transform.resx",
)
This builds a dotnet .resources files from multiple .resx file (one for each).
Name | Type | Default value |
name |
string | mandatory value |
A unique name for this rule. | ||
srcs |
label_list | mandatory value |
The source files to be embeded. | ||
identiferBase |
string | "" |
The logical name for given resource is constructred from identiferBase + "." + "directory.repalce('/','.')" + "." + basename + ".resources". The resulting name that is used to load the resource. | ||
fixedIdentifierBase |
string | "" |
The logical name for given resource is constructred from fixedIdentiferBase + "." + "." + basename + ".resources. The resulting name that is used to load the resource. Either identifierBase of fixedIdentifierBase must be specified | ||
simpleresgen |
Label | <as required> |
An alternative tool for generating resources file. It is used by .NET Core to use a custom //tools/simpleresgen tool |
This wraps a resource so it can be embeded into an assembly.
Name | Type | Default value |
name |
string | mandatory value |
A unique name for this rule. | ||
src |
label | mandatory value |
The source to be embeded. | ||
identifer |
string | "" |
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). |
This wraps multiple resource files so they can be embeded into an assembly.
dotnet_import_library, core_import_library, net_import_library, dotnet_import_binary, core_import_binary, net_import_binary
This imports an external dll and transforms it into DotnetLibrary so it can be referenced as dependency by other rules. Often used with dotnet_nuget_new.
Name | Type | Default value |
name |
string | mandatory value |
A unique name for this rule. | ||
deps |
label_list | None |
The direct dependencies of this dll. These may be dotnet_library rules or compatible rules with the DotnetLibrary provider. | ||
src |
label | mandatory value |
The file to be transformed into DotnetLibrary provider |
See dotnet_nuget_new.
This imports a frameworkl dll and transforms it into DotnetLibrary so it can be referenced as dependency by other rules. Uses by //dotnet/stdlib... packages.
Name | Type | Default value |
name |
string | mandatory value |
A unique name for this rule. | ||
deps |
label_list | None |
The direct dependencies of this dll. These may be dotnet_library rules or compatible rules with the DotnetLibrary provider. | ||
data |
label_list | None |
The list of additional files to include in the list of runfiles for compile assembly | ||
dll |
label | "" |
The file to be transformed into DotnetLibrary provider. If empty then name is used. |