bazel-contrib / bazel-contrib/rules_dotnet

Run tests with custom DLL locations

Open
#450 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Starlark
Stars
209
Forks
98
Avg merge
3h 59m
Merged PRs (30d)
14

Description

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!

Contributor guide

Open the contributing guide

Research direction

Start by reading the src/dotnet/business/BUILD.bazel, src/dotnet/plugin1/BUILD.bazel, src/dotnet/plugin2/BUILD.bazel, and src/dotnet/tests/BUILD.bazel files, along with the csharp_nunit_test entry point. Reproduce the test with business.dll and both plugins, then verify that runtime resolution places the plugin DLLs in a plugins subdirectory beside business.dll and that the test passes.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
build-system, testing
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.