Skip to content

Conversation

@davidollmann
Copy link

@davidollmann davidollmann commented Nov 30, 2025

.NET 10 WPF builds fail due to missing System.Private.Windows.GdiPlus reference. This is a known issue tracked at dotnet/wpf#11246.

Changes

  • Added FixWpfReferences MSBuild target to src/libs/Directory.Build.targets
  • Target runs after ResolveTargetingPackAssets for WPF projects only
  • Automatically adds the missing GdiPlus assembly reference derived from the Core assembly path
<!-- Workaround for https://github.com/dotnet/wpf/issues/11246 -->
<Target Name="FixWpfReferences" AfterTargets="ResolveTargetingPackAssets" Condition="'$(UseWPF)' == 'true'">
    <ItemGroup>
        <SystemPrivateWindowsCoreRef Include="@(Reference)" Condition="'%(Filename)' == 'System.Private.Windows.Core'" />
        <ReferencePath Include="@(SystemPrivateWindowsCoreRef->'%(RootDir)%(Directory)System.Private.Windows.GdiPlus.dll')">
            <AssemblyName>System.Private.Windows.GdiPlus</AssemblyName>
        </ReferencePath>
    </ItemGroup>
</Target>

This is a temporary workaround until the upstream fix is released.

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced build configuration to resolve WPF project assembly reference issues, ensuring more reliable builds for projects using Windows Presentation Foundation.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Nov 30, 2025

Walkthrough

Adds a new MSBuild target FixWpfReferences in src/libs/Directory.Build.targets that runs after ResolveTargetingPackAssets when UseWPF is enabled. The target injects a reference mapping from System.Private.Windows.Core to System.Private.Windows.GdiPlus.dll to resolve a WPF assembly resolution issue during build.

Changes

Cohort / File(s) Summary
WPF Reference Fix
src/libs/Directory.Build.targets
Added FixWpfReferences MSBuild target that creates an item group entry to map System.Private.Windows.Core references to System.Private.Windows.GdiPlus.dll when UseWPF is true

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

  • Single file modification with straightforward MSBuild XML configuration
  • No complex logic or multi-component interactions
  • Localized workaround for a known WPF targeting issue

Poem

🐰 wiggles nose contentedly
When Windows references get all twisted tight,
This rabbit's MSBuild target sets things right,
GdiPlus maps dance in the build system's glow,
WPF troubles melt like spring's sweet snow! ❄️✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly references the upstream issue (dotnet/wpf#11246) that this PR addresses and clearly indicates this is a workaround fix for a WPF build problem.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 27507ca and ed927bf.

📒 Files selected for processing (1)
  • src/libs/Directory.Build.targets (1 hunks)
🧰 Additional context used
🧠 Learnings (10)
📓 Common learnings
Learnt from: CR
Repo: HavenDV/H.NotifyIcon PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-10-23T11:04:44.417Z
Learning: Applies to src/libs/H.NotifyIcon.Shared/**/*.{Wpf,WinUI,WinRT}.cs : Use platform-specific filename suffixes .Wpf.cs, .WinUI.cs, .WinRT.cs for platform-specific implementations in the Shared project
Learnt from: CR
Repo: HavenDV/H.NotifyIcon PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-10-23T11:04:44.417Z
Learning: Applies to src/libs/H.NotifyIcon/** : Use CsWin32-generated P/Invoke for Windows interop (Shell_NotifyIcon and NOTIFYICONDATA) instead of handwritten signatures
Learnt from: CR
Repo: HavenDV/H.NotifyIcon PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-10-23T11:04:44.417Z
Learning: Applies to tests/H.NotifyIcon.IntegrationTests/*.csproj : Maintain test target frameworks for Windows (e.g., net4.8 and net9.0-windows) in the integration test project
Learnt from: CR
Repo: HavenDV/H.NotifyIcon PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-10-23T11:04:44.417Z
Learning: Applies to src/libs/Directory.Build.props : Configure GraphicsLibrary (System.Drawing or SkiaSharp) in src/libs/Directory.Build.props and map to HAS_SYSTEM_DRAWING or HAS_SKIA_SHARP defines
📚 Learning: 2025-10-23T11:04:44.417Z
Learnt from: CR
Repo: HavenDV/H.NotifyIcon PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-10-23T11:04:44.417Z
Learning: Applies to src/libs/{H.GeneratedIcons.System.Drawing,H.GeneratedIcons.SkiaSharp}/**/*.cs : When modifying icon generation, update both System.Drawing and SkiaSharp implementations to maintain feature parity

