csharp_binary
A csharp_binary() rule builds a .Net executable from the supplied set of C# source files and dependencies by invoking csc. The executable and the assemblies of the targets it depends on are copied to one directory, where the executable finds each of them in a .dll or .exe file named after the assembly: the assembly of a prebuilt_dotnet_library has to be named that way. A prebuilt_dotnet_library cannot name the assemblies it needs, so the executable has to depend on those too.
Function Signature
def csharp_binary(
*,
name: str,
default_target_platform: None | str = None,
target_compatible_with: list[str] = [],
compatible_with: list[str] = [],
exec_compatible_with: list[str] = [],
visibility: list[str | target_name_glob] = [],
within_view: list[str | target_name_glob] = ["PUBLIC"],
metadata: OpaqueMetadata = {},
tests: list[str] = [],
modifiers: OpaqueMetadata = [],
compiler_flags: list[str] = [],
contacts: list[str] = [],
deps: list[str] = [],
exe_name: str = "",
framework_ver: str,
labels: list[str] = [],
licenses: list[str] = [],
srcs: list[str] = [],
) -> None
Parameters
-
name: (required)name of the target
-
default_target_platform: (defaults to:None)specifies the default target platform, used when no platforms are specified on the command line
-
target_compatible_with: (defaults to:[])a list of constraints that are required to be satisfied for this target to be compatible with a configuration
-
compatible_with: (defaults to:[])a list of constraints that are required to be satisfied for this target to be compatible with a configuration
-
exec_compatible_with: (defaults to:[])a list of constraints that are required to be satisfied for this target to be compatible with an execution platform
-
visibility: (defaults to:[])a list of visibility patterns restricting what targets can depend on this one
-
within_view: (defaults to:["PUBLIC"])a list of visibility patterns restricting what this target can depend on
-
metadata: (defaults to:{})a key-value map of metadata associated with this target
-
tests: (defaults to:[])a list of targets that provide tests for this one
-
modifiers: (defaults to:[])an array of modifiers associated with this target
-
compiler_flags: (defaults to:[])The set of additional compiler flags, in which macros such as
$(location //some:target)are expanded. A/targetamong them has no effect: the rule passes its own after them. -
contacts: (defaults to:[])A list of organizational contacts for this rule. These could be individuals who you would contact in the event of a failure or other issue with the rule.
contacts = [ 'Joe Sixpack', 'Erika Mustermann' ] -
deps: (defaults to:[])The set of targets or system-provided assemblies this target depends on. Any values that are targets must be either csharp_library or
prebuilt_dotnet_libraryinstances. -
exe_name: (defaults to:"")The output name of the executable. This allows you to specify the name of the executable exactly. When this is not set, the executable will be named after the short name of the target, with the extension
.exe. -
framework_ver: (required)The version of the .Net framework that the assembly targets. This is one of net35, net40, net45, net46.
-
labels: (defaults to:[])Set of arbitrary strings which allow you to annotate a build rule with tags that can be searched for over an entire dependency tree using
buck query(). -
licenses: (defaults to:[])Set of license files for this library. To get the list of license files for a given build rule and all of its dependencies, you can use buck query
-
srcs: (defaults to:[])The set of C# source files to be compiled, and assembled by this rule. Each element may be either a literal string (representing the path within this package), or a target.
Examples
python
csharp_binary(
name = 'simple',
exe_name = 'Cake.exe',
framework_ver = 'net46',
srcs = [
'Hello.cs',
],
deps=[
':other',
'mscorlib.dll',
'System.dll',
],
)
prebuilt_dotnet_library(
name = 'other',
assembly = 'other.dll',
)