tree: 82697e94b548d1c9f46b0573dd57c2d5af8b498b [path history] [tgz]
  1. BUILD
  2. csharp.bzl
  3. README.md
tools/build_defs/dotnet/README.md

C# Rules

Rules

Overview

This is a minimal viable set of C# bindings for building csharp code with mono. It's still pretty rough but it works as a proof of concept that could grow into something more. If windows support ever happens for Bazel then this might become especially valuable.

Setup

Add the following to your WORKSPACE file to add the external repositories:

load("@bazel_tools//tools/build_defs/dotnet:csharp.bzl", "csharp_repositories")

csharp_repositories()

Examples

csharp_library

csharp_library(
    name = "MyLib",
    srcs = ["MyLib.cs"],
    deps = ["//my/dependency:SomeLib"],
)

csharp_binary

csharp_binary(
    name = "MyApp",
    main = "MyApp", # optional name of the main class.
    srcs = ["MyApp.cs"],
    deps = ["//my/dependency:MyLib"],
)

csharp_nunit_test

csharp_nunit_test(
    name = "MyApp",
    srcs = ["MyApp.cs"],
    deps = ["//my/dependency:MyLib"],
)

Things still missing:

  • Handle .resx files correctly.
  • .Net Modules
  • Conditionally building documentation.
  • Pulling Mono in through a mono.WORKSPACE file.

Future nice to haves:

  • Building csproj and sln files for VS and MonoDevelop.
  • Nuget Packaging
  • Windows .NET framwork support

csharp_library

csharp_library(name, srcs, deps, warn=4, csc)

Builds a C# .NET library and its corresponding documentation.

csharp_binary

csharp_binary(name, srcs, deps, main_class, warn=4, csc)

Builds a C# .NET binary.

csharp_nunit_test

csharp_nunit_test(name, srcs, deps, warn=4, csc)

Builds a C# .NET test binary that uses the NUnit unit testing framework.