APIReference.md

October 27, 2020 ยท View on GitHub

csharp_binary

csharp_binary(name, additionalfiles, analyzers, defines, deps, include_stdrefs, keyfile,
              langversion, out, resources, runtimeconfig_template, srcs, target_frameworks, winexe)

Compile a C# exe

ATTRIBUTES

NameDescriptionTypeMandatoryDefault
nameA unique name for this target.Namerequired
additionalfilesExtra files to configure analyzers.List of labelsoptional[]
analyzersA list of analyzer references.List of labelsoptional[]
definesA list of preprocessor directive symbols to define.List of stringsoptional[]
depsOther C# libraries, binaries, or imported DLLsList of labelsoptional[]
include_stdrefsWhether to reference @net//:StandardReferences (the default set of references that MSBuild adds to every project).BooleanoptionalTrue
keyfileThe key file used to sign the assembly with a strong name.LabeloptionalNone
langversionThe version string for the C# language.Stringoptional""
outFile name, without extension, of the built assembly.Stringoptional""
resourcesA list of files to embed in the DLL as resources.List of labelsoptional[]
runtimeconfig_templateA template file to use for generating runtimeconfig.jsonLabeloptional:runtimeconfig.json.tpl
srcsC# source files.List of labelsoptional[]
target_frameworksA list of target framework monikers to buildSee https://docs.microsoft.com/en-us/dotnet/standard/frameworksList of stringsoptional[]
winexeIf true, output a winexe-style executable, otherwiseoutput a console-style executable.BooleanoptionalFalse

csharp_library

csharp_library(name, additionalfiles, analyzers, defines, deps, include_stdrefs, keyfile,
               langversion, out, resources, srcs, target_frameworks)

Compile a C# DLL

ATTRIBUTES

NameDescriptionTypeMandatoryDefault
nameA unique name for this target.Namerequired
additionalfilesExtra files to configure analyzers.List of labelsoptional[]
analyzersA list of analyzer references.List of labelsoptional[]
definesA list of preprocessor directive symbols to define.List of stringsoptional[]
depsOther C# libraries, binaries, or imported DLLsList of labelsoptional[]
include_stdrefsWhether to reference @net//:StandardReferences (the default set of references that MSBuild adds to every project).BooleanoptionalTrue
keyfileThe key file used to sign the assembly with a strong name.LabeloptionalNone
langversionThe version string for the C# language.Stringoptional""
outFile name, without extension, of the built assembly.Stringoptional""
resourcesA list of files to embed in the DLL as resources.List of labelsoptional[]
srcsC# source files.List of labelsoptional[]
target_frameworksA list of target framework monikers to buildSee https://docs.microsoft.com/en-us/dotnet/standard/frameworksList of stringsoptional[]

csharp_library_set

csharp_library_set(name, deps, target_framework)

Defines a set of C# libraries to be depended on together

ATTRIBUTES

NameDescriptionTypeMandatoryDefault
nameA unique name for this target.Namerequired
depsThe set of librariesList of labelsoptional[]
target_frameworkThe target framework for this set of librariesStringrequired

csharp_nunit_test

csharp_nunit_test(name, additionalfiles, analyzers, defines, deps, include_stdrefs, keyfile,
                  langversion, out, resources, srcs, target_frameworks)

Compile a C# exe

ATTRIBUTES

NameDescriptionTypeMandatoryDefault
nameA unique name for this target.Namerequired
additionalfilesExtra files to configure analyzers.List of labelsoptional[]
analyzersA list of analyzer references.List of labelsoptional[]
definesA list of preprocessor directive symbols to define.List of stringsoptional[]
depsOther C# libraries, binaries, or imported DLLsList of labelsoptional[]
include_stdrefsWhether to reference @net//:StandardReferences (the default set of references that MSBuild adds to every project).BooleanoptionalTrue
keyfileThe key file used to sign the assembly with a strong name.LabeloptionalNone
langversionThe version string for the C# language.Stringoptional""
outFile name, without extension, of the built assembly.Stringoptional""
resourcesA list of files to embed in the DLL as resources.List of labelsoptional[]
srcsC# source files.List of labelsoptional[]
target_frameworksA list of target framework monikers to buildSee https://docs.microsoft.com/en-us/dotnet/standard/frameworksList of stringsoptional[]

import_library

import_library(name, deps, dll, native_dlls, pdb, refdll, target_framework)

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

ATTRIBUTES

NameDescriptionTypeMandatoryDefault
nameA unique name for this target.Namerequired
depsother DLLs that this DLL depends on.List of labelsoptional[]
dllA static DLLLabeloptionalNone
native_dllsA list of native dlls, which while unreferenced, are required for running and compilingList of labelsoptional[]
pdbDebug symbols for the dllLabeloptionalNone
refdllA metadata-only DLL, suitable for compiling against but not runningLabeloptionalNone
target_frameworkThe target framework for this DLLStringrequired

import_multiframework_library

