rules_csharp 0.1.0Latest published <1h ago
MODULE.bazel
bazel_dep(name = "rules_csharp", version = "0.1.0")
README

Public API for rules_csharp.

csharp_analyzer_import

name

Imports precompiled Roslyn analyzer and source generator assemblies.

ATTRIBUTES

Name Description Type Mandatory Default
name A unique name for this target. Name required
analyzers Precompiled Roslyn analyzer DLL files. List of labels optional []
dlls Precompiled implementation assembly DLL files. List of labels optional []

csharp_analyzer_library

name

Compiles Roslyn analyzer or source generator assemblies.

ATTRIBUTES

Name Description Type Mandatory Default
name A unique name for this target. Name required
deps Direct dependency libraries. List of labels optional []
srcs C# source files to compile. List of labels optional []
resources Embedded resource files mapped to logical names. Dictionary: Label -> String optional {}
analyzers Precompiled Roslyn analyzer DLL files. List of labels optional []
compile_refs Precompiled reference assembly DLL files. List of labels optional []
content Static content files copied to runtime directories. List of labels optional []
copy_to_output Files mapped to destination output paths. Dictionary: Label -> String optional {}
defines Preprocessor symbols to define during compilation. List of strings optional []
dlls Precompiled implementation assembly DLL files. List of labels optional []
exports Dependencies exported to downstream consumers. List of labels optional []
generate_assembly_info Synthesize assembly information attributes. Boolean optional True
implicit_usings Synthesize implicit global usings namespace imports. Boolean optional True
internals_visible_to Friend assembly names for InternalsVisibleTo. List of strings optional []
langversion Target C# language version specification. String optional "latest"
native_libs Unmanaged target platform shared libraries. List of labels optional []
nowarn Compiler diagnostic codes to suppress. List of strings optional []
plugins Roslyn analyzer and generator plugins. List of labels optional []
runtime_dlls Precompiled runtime implementation assembly DLL files. List of labels optional []
sdk Target .NET SDK project flavor. String optional "Microsoft.NET.Sdk"
target_framework Target framework moniker string. String optional ""
target_type Compiler target type output flag. String optional "library"
warn_as_error Treat compiler warnings as errors. Boolean optional False
warning_level Compiler diagnostic severity level. Integer optional 4

csharp_binary

name

Compiles a C# executable and stamps the native application host binary.

ATTRIBUTES

Name Description Type Mandatory Default
name A unique name for this target. Name required
deps Direct dependency libraries. List of labels optional []
srcs C# source files to compile. List of labels optional []
resources Embedded resource files mapped to logical names. Dictionary: Label -> String optional {}
content Static content files copied to runtime directories. List of labels optional []
copy_to_output Files mapped to destination output paths. Dictionary: Label -> String optional {}
defines Preprocessor symbols to define during compilation. List of strings optional []
exports Dependencies exported to downstream consumers. List of labels optional []
generate_assembly_info Synthesize assembly information attributes. Boolean optional True
implicit_usings Synthesize implicit global usings namespace imports. Boolean optional True
internals_visible_to Friend assembly names for InternalsVisibleTo. List of strings optional []
langversion Target C# language version specification. String optional "latest"
nowarn Compiler diagnostic codes to suppress. List of strings optional []
plugins Roslyn analyzer and generator plugins. List of labels optional []
sdk Target .NET SDK project flavor. String optional "Microsoft.NET.Sdk"
target_framework Target framework moniker string. String optional ""
target_type Compiler target type output flag. String optional "exe"
warn_as_error Treat compiler warnings as errors. Boolean optional False
warning_level Compiler diagnostic severity level. Integer optional 4

csharp_grpc_library

name

Compiles Protocol Buffer and gRPC service definitions into a C# assembly library.

ATTRIBUTES

