Git Product home page Git Product logo

rules_dotnet's Introduction

.Net Rules for Bazel

Gitpod ready-to-code

Build status

Bazel CI
Build status

Documentation

The full documentation is here.

Overview

This is a minimal viable set of C#/F# bindings for building C#/F# code with Core

Caveats

Bazel creates long paths. Therefore it is recommended to increase the length limit using newer version of Windows. Please see here.

However, some Windows programs do not handle long path names. Most notably - Microsoft C compiler (cl.exe). Therefore TMP env variable should be set to something short (like X:\ or c:\TEMP).

Bazel and dotnet_rules rely on symbolic linking. On Windows it, typically, requires elevated permissions. However, newer versions of Windows have a workaround.

Setup

  • The rules take full advantage of Bazel platforms and toolchains

  • When building any project the platform has to be specified. For example:

        bazel build --host_platform=@io_bazel_rules_dotnet//dotnet/toolchain:linux_amd64_6.0.101 --platforms=@io_bazel_rules_dotnet//dotnet/toolchain:linux_amd64_6.0.101 //...
  • The platform specification has the form of //dotnet/toolchain:. The available values are listed in dotnet/platform/list.bzl in variables DOTNET_OS_ARCH and DOTNET_CORE_FRAMEWORKS. Typically the --host_platform and --platforms values are set in .bazelrc file.

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

    # A newer version should be fine
    load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
    git_repository(
        name = "io_bazel_rules_dotnet",
        remote = "https://github.com/bazelbuild/rules_dotnet",
        branch = "master",
    )
    
    load("@io_bazel_rules_dotnet//dotnet:deps.bzl", "dotnet_repositories")
    dotnet_repositories()
    
    load(
        "@io_bazel_rules_dotnet//dotnet:defs.bzl",
        "dotnet_register_toolchains",
        "dotnet_repositories_nugets",
    )
    
    dotnet_register_toolchains()
    dotnet_repositories_nugets()

    The dotnet_repositories rule fetches external dependencies which have to be defined before loading any other file of rules_dotnet. dotnet_repositories_nugets loads nuget packages required by test rules.

    The dotnet_register_toolchains configures toolchains.

  • Add a file named BUILD.bazel in the root directory of your project. In general, you need one of these files in every directory with dotnet code.

    At the top of the file used rules should be imported:

      load("@io_bazel_rules_dotnet//dotnet:defs.bzl", "csharp_library", "csharp_binary")
  • See nuget2bazel for using nuget dependencies.

  • See examples folder for examples.

rules_dotnet's People

Contributors

tomaszstrejczek avatar damirdev avatar purkhusid avatar zaphar avatar pcj avatar j3parker avatar strejczek avatar kchodorow avatar damienmg avatar davidzchen avatar dependabot[bot] avatar nmalsang avatar philwo avatar iainmerrick avatar ilya-klyuchnikov avatar jimevans avatar samhowes avatar thelgevold avatar tomdegoede avatar katre avatar vladmos avatar renovate-bot avatar plule-ansys avatar mtsgrd avatar laurentlb avatar jart avatar joey9801 avatar j-swift avatar jagobagascon avatar hsyed-dojo avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.