import_multiframework_library(name, net11, net20, net30, net35, net40, net403, net45, net451,
                              net452, net46, net461, net462, net47, net471, net472, net48,
                              netcoreapp1_0, netcoreapp1_1, netcoreapp2_0, netcoreapp2_1,
                              netcoreapp2_2, netcoreapp3_0, netcoreapp3_1,  netstandard, netstandard1_0,
                              netstandard1_1, netstandard1_2, netstandard1_3, netstandard1_4,
                              netstandard1_5, netstandard1_6, netstandard2_0, netstandard2_1)

Aggregate import_library targets for specific target-frameworks into one target

ATTRIBUTES

NameDescriptionTypeMandatoryDefault
nameA unique name for this target.Namerequired
net11The net11 version of this libraryLabeloptionalNone
net20The net20 version of this libraryLabeloptionalNone
net30The net30 version of this libraryLabeloptionalNone
net35The net35 version of this libraryLabeloptionalNone
net40The net40 version of this libraryLabeloptionalNone
net403The net403 version of this libraryLabeloptionalNone
net45The net45 version of this libraryLabeloptionalNone
net451The net451 version of this libraryLabeloptionalNone
net452The net452 version of this libraryLabeloptionalNone
net46The net46 version of this libraryLabeloptionalNone
net461The net461 version of this libraryLabeloptionalNone
net462The net462 version of this libraryLabeloptionalNone
net47The net47 version of this libraryLabeloptionalNone
net471The net471 version of this libraryLabeloptionalNone
net472The net472 version of this libraryLabeloptionalNone
net48The net48 version of this libraryLabeloptionalNone
netcoreapp1_0The netcoreapp1.0 version of this libraryLabeloptionalNone
netcoreapp1_1The netcoreapp1.1 version of this libraryLabeloptionalNone
netcoreapp2_0The netcoreapp2.0 version of this libraryLabeloptionalNone
netcoreapp2_1The netcoreapp2.1 version of this libraryLabeloptionalNone
netcoreapp2_2The netcoreapp2.2 version of this libraryLabeloptionalNone
netcoreapp3_0The netcoreapp3.0 version of this libraryLabeloptionalNone
netcoreapp3_1The netcoreapp3.1 version of this libraryLabeloptionalNone
netstandardThe netstandard version of this libraryLabeloptionalNone
netstandard1_0The netstandard1.0 version of this libraryLabeloptionalNone
netstandard1_1The netstandard1.1 version of this libraryLabeloptionalNone
netstandard1_2The netstandard1.2 version of this libraryLabeloptionalNone
netstandard1_3The netstandard1.3 version of this libraryLabeloptionalNone
netstandard1_4The netstandard1.4 version of this libraryLabeloptionalNone
netstandard1_5The netstandard1.5 version of this libraryLabeloptionalNone
netstandard1_6The netstandard1.6 version of this libraryLabeloptionalNone
netstandard2_0The netstandard2.0 version of this libraryLabeloptionalNone
netstandard2_1The netstandard2.1 version of this libraryLabeloptionalNone

csharp_register_toolchains

csharp_register_toolchains()

PARAMETERS

csharp_repositories

csharp_repositories()

Download dependencies of csharp rules.

PARAMETERS

import_nuget_package

import_nuget_package(name, dir, file, build_file, build_file_content, sha256)

Import a vendored NuGet package from either a directory or .nupkg file.

Rather than downloading the package over HTTP from a package source, an extracted package directory or a .nupkg file can be used. These may be checked into your repository within your workspace, or somewhere else on your disk.

Exactly one of either the dir or file arguments must be provided. They can either be a relative path in the workspace, or an absolute path. Note that paths on Windows use forward slashes.

At most one of build_file or build_file_content may be provided. If neither are, a default BUILD file will be used that makes a "best effort" to wire up the package. See docs/UsingNuGetPacakges.md for more info.

PARAMETERS

NameDescriptionDefault Value
nameA unique name for the package's workspace.none
dirA directory containing an extracted package.None
fileA path to a nupkg fileNone
build_fileThe path to a BUILD file to use for the package.None
build_file_contentA string containing the contents of a BUILD file.None
sha256The SHA256 of the package.

This is only used when importing nupkg files. You may or may not find it useful, but it will silence a DEBUG message from Bazel regarding reproducibility.
None

nuget_package

nuget_package(name, package, version, nuget_sources, sha256, build_file, build_file_content)

Download an external NuGet package.

At most one of build_file or build_file_content may be provided. If neither are, a default BUILD file will be used that makes a "best effort" to wire up the package. See docs/UsingNuGetPacakges.md for more info.

PARAMETERS

NameDescriptionDefault Value
nameA unique name for the package's workspace.none
packageThe name of the package in the NuGet feed.none
versionThe version of the package in the NuGet feed.none
nuget_sourcesA list of nuget package sources. Defaults to nuget.org.None
sha256The SHA256 of the package.None
build_fileThe path to a BUILD file to use for the package.None
build_file_contentA string containing the contents of a BUILD file.None