bazel-contrib / bazel-contrib/rules_dotnet

Building .NET Framework libraries fails: error CS0006: Metadata file 'System.EnterpriseServices.Wrapper.dll' could not be found

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

Description

This error seems to happen because of the fix done to solve #405:

https://github.com/bazel-contrib/rules_dotnet/blob/54cf66c0a8d68dd8c5081073da5ac9ce4d762ddd/dotnet/private/rules/nuget/nuget_archive.bzl#L155-L157

This causes the following problem:

```
error CS0006: Metadata file '/tmp/bazel-working-directory/_main/external/_main~targeting_packs_extension~nuget.microsoft.netframework.referenceassemblies.net48.v1.0.3/build/.NETFramework/v4.8/System.EnterpriseServices.Wrapper.dll' could not be found
```

However, naively removing this check fails with:

```
error CS1509: The referenced file '/tmp/bazel-working-directory/_main/external/_main~targeting_packs_extension~nuget.microsoft.netframework.referenceassemblies.net48.v1.0.3/build/.NETFramework/v4.8/System.EnterpriseServices.Wrapper.dll' is not an assembly
```

This is because `System.EnterpriseServices.Wrapper.dll` is not an assembly, but a "module", which is a collection of IL code without an assembly manifest (why this is even a thing is an exercise for the reader). It appears that we need another kind of entry beyond "lib" and "ref" called "module", and this library should be added with `-addmodule:`.

See: https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-options/inputs

Contributor guide

Open the contributing guide

Research direction

Start in dotnet/private/rules/nuget/nuget_archive.bzl at lines 155-157 and compare the existing handling with the C# compiler inputs documentation linked in the issue. Determine how the .NET Framework module should be represented, then verify that builds no longer report either the missing metadata file or the module-not-an-assembly error.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.