Skip to content

Commit 8f01bbd

Browse files
committed
Expose NuGet files as a filegroup
1 parent 11d2307 commit 8f01bbd

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

dotnet/private/rules/nuget/nuget_archive.bzl

+3-2
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ def _nuget_archive_impl(ctx):
364364
for name in names:
365365
ctx.symlink(file_name, name)
366366

367-
files = sorted(_read_dir(ctx, ".").replace(str(ctx.path(".")) + "/", "").splitlines())
367+
all_files = sorted(_read_dir(ctx, ".").replace(str(ctx.path(".")) + "/", "").splitlines())
368368

369369
# The NuGet package format
370370
groups = {
@@ -400,7 +400,7 @@ def _nuget_archive_impl(ctx):
400400
},
401401
}
402402

403-
for file in files:
403+
for file in all_files:
404404
file = _sanitize_path(file)
405405
i = file.find("/")
406406
key = file[:i]
@@ -493,6 +493,7 @@ load("@rules_dotnet//dotnet/private/rules/nuget:nuget_archive.bzl", "tfm_filegro
493493
"filegroup(name = \"data\", srcs = [])",
494494
_create_rid_native_select("native", native) or "filegroup(name = \"native\", srcs = [])",
495495
"filegroup(name = \"content_files\", srcs = [%s])" % ",".join(["\n \"%s\"" % a for a in groups.get("contentFiles")["any"]]),
496+
"filegroup(name = \"files\", srcs = [%s])" % ",".join(["\n \"%s\"" % _sanitize_path(a) for a in all_files]),
496497
"exports_files([\"%s\"])" % nupkg_name,
497498
]))
498499

dotnet/private/rules/nuget/nuget_repo.bzl

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ def _nuget_repo_impl(ctx):
3838
ctx.file("{}/BUILD.bazel".format(name.lower()), r"""package(default_visibility = ["//visibility:public"])
3939
alias(name = "{name}", actual = "//{id}/{version}")
4040
alias(name = "content_files", actual = "@{prefix}.{id}.v{version}//:content_files")
41+
alias(name = "files", actual = "@{prefix}.{id}.v{version}//:files")
4142
""".format(prefix = _GLOBAL_NUGET_PREFIX, name = name.lower(), id = id.lower(), version = version))
4243

4344
_nuget_repo = repository_rule(

dotnet/private/tests/nuget_structure/BUILD.bazel

+8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
2+
load("@bazel_skylib//rules:select_file.bzl", "select_file")
23
load(":analyzers.bzl", "analyzers_structure")
34
load(":resolution.bzl", "resolution_structure")
45
load(":runtimes.bzl", "runtimes_structure")
@@ -51,3 +52,10 @@ bzl_library(
5152
visibility = ["//dotnet:__subpackages__"],
5253
deps = [":common"],
5354
)
55+
56+
select_file(
57+
name = "should_expose_files_as_filegroup",
58+
srcs = "@paket.rules_dotnet_dev_nuget_packages//fsharp.core:files",
59+
subpath = "lib/netstandard2.1/it/FSharp.Core.resources.dll",
60+
visibility = ["//dotnet:__subpackages__"],
61+
)

0 commit comments

Comments
 (0)