dotnet / dotnet/winforms

System.Drawing.Common package omits required System.Formats.Nrbf dependency

Open
#14,890 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
4.9k
Forks
1.1k
Avg merge
1d 13m
Merged PRs (30d)
85

Description

### Description

`System.Drawing.Common` version `11.0.0-preview.7.26381.103` ships `lib/net11.0/System.Private.Windows.Core.dll`, which has a direct assembly reference to `System.Formats.Nrbf, Version=11.0.0.0`. However, the package's `net11.0` nuspec dependency group declares only `Microsoft.Win32.SystemEvents`.

As a result, NuGet restore does not resolve `System.Formats.Nrbf`, and publish does not copy `System.Formats.Nrbf.dll` or include it in the ReadyToRun compiler reference closure. This produces an invalid deployment closure.

### Reproduction

1. Restore or publish an application that references `System.Drawing.Common` `11.0.0-preview.7.26381.103` for `net11.0`.
2. Inspect `project.assets.json`: the `System.Drawing.Common` target entry lists these runtime assets:
- `System.Drawing.Common.dll`
- `System.Private.Windows.Core.dll`
- `System.Private.Windows.GdiPlus.dll`
3. The same entry contains only this dependency:
- `Microsoft.Win32.SystemEvents`
4. `System.Formats.Nrbf` has no resolved node and is not copied to publish output.
5. ReadyToRun/Crossgen2 fails while processing `System.Private.Windows.Core.dll`:

```
Error: Failed to load assembly 'System.Formats.Nrbf'
Internal.TypeSystem.TypeSystemException+FileNotFoundException: Failed to load assembly 'System.Formats.Nrbf'
```

Adding the matching `System.Formats.Nrbf.dll` to the Crossgen2 reference set makes the same compilation complete successfully.

### Source cause

`System.Private.Windows.Core.csproj` references `System.Formats.Nrbf`. `System.Drawing.Common.csproj` packs `System.Private.Windows.Core` using a project reference with `Pack=true` and `PrivateAssets=all`, which embeds the assembly but suppresses its NuGet dependency edge from the resulting `System.Drawing.Common` package.

### Expected behavior

The `net11.0` `System.Drawing.Common` package dependency group should make `System.Formats.Nrbf` available to consumers, so publish and ReadyToRun receive a complete runtime assembly closure.

### Suggested fix

Add a `System.Formats.Nrbf` package dependency to `System.Drawing.Common` for the applicable target frameworks, or otherwise change the package authoring so the dependency of the packed `System.Private.Windows.Core` asset is propagated.

### Additional context

This was observed while investigating https://github.com/dotnet/runtime/issues/132225. The same missing manifest edge appears in `11.0.0-preview.6.26359.118`; .NET 11 preview 7 Crossgen2 exposes it during ReadyToRun compilation.

Contributor guide

Open the contributing guide

Research direction

Start by comparing System.Private.Windows.Core.csproj and System.Drawing.Common.csproj to see how the packed project reference affects dependencies. Restore or publish the net11.0 reproduction and inspect project.assets.json, then run the ReadyToRun/Crossgen2 scenario. Done means the package exposes System.Formats.Nrbf and publish includes it in the runtime and compiler reference closure.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
build-system, desktop
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.