CommunityToolkit / Microsoft.Toolkit.Win32

ARCHIVE - This repository contained XAML Islands wrapper controls and tooling for XAML Islands with WinUI 2, see readme for more info about XAML Islands with WinUI 3 and the WindowsAppSDK.
https://aka.ms/windowsappsdk
Other
383 stars 89 forks source link

Can't make release build with a WPF desktop app that is using Xaml Islands and Background Tasks #295

Open JosHuybrighs opened 3 years ago

JosHuybrighs commented 3 years ago

I am setting up a desktop bridge project with a WPF desktop app that uses Xaml Islands and Background Tasks. When building in Release mode the ‘package’ project generates the error: “Conflicting values for resource ‘Files/App.xbf’”.

The exact error messages are:

 5>Generating native code
 5>Generating fixups for native code
 5>error PRI175 : 0x80073b0f - Processing Resources failed with error : Duplicate Entry.
 5>GENERATEPROJECTPRIFILE : error PRI277: 0xdef00532 - Conflicting values for resource 'Files/App.xbf'
 5>Done building project "WPFXamlIslandsWithBGTask.Package.wapproj" -- FAILED.

Building in Debug mode gives no error and the app also runs successfully: the xaml user control is correctly displayed and the background task (a 15 minute Timer task) successfully fires.

It looks like the error in Release mode is related with the fact that there are 2 UWP ‘host’ apps in the package. They are required because:

The packaging project therefore contains:

The error has been reported to the Visual Studio team, and the response was:

Unfortunately due to the requirement that UWP projects use .NET Native, this requires us to put UWP components into the root of the package instead of separate folders for each project which would avoid name collisions. As you have found out, all UWP host projects have a App.xaml and therefore App.xbf which will always collide making it so that the packaging project can only have 1 UWP host project.

If this is correct then this not only has to be mentioned in the Xaml Islands documentation, but one should wonder whether Xaml Islands is a good concept for building WPF desktop apps. The reason why one would choose WPF (and not UWP) is that typically those apps want to do more than what UWP allows us to do, like being able to run background processes for things like periodically scheduling some actions, detecting USB peripheral insertion, etc.

For anyone interested in trying this, I made a full solution (which is really simple at this point in time) available on OneDrive (see WPFXamlIslandsWithBGTask.zip. It should give the above error when building in Release mode (x64 and x86).

ghost commented 3 years ago

Hello JosHuybrighs, thank you for opening an issue with us!

I have automatically added a "needs triage" label to help get things started. Our team will analyze and investigate the issue, and escalate it to the relevant team if possible. Other community members may also look into the issue and provide feedback 🙌

michael-hawker commented 3 years ago

@marb2000 any guidance here?

atiyka commented 3 years ago

Hi @JosHuybrighs couple of weeks ago I also started to add Xaml Islands components to my WPF project and I have more than two UWP ‘host’ components. As I read your problem, immediately tried to build in release mode, and I could. I could also run the bridge application. Can you please update your project in OneDrive, I'd like to check, but it says, the item is no longer exists.

JosHuybrighs commented 3 years ago

Hi,

I created a new link to the solution file: WPFXamlIslandsWithBGTask.ziphttps://1drv.ms/u/s!AugQvFxkydtIhq1NnnoolVdYmhrggQ?e=jkoebE

Thanks for the help.