Applied to files:

  • src/libs/Directory.Build.targets
📚 Learning: 2025-10-23T11:04:44.417Z
Learnt from: CR
Repo: HavenDV/H.NotifyIcon PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-10-23T11:04:44.417Z
Learning: Applies to tests/H.NotifyIcon.IntegrationTests/*.csproj : Maintain test target frameworks for Windows (e.g., net4.8 and net9.0-windows) in the integration test project

Applied to files:

  • src/libs/Directory.Build.targets
📚 Learning: 2025-10-23T11:04:44.417Z
Learnt from: CR
Repo: HavenDV/H.NotifyIcon PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-10-23T11:04:44.417Z
Learning: Applies to src/libs/Directory.Build.props : Configure GraphicsLibrary (System.Drawing or SkiaSharp) in src/libs/Directory.Build.props and map to HAS_SYSTEM_DRAWING or HAS_SKIA_SHARP defines

Applied to files:

  • src/libs/Directory.Build.targets
📚 Learning: 2025-10-23T11:04:44.417Z
Learnt from: CR
Repo: HavenDV/H.NotifyIcon PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-10-23T11:04:44.417Z
Learning: Applies to src/apps/**/*.csproj : Sample apps should target the platform-appropriate frameworks listed (e.g., WPF, WinUI, Console, MAUI) and remain buildable via dotnet run/build commands

Applied to files:

  • src/libs/Directory.Build.targets
📚 Learning: 2025-10-23T11:04:44.417Z
Learnt from: CR
Repo: HavenDV/H.NotifyIcon PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-10-23T11:04:44.417Z
Learning: Applies to src/**/*.cs : Use conditional compilation symbols for platform code: HAS_WPF, HAS_WINUI, HAS_UNO, HAS_MAUI; and for graphics backends: HAS_SYSTEM_DRAWING, HAS_SKIA_SHARP

Applied to files:

  • src/libs/Directory.Build.targets
📚 Learning: 2025-10-23T11:04:44.417Z
Learnt from: CR
Repo: HavenDV/H.NotifyIcon PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-10-23T11:04:44.417Z
Learning: Applies to src/libs/H.NotifyIcon.Shared/**/*.{Wpf,WinUI,WinRT}.cs : Use platform-specific filename suffixes .Wpf.cs, .WinUI.cs, .WinRT.cs for platform-specific implementations in the Shared project

Applied to files:

  • src/libs/Directory.Build.targets
📚 Learning: 2025-10-23T11:04:44.417Z
Learnt from: CR
Repo: HavenDV/H.NotifyIcon PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-10-23T11:04:44.417Z
Learning: Applies to .github/workflows/dotnet.yml : Keep CI running on Windows runners, with steps to install MAUI and Tizen workloads, build all libraries, and publish on tag pushes (v**)

Applied to files:

  • src/libs/Directory.Build.targets
📚 Learning: 2025-10-23T11:04:44.417Z
Learnt from: CR
Repo: HavenDV/H.NotifyIcon PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-10-23T11:04:44.417Z
Learning: Applies to src/libs/**/{*.ios.cs,ios/**/*.cs,*.macos.cs,macos/**/*.cs,*.android.cs,android/**/*.cs,*.windows.cs,windows/**/*.cs,*.net.cs} : Use platform/file exclusion naming patterns (*.ios.cs, *.macos.cs, *.android.cs, *.windows.cs, *.net.cs and corresponding folders) and MSBuild conditions to include them only for matching targets

Applied to files:

  • src/libs/Directory.Build.targets
📚 Learning: 2025-10-23T11:04:44.417Z
Learnt from: CR
Repo: HavenDV/H.NotifyIcon PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-10-23T11:04:44.417Z
Learning: Applies to src/libs/**/*.csproj : Mark libraries as trimming- and AOT-compatible (IsTrimmable true; IsAotCompatible true for net7.0+)

Applied to files:

  • src/libs/Directory.Build.targets

@davidollmann davidollmann closed this by deleting the head repository Nov 30, 2025
HavenDV added a commit that referenced this pull request Dec 1, 2025
@HavenDV
Copy link
Owner

HavenDV commented Dec 1, 2025

Thank you, it works, because PR was closed I can't merge but added it as an separate commit

@davidollmann
Copy link
Author

Thanks! The dotnet team has fixed the issue, and the fix will be in the next servicing update at dotnet/dotnet#3120. Once that’s out, you can remove the workaround.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants