//gazelle/dotnet
Gazelle is a build file generator for Bazel projects.
This package implements a Gazelle extension for managing the rules defined by rules_msbuild. All msbuild rules in the
rules_msbuild repository are generated by gazelle-dotnet.
All updates to rules_msbuild will be reflected in gazelle-dotnet, and rules_msbuild will assume that
you manage your build files with gazelle-dotnet.
Quickstart
Use a precompiled gazelle-dotnet binary
This method hs no WORKSPACE dependencies other than @rules_msbuild.
Add the following to the BUILD.bazel file at the root of your repository:
load("@rules_msbuild//tools/gazelle.bzl", "gazelle")
gazelle(
name = "gazelle",
args = [
"--srcs_mode=explicit", # explicitly list src files instead of globbing
"--deps_macro=deps:nuget.bzl%nuget_deps", # store nuget dependencies in deps/nuget.bzl
],
)
To generate or update build files run: bazel run //:gazelle
.
This will run a precompiled executable for your platform and generate build rules for proto_library
and rules_msbuild targets. (windows-amd64, darwin-amd64 or linux-amd64 are supported).
This binary is also packaged with SamHowes.Bzl
and can be run with bzl gazelle
.
Use gazelle-dotnet alongside your existing gazelle rule
If you'd like to compile gazelle from source or use gazelle-dotnet alongside your existing gazelle
languages:
Add the appropriate WORKSPACE dependencies for rules_go and bazel-gazelle as per the rules_go docs, then add gazelle-dotnet as a
language:
load("@bazel_gazelle//:def.bzl", "DEFAULT_LANGUAGES", "gazelle", "gazelle_binary")
gazelle_binary(
name = "gazelle",
languages = DEFAULT_LANGUAGES + [ # order matters!
"@rules_msbuild//gazelle/dotnet",
],
)
Note: if you are running on windows, be aware of issue #93 if you run into issues with the standard dependencies from the rules_go docs.
Generated rules
The primary rules (msbuild_binary, msbuild_library, and msbuild_test) are all
generated from gazelle-dotnet, as well as NuGet dependency management via nuget_fetch
.