Skip to content

Commit 2b4f860

Browse files
authored
Automatically download correct .Net SDK packs (#426)
This change removes the `targeting_packs` and `runtime_packs` attributes from all rules and now all packs are automatically inferred from the project SDK, target framework and runtime identifier for a target.
1 parent f6c81e4 commit 2b4f860

File tree

176 files changed

+6114
-1468
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

176 files changed

+6114
-1468
lines changed

.bazelci/presubmit.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
---
22
buildifier:
3-
version: 6.3.3
3+
version: 7.1.0
44

55
matrix:
6-
platform: ["windows", "ubuntu1804", "rbe_ubuntu1604", "macos"]
6+
platform: ["windows", "ubuntu1804", "rbe_ubuntu1604", "macos", "macos_arm64", "ubuntu2004_arm64", "windows_arm64"]
77
working_directory: ["", "examples"]
88
strict_deps: ["--@rules_dotnet//dotnet/settings:strict_deps=true", "--@rules_dotnet//dotnet/settings:strict_deps=false"]
9-
flag_combo: [["--enable_bzlmod", "--@rules_dotnet//dotnet/settings:strict_deps=true"], ["--enable_bzlmod", "--@rules_dotnet//dotnet/settings:strict_deps=false"], ["--noenable_bzlmod", "--@rules_dotnet//dotnet/settings:strict_deps=true"], ["--noenable_bzlmod", "--@rules_dotnet//dotnet/settings:strict_deps=false"]]
9+
flag_combo: [["--enable_bzlmod", "--@rules_dotnet//dotnet/settings:strict_deps=true"], ["--enable_bzlmod", "--@rules_dotnet//dotnet/settings:strict_deps=false"]]
1010
e2e_working_directory: ["e2e/net6.0", "e2e/net7.0", "e2e/net8.0"]
1111

1212
tasks:

.bazelversion

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
7.1.0
1+
7.1.1

.devcontainer/Dockerfile

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,17 @@ RUN curl -o $HOME/bin/bazelisk-linux-$TARGETARCH -fsSL https://github.com/bazelb
2222
&& ln -s $HOME/bin/bazelisk $HOME/bin/bazel
2323

2424
# Install bazel-watcher
25-
RUN curl -o $HOME/bin/ibazel_linux_$TARGETARCH -fsSL https://github.com/bazelbuild/bazel-watcher/releases/download/v0.24.0/ibazel_linux_$TARGETARCH \
25+
RUN curl -o $HOME/bin/ibazel_linux_$TARGETARCH -fsSL https://github.com/bazelbuild/bazel-watcher/releases/download/v0.25.1/ibazel_linux_$TARGETARCH \
2626
&& mv $HOME/bin/ibazel_linux_$TARGETARCH $HOME/bin/ibazel \
2727
&& chmod +x $HOME/bin/ibazel
2828

2929
# Install buildifier
30-
RUN curl -o $HOME/bin/buildifier-linux-$TARGETARCH -fsSL https://github.com/bazelbuild/buildtools/releases/download/v6.4.0/buildifier-linux-$TARGETARCH \
30+
RUN curl -o $HOME/bin/buildifier-linux-$TARGETARCH -fsSL https://github.com/bazelbuild/buildtools/releases/download/v7.1.0/buildifier-linux-$TARGETARCH \
3131
&& mv $HOME/bin/buildifier-linux-$TARGETARCH $HOME/bin/buildifier \
3232
&& chmod +x $HOME/bin/buildifier
3333

3434
# Install buildozer
35-
RUN curl -o $HOME/bin/buildozer-linux-$TARGETARCH -fsSL https://github.com/bazelbuild/buildtools/releases/download/v6.4.0/buildozer-linux-$TARGETARCH \
35+
RUN curl -o $HOME/bin/buildozer-linux-$TARGETARCH -fsSL https://github.com/bazelbuild/buildtools/releases/download/v7.1.0/buildozer-linux-$TARGETARCH \
3636
&& mv $HOME/bin/buildozer-linux-$TARGETARCH $HOME/bin/buildozer \
3737
&& chmod +x $HOME/bin/buildozer
3838

.github/workflows/release_prep.sh

+6-30
Original file line numberDiff line numberDiff line change
@@ -16,47 +16,23 @@ git archive --format=tar --prefix=${PREFIX}/ ${TAG} | gzip > $ARCHIVE
1616
SHA=$(shasum -a 256 $ARCHIVE | awk '{print $1}')
1717

1818
cat << EOF
19-
## Using Bzlmod with Bazel 7 (We require Bazel 7 and above)
19+
## Using Bzlmod with Bazel 7 and above
20+
21+
Requirements:
22+
* Bazel 7.0.0 or later
23+
* Bzlmod must be enabled
2024
2125
1. Add to your \`MODULE.bazel\` file:
2226
2327
\`\`\`starlark
2428
bazel_dep(name = "rules_dotnet", version = "${TAG:1}")
2529
2630
dotnet = use_extension("@rules_dotnet//dotnet:extensions.bzl", "dotnet")
27-
dotnet.toolchain(dotnet_version = "8.0.100")
31+
dotnet.toolchain(dotnet_version = "8.0.200")
2832
use_repo(dotnet, "dotnet_toolchains")
2933
3034
register_toolchains("@dotnet_toolchains//:all")
3135
3236
\`\`\`
3337
34-
## Using WORKSPACE
35-
36-
Paste this snippet into your `WORKSPACE.bazel` file:
37-
38-
\`\`\`starlark
39-
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
40-
http_archive(
41-
name = "rules_dotnet",
42-
sha256 = "${SHA}",
43-
strip_prefix = "${PREFIX}",
44-
url = "https://github.com/bazelbuild/rules_dotnet/releases/download/${TAG}/${ARCHIVE}",
45-
)
46-
47-
load(
48-
"@rules_dotnet//dotnet:repositories.bzl",
49-
"dotnet_register_toolchains",
50-
"rules_dotnet_dependencies",
51-
)
52-
53-
rules_dotnet_dependencies()
54-
55-
# Here you can specify the version of the .NET SDK to use.
56-
dotnet_register_toolchains("dotnet", "8.0.100")
57-
58-
load("@rules_dotnet//dotnet:paket.rules_dotnet_nuget_packages.bzl", "rules_dotnet_nuget_packages")
59-
60-
rules_dotnet_nuget_packages()
61-
\`\`\`
6238
EOF

BUILD.bazel

-10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
load("@bazel_gazelle//:def.bzl", "gazelle", "gazelle_binary")
2-
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
32

43
package(default_visibility = ["//visibility:public"])
54

@@ -15,12 +14,3 @@ gazelle(
1514
name = "gazelle",
1615
gazelle = "gazelle_bin",
1716
)
18-
19-
bzl_library(
20-
name = "internal_deps",
21-
srcs = ["internal_deps.bzl"],
22-
deps = [
23-
"@bazel_tools//tools/build_defs/repo:http.bzl",
24-
"@bazel_tools//tools/build_defs/repo:utils.bzl",
25-
],
26-
)

MODULE.bazel

+12-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ module(
88
)
99

1010
dotnet = use_extension("@rules_dotnet//dotnet:extensions.bzl", "dotnet")
11-
dotnet.toolchain(dotnet_version = "8.0.100")
11+
dotnet.toolchain(dotnet_version = "8.0.200")
1212
use_repo(dotnet, "dotnet_toolchains")
1313

1414
register_toolchains("@dotnet_toolchains//:all")
@@ -19,11 +19,20 @@ use_repo(paket2bazel_dependencies_extension, "paket.paket2bazel_dependencies")
1919
rules_dotnet_nuget_packages_extension = use_extension("//dotnet:paket.rules_dotnet_nuget_packages_extension.bzl", "rules_dotnet_nuget_packages_extension")
2020
use_repo(rules_dotnet_nuget_packages_extension, "paket.rules_dotnet_nuget_packages")
2121

22+
targeting_packs_extension = use_extension("//dotnet/private/sdk/targeting_packs:dotnet.targeting_packs_extension.bzl", "targeting_packs_extension")
23+
use_repo(targeting_packs_extension, "dotnet.targeting_packs")
24+
25+
runtime_packs_extension = use_extension("//dotnet/private/sdk/runtime_packs:dotnet.runtime_packs_extension.bzl", "runtime_packs_extension")
26+
use_repo(runtime_packs_extension, "dotnet.runtime_packs")
27+
28+
apphost_packs_extension = use_extension("//dotnet/private/sdk/apphost_packs:dotnet.apphost_packs_extension.bzl", "apphost_packs_extension")
29+
use_repo(apphost_packs_extension, "dotnet.apphost_packs")
30+
2231
bazel_dep(name = "bazel_skylib", version = "1.4.2")
23-
bazel_dep(name = "platforms", version = "0.0.7")
32+
bazel_dep(name = "platforms", version = "0.0.9")
2433

2534
# Dev dependencies
26-
bazel_dep(name = "rules_pkg", version = "0.9.1", dev_dependency = True)
35+
bazel_dep(name = "rules_pkg", version = "0.10.1", dev_dependency = True)
2736
bazel_dep(name = "gazelle", version = "0.33.0", dev_dependency = True, repo_name = "bazel_gazelle")
2837
bazel_dep(name = "bazel_skylib_gazelle_plugin", version = "1.4.2", dev_dependency = True)
2938
bazel_dep(name = "rules_cc", version = "0.0.9", dev_dependency = True)

WORKSPACE

-70
Original file line numberDiff line numberDiff line change
@@ -1,71 +1 @@
11
workspace(name = "rules_dotnet")
2-
3-
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
4-
load(":internal_deps.bzl", "rules_dotnet_internal_deps")
5-
6-
# Fetch deps needed only locally for development
7-
rules_dotnet_internal_deps()
8-
9-
# Fetch dependencies needed by end-users
10-
load(
11-
"//dotnet:repositories.bzl",
12-
"dotnet_register_toolchains",
13-
"rules_dotnet_dependencies",
14-
)
15-
16-
rules_dotnet_dependencies()
17-
18-
dotnet_register_toolchains("dotnet", "8.0.100")
19-
20-
# Fetch NuGet packages needed by end-users
21-
load("//dotnet:paket.rules_dotnet_nuget_packages.bzl", "rules_dotnet_nuget_packages")
22-
23-
rules_dotnet_nuget_packages()
24-
25-
load("//dotnet:paket.paket2bazel_dependencies.bzl", "paket2bazel_dependencies")
26-
27-
paket2bazel_dependencies()
28-
29-
# Fetch NuGet packages needed for our tests
30-
load("//dotnet:paket.rules_dotnet_dev_nuget_packages.bzl", "rules_dotnet_dev_nuget_packages")
31-
32-
rules_dotnet_dev_nuget_packages()
33-
34-
# For running our own unit tests
35-
load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")
36-
37-
bazel_skylib_workspace()
38-
39-
load("@rules_pkg//:deps.bzl", "rules_pkg_dependencies")
40-
41-
rules_pkg_dependencies()
42-
43-
load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")
44-
45-
############################################
46-
# Gazelle, for generating bzl_library targets
47-
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
48-
49-
go_rules_dependencies()
50-
51-
go_register_toolchains(version = "1.20.5")
52-
53-
gazelle_dependencies()
54-
55-
# Used for Bazel CI
56-
http_archive(
57-
name = "bazelci_rules",
58-
sha256 = "eca21884e6f66a88c358e580fd67a6b148d30ab57b1680f62a96c00f9bc6a07e",
59-
strip_prefix = "bazelci_rules-1.0.0",
60-
url = "https://github.com/bazelbuild/continuous-integration/releases/download/rules-1.0.0/bazelci_rules-1.0.0.tar.gz",
61-
)
62-
63-
load("@bazelci_rules//:rbe_repo.bzl", "rbe_preconfig")
64-
65-
# Creates a default toolchain config for RBE.
66-
# Use this as is if you are using the rbe_ubuntu16_04 container,
67-
# otherwise refer to RBE docs.
68-
rbe_preconfig(
69-
name = "buildkite_config",
70-
toolchain = "ubuntu1804-bazel-java11",
71-
)

docs/README.md

+1-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/csharp_binary.md

+4-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)