rules_dotnet icon indicating copy to clipboard operation
rules_dotnet copied to clipboard

Run tests with custom DLL locations

Open peakschris opened this issue 5 months ago • 1 comments

Hi there,

We are trying to get csharp_nunit_test working with a particular dotnet library in our product that has some interesting requirements. Let's call it business.dll. At runtime, business.dll looks for a folder named 'plugins' (relative to directory containing business.dll) and loads all DLLs inside that directory.

The source layout is:

src\dotnet\business\BUILD.bazel (business.dll)
src\dotnet\plugin1\BUILD.bazel (plugin1.dll)
src\dotnet\plugin2\BUILD.bazel (plugin2.dll)
src\dotnet\tests\BUILD.bazel(test)

The test is:

csharp_nunit_test(
    srcs = glob(["*.cs"]),
    deps = [
         "//src/dotnet/business",
         "//src/dotnet/plugin1",
         "//src/dotnet/plugin2",
    ],
)

The issue is, at runtime, the plugin DLLs are located in a mirror of their src tree locations instead of in a plugins subdirectory at the same parent directory of business.dll

I have tried using aspect copy_file and copy_to_directory to move the DLLs around and then make the test depend on the copied targets, but this does not seem to work

What is the correct way to get this working? I can't edit the code inside business.dll - should not put bazel logic inside our product.

Thanks!

peakschris avatar Sep 16 '24 12:09 peakschris