Skip to content

System.Drawing.Common pruning leads to a compile error when only UseWPF is specified #51173

@nkolev92

Description

@nkolev92

Describe the bug

This bug was originally raised in NuGet/Home#11786 (comment).

The gist is that there's a net9.0-windows project with UseWPF in the project file referencing a single package.
That project has 3 vulnerabilities, one of which is System.Drawing.Common, so the customer enabled pruning.

Enabling pruning leads to the System.Drawing.Common which is expected, but unfortunately that then leads to a compile error.

To Reproduce

Check out https://github.com/omghb/NuGetIssue11786.

Restore and build

Error (if any)

Error:

The type name 'Bitmap' could not be found in the namespace 'System.Drawing'. This type has been forwarded to assembly 'System.Drawing.Common, Version=0.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' Consider adding a reference to that assembly.

Unfortunately it seems like while the WindowsForms data provides System.Drawing.Common as package that can be pruned, but it doesn't actually provide the types for System.Drawing.Common.

At least that's my analysis.

Further technical details

.NET 10 SDK: 10.0.100-rc.1.25451.107

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions