Open ltcmelo opened 1 year ago
To use the C# rules you need to manually specify the toolchains and platforms, for example:
bazel build --platforms=@io_bazel_rules_dotnet//dotnet/toolchain:linux_amd64_5.0.201 --host_platform=@io_bazel_rules_dotnet//dotnet/toolchain:linux_amd64_5.0.201 //:person_csharp_proto.dll
This is a requirement of rules_dotnet and isn't specific to rules_proto_grpc. It appears that recent rules_dotnet updates remove this mandatory toolchain specification, but that version is not currently used here. You could try overriding your rules_dotnet version in your WORKSPACE prior to loading rules_proto_grpc, but you'd be in untested territory.
Thanks @aaliddell . Indeed, the current rules_dotnet allows you to register the desired dotnet toolchain in the WORKSPACE.
Yet, I tried --platforms
and --host-platform
as you suggest, and while works for a "pure C#" csharp_proto_library
, it doesn't for a C# csharp_proto_library
that depends on a proto_library
.
proto_library(
name = "lib",
srcs = [a.proto],
deps = ["@com_google_protobuf//..."],
visibility = ["//visibility:public"],
)
csharp_proto_library(
name = "other_lib.dll",
protos = [b.proto],
deps = ["//:lib"],
visibility = ["//visibility:public"],
)
bazel build --platforms=@io_bazel_rules_dotnet//dotnet/toolchain:darwin_arm64_6.0.101 --host_platform=@io_bazel_rules_dotnet//dotnet/toolchain:darwin_arm64_6.0.101 //src/dotnet:other_lib.dll
ERROR: /src/dotnet/BUILD.bazel:55:21: in deps attribute of csharp_library rule //src/dotnet:other_lib.dll: '//:lib' does not have mandatory providers: 'DotnetLibraryInfo'. Since this rule was created by the macro 'csharp_proto_library', the error might have been caused by the macro implementation
But I'm not sure whether this error ☝🏽 is related to same issue; would you have an idea?
It appears that I'm supposed to add "//:lib"
to protos
rather than to deps
. Still, the deps
from lib
don't seem to be picked up (automatically), and if I add them to other_lib.dll
, I'm "back" to the missing provider problem.
Issue Description
I'm unable to build a
csharp_proto_library
due to a toolchain-related error. I can reproduce this error with thecsharp_proto_library
example on the master branch.Building a
csharp_proto_compile
works, though.rules_proto_grpc Version
4.3.0 (and master)
Bazel Version
5.3.0
OS
macos (darwin arm64)
dotnet Version
6.0.101, 7.0.101, 7.0.202, and 7.0.203