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

Jos Huybrighs 336 Reputation points
2020-11-09T18:05:42.08+00:00

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 : Dubbele vermelding.  
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.

I think that the error in Release mode is related with the fact that there are 2 UWP 'host' apps in the package. They are required because:

  • Xaml Islands needs a UWP host app (as per Microsoft's guideline Host WinRT XAML controls in desktop apps (XAML Islands)). This app (called UWP.WinUI in my solution) is referenced by the WPF app and instantiated in the WPF's App constructor.
  • The Background Task must be an out-of-process IBackgroundTask that implements the Run method and therefore also requires a UWP host app (called UWP.BGHost in my solution).

The packaging project therefore contains:

  • UWP.BGHost, and
  • The WPF app (which indirectly also brings in UWP.WinUI)

Any idea what is wrong here with Release mode?
Is this a Visual Studio 2019 problem? I am running VS 2019, version 16.7.7.

I made my 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).

Not Monitored
Not Monitored
Tag not monitored by Microsoft.
35,821 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Jos Huybrighs 336 Reputation points
    2020-11-12T17:05:46.437+00:00

    Got an answer back from the Visual Studio team: It turns out that it is not possible to make a WPF desktop app supporting XAML Islands and Background Tasks. See Visual Studio Developer Community - Feedback.

    The reason for wanting to use a Background Task running every 15 minutes, was that this process will automatically be removed when someone would uninstall the app. Other possibilities in WPF, like Windows Schedular and Windows Service, will be impossible with the Windows Store app update/uninstall mechanism.
    I assume that the only other option now is to use a Win32 Background Process (living in the systray) that is launched at startup/logon and continuously sleeps for 15 minutes.

    0 comments No comments