Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FrameworkReference Microsoft.WindowsDesktop.App.WindowsForms Incorrectly Includes WindowsFormsIntegration.dll #4789

Open
lonitra opened this issue Nov 21, 2024 · 1 comment · Fixed by #4788

Comments

@lonitra
Copy link
Member

lonitra commented Nov 21, 2024

In .NET 9 we are experiencing issues where when adding <FrameworkReference Include="Microsoft.WindowsDesktop.App.WindowsForms" /> in a winUI project and building, it tries to resolve System.Xaml even though WinForms does not reference Xaml. This is occurring because we had changed WindowsFormsIntegration.dll to have profile with WPF and WindowsForms causing ResolveAssemblyReferences target to include WindowsFormsIntegration.dll in references thus pulling this .dll in even though it is only intended when no profile is specified i.e. UseWindowsForms and UseWPF is true as indicated in https://github.com/dotnet/wpf/blob/bbfc24fd13804a191e20064acd599b0a359092df/packaging/Microsoft.NET.Sdk.WindowsDesktop/targets/Microsoft.NET.Sdk.WindowsDesktop.props#L45-L46. In .NET 8 there was no profile attribute for this dll.

We had made this update as part of #4227 to support runtime pack respecting profiles when publish self contained winforms/wpf app (dotnet/sdk#37088)

Repro project: App11.zip

Repro steps:

  1. unzip and build project via command line with msbuild -p:platform=x64 -bl
  2. Observe failure about trying to resolve System.Xaml
  3. If we look at the binlog, failure occurs under MarkupCompilePass1 target, specifically in CompileXaml task. For that task, if we look at Parameters > ReferenceAssemblies we can see WindowsFormsIntegration.dll
  4. If we search ReferencePath (this is what the ReferenceAssemblies parameter is in the targets file), we can see WindowsFormsIntegration.dll first gets added in ResolveAssemblyReferences target, specifically ResolveAssemblyReference task
  5. In .NET 8 binlog which is included in zip observe WindowsFormsIntegration.dll is not included in ReferencePath

More info: This was originally reported via dotnet/maui#25883 but scenario can be simplified which is what the repro project demonstrates

@lonitra lonitra changed the title Microsoft.WindowsDesktop.App.WindowsForms Tries to Pull in System.Xaml FrameworkReference Microsoft.WindowsDesktop.App.WindowsForms Includes WindowsFormsIntegration.dll Nov 21, 2024
@lonitra lonitra changed the title FrameworkReference Microsoft.WindowsDesktop.App.WindowsForms Includes WindowsFormsIntegration.dll FrameworkReference Microsoft.WindowsDesktop.App.WindowsForms Incorrectly Includes WindowsFormsIntegration.dll Nov 21, 2024
@lonitra lonitra reopened this Nov 22, 2024
@lonitra
Copy link
Member Author

lonitra commented Nov 22, 2024

Reopening for pending port to 9.0

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 a pull request may close this issue.

1 participant