Name Description Type Mandatory Default
name A unique name for this target. Name required
deps Direct dependency libraries. List of labels optional []
srcs C# source files to compile. List of labels optional []
resources Embedded resource files mapped to logical names. Dictionary: Label -> String optional {}
analyzers Precompiled Roslyn analyzer DLL files. List of labels optional []
compile_refs Precompiled reference assembly DLL files. List of labels optional []
content Static content files copied to runtime directories. List of labels optional []
copy_to_output Files mapped to destination output paths. Dictionary: Label -> String optional {}
defines Preprocessor symbols to define during compilation. List of strings optional []
dlls Precompiled implementation assembly DLL files. List of labels optional []
exports Dependencies exported to downstream consumers. List of labels optional []
generate_assembly_info Synthesize assembly information attributes. Boolean optional True
implicit_usings Synthesize implicit global usings namespace imports. Boolean optional True
internals_visible_to Friend assembly names for InternalsVisibleTo. List of strings optional []
langversion Target C# language version specification. String optional "latest"
native_libs Unmanaged target platform shared libraries. List of labels optional []
nowarn Compiler diagnostic codes to suppress. List of strings optional []
plugin The grpc_csharp_plugin executable. Label optional None
plugins Roslyn analyzer and generator plugins. List of labels optional []
proto Target providing ProtoInfo with proto sources. Label optional None
runtime_dlls Precompiled runtime implementation assembly DLL files. List of labels optional []
sdk Target .NET SDK project flavor. String optional "Microsoft.NET.Sdk"
target_framework Target framework moniker string. String optional ""
target_type Compiler target type output flag. String optional "library"
warn_as_error Treat compiler warnings as errors. Boolean optional False
warning_level Compiler diagnostic severity level. Integer optional 4

csharp_import

name

Imports precompiled reference and implementation assemblies.

ATTRIBUTES

Name Description Type Mandatory Default
name A unique name for this target. Name required
deps Direct dependency libraries. List of labels optional []
analyzers Precompiled Roslyn analyzer DLL files. List of labels optional []
compile_refs Precompiled reference assembly DLL files. List of labels optional []
dlls Precompiled implementation assembly DLL files. List of labels optional []
exports Dependencies exported to downstream consumers. List of labels optional []
native_libs Unmanaged target platform shared libraries. List of labels optional []
plugins Roslyn analyzer and generator plugins. List of labels optional []
runtime_dlls Precompiled runtime implementation assembly DLL files. List of labels optional []
target_framework Target framework moniker string. String optional ""

csharp_library

name

Compiles C# source files into reference and implementation assemblies.

ATTRIBUTES

Name Description Type Mandatory Default
name A unique name for this target. Name required
deps Direct dependency libraries. List of labels optional []
srcs C# source files to compile. List of labels optional []
resources Embedded resource files mapped to logical names. Dictionary: Label -> String optional {}
analyzers Precompiled Roslyn analyzer DLL files. List of labels optional []
compile_refs Precompiled reference assembly DLL files. List of labels optional []
content Static content files copied to runtime directories. List of labels optional []
copy_to_output Files mapped to destination output paths. Dictionary: Label -> String optional {}
defines Preprocessor symbols to define during compilation. List of strings optional []
dlls Precompiled implementation assembly DLL files. List of labels optional []
exports Dependencies exported to downstream consumers. List of labels optional []
generate_assembly_info Synthesize assembly information attributes. Boolean optional True
implicit_usings Synthesize implicit global usings namespace imports. Boolean optional True
internals_visible_to Friend assembly names for InternalsVisibleTo. List of strings optional []
langversion Target C# language version specification. String optional "latest"
native_libs Unmanaged target platform shared libraries. List of labels optional []
nowarn Compiler diagnostic codes to suppress. List of strings optional []
plugins Roslyn analyzer and generator plugins. List of labels optional []
runtime_dlls Precompiled runtime implementation assembly DLL files. List of labels optional []
sdk Target .NET SDK project flavor. String optional "Microsoft.NET.Sdk"
target_framework Target framework moniker string. String optional ""
target_type Compiler target type output flag. String optional "library"
warn_as_error Treat compiler warnings as errors. Boolean optional False
warning_level Compiler diagnostic severity level. Integer optional 4

csharp_proto_library

name

Compiles Protocol Buffer definitions into a C# assembly library.

ATTRIBUTES

Name Description Type Mandatory Default
name A unique name for this target. Name required
deps Direct dependency libraries. List of labels optional []
srcs C# source files to compile. List of labels optional []
resources Embedded resource files mapped to logical names. Dictionary: Label -> String optional {}
analyzers Precompiled Roslyn analyzer DLL files. List of labels optional []
compile_refs Precompiled reference assembly DLL files. List of labels optional []
content Static content files copied to runtime directories. List of labels optional []
copy_to_output Files mapped to destination output paths. Dictionary: Label -> String optional {}
defines Preprocessor symbols to define during compilation. List of strings optional []
dlls Precompiled implementation assembly DLL files. List of labels optional []
exports Dependencies exported to downstream consumers. List of labels optional []
generate_assembly_info Synthesize assembly information attributes. Boolean optional True
implicit_usings Synthesize implicit global usings namespace imports. Boolean optional True
internals_visible_to Friend assembly names for InternalsVisibleTo. List of strings optional []
langversion Target C# language version specification. String optional "latest"
native_libs Unmanaged target platform shared libraries. List of labels optional []
nowarn Compiler diagnostic codes to suppress. List of strings optional []
plugins Roslyn analyzer and generator plugins. List of labels optional []
proto Target providing ProtoInfo with proto sources. Label optional None
runtime_dlls Precompiled runtime implementation assembly DLL files. List of labels optional []
sdk Target .NET SDK project flavor. String optional "Microsoft.NET.Sdk"
target_framework Target framework moniker string. String optional ""
target_type Compiler target type output flag. String optional "library"
warn_as_error Treat compiler warnings as errors. Boolean optional False
warning_level Compiler diagnostic severity level. Integer optional 4

csharp_test

name

Compiles and executes a C# test binary under the Bazel test harness.

ATTRIBUTES

Name Description Type Mandatory Default
name A unique name for this target. Name required
deps Direct dependency libraries. List of labels optional []
srcs C# source files to compile. List of labels optional []
data Runtime data files for test execution. List of labels optional []
resources Embedded resource files mapped to logical names. Dictionary: Label -> String optional {}
content Static content files copied to runtime directories. List of labels optional []
copy_to_output Files mapped to destination output paths. Dictionary: Label -> String optional {}
defines Preprocessor symbols to define during compilation. List of strings optional []
env Environment variables for test execution. Dictionary: String -> String optional {}
env_inherit Environment variables inherited from client environment. List of strings optional []
exports Dependencies exported to downstream consumers. List of labels optional []
generate_assembly_info Synthesize assembly information attributes. Boolean optional True
implicit_usings Synthesize implicit global usings namespace imports. Boolean optional True
internals_visible_to Friend assembly names for InternalsVisibleTo. List of strings optional []
langversion Target C# language version specification. String optional "latest"
nowarn Compiler diagnostic codes to suppress. List of strings optional []
plugins Roslyn analyzer and generator plugins. List of labels optional []
sdk Target .NET SDK project flavor. String optional "Microsoft.NET.Sdk"
target_framework Target framework moniker string. String optional ""
target_type Compiler target type output flag. String optional "exe"
test_filter Default test filter expression. String optional ""
warn_as_error Treat compiler warnings as errors. Boolean optional False
warning_level Compiler diagnostic severity level. Integer optional 4

CSharpAnalyzerInfo

analyzers

Propagates Roslyn analyzer and source generator assembly files.

FIELDS

Name Description
analyzers Depset of Roslyn analyzer and generator assembly Files.

CSharpInfo

compile_ref

Propagates compilation references, runtime assemblies, and unmanaged libraries.

FIELDS

Name Description
compile_ref Metadata-only reference assembly File produced by -refout.
pdb Portable program database symbol File.
runtime_dll Implementation assembly File.
target_framework Target framework moniker string (for example net8.0).
transitive_compile_refs Depset of reference assembly Files for compilation.
transitive_native_libs Depset of target platform unmanaged shared libraries.
transitive_runtime_dlls Depset of runtime assembly Files for execution.

CSharpToolchainInfo

aspnetcore_ref_pack

Defines resolved C# SDK tools, packs, and target monikers.

FIELDS

Name Description
aspnetcore_ref_pack Depset of reference assembly Files for Microsoft.AspNetCore.App.
csc_dll Host File for Roslyn compiler assembly.
csc_worker Host executable File for persistent compilation worker.
csc_worker_files Depset of files required by csc_worker.
dotnet_env Dictionary of sealed environment variables for hermetic dotnet execution.
dotnet_muxer Host executable File for dotnet driver.
host_pack Binary template File for target platform application host.
host_rid Host runtime identifier string.
ref_pack Depset of reference assembly Files for target framework.
runtime_pack Depset of runtime assembly Files for target platform.
target_framework Target framework moniker string.
target_rid Target runtime identifier string.
vstest_dll Host File for vstest.console.dll.

About

Rules for building .NET and C# projects with Bazel

@rulescsharp/rules_csharp@rulescsharp

Languages

C#20.3%
Shell9.9%

Maintainers

@rulescsharp

Versions

0.1.02026-10-15