diff --git a/dotnet/merge-assemblies.bzl b/dotnet/merge-assemblies.bzl index 0a829d8ee97a2..cf33392041d1a 100644 --- a/dotnet/merge-assemblies.bzl +++ b/dotnet/merge-assemblies.bzl @@ -1,6 +1,19 @@ -load("@io_bazel_rules_dotnet//dotnet/private:context.bzl", "dotnet_context") +load( + "@io_bazel_rules_dotnet//dotnet/private:context.bzl", + "dotnet_context" +) +load( + "@io_bazel_rules_dotnet//dotnet/private:providers.bzl", + "DotnetLibrary", +) def _merged_assembly_impl(ctx): + dotnet = dotnet_context(ctx) + name = ctx.label.name + + deps = ctx.attr.deps + result = ctx.outputs.out + args = [ "-v4", "-xmldocs", @@ -23,6 +36,28 @@ def _merged_assembly_impl(ctx): outputs = [ctx.outputs.out] ) + data = depset() + + runfiles = depset(direct = [result], transitive = [d[DotnetLibrary].runfiles for d in deps] + [data]) + transitive = depset(direct = deps, transitive = [a[DotnetLibrary].transitive for a in deps]) + + merged_lib = dotnet.new_library( + dotnet = dotnet, + name = name, + deps = deps, + transitive = transitive, + runfiles = runfiles, + result = result, + ) + + return [ + merged_lib, + DefaultInfo( + files = depset([merged_lib.result]), + runfiles = ctx.runfiles(files = [], transitive_files = merged_lib.runfiles), + ), + ] + merged_assembly = rule( implementation = _merged_assembly_impl, attrs = { @@ -30,6 +65,7 @@ merged_assembly = rule( "deps": attr.label_list(), "out": attr.output(mandatory = True), "keyfile": attr.label(allow_single_file = True), + "dotnet_context_data": attr.label(default = Label("@io_bazel_rules_dotnet//:dotnet_context_data")), "merge_tool": attr.label( executable = True, cfg = "host",