uwpwindows-runtimewin-universal-appwindows-10-universalwinrt-component

Pre-Installed Configuration Task for UWP App not runing


for a LOB App written as a Windows Universal App, I want to register a Background Task when the app is installed without the need to start it. From what I can see, the documentation points me to the Pre-Installed Configuration capability in the Package.appxmanifest and I found this.

However, when using this extension, the background task is not registered nor can I see that it runs anything.

Here is my Pre-Installed Configuration extension in Package.appxmanifest:

<Extension Category="windows.preInstalledConfigTask" EntryPoint="Foo.BackgroundTasks.DefaultRegistrationBackgroundTask" />

To validate that the Task and Entrypoint is set correctly, I registered it using the Update Task capability, increased the App version, deployed it again and the background task is registered and everything works as expected.

Here is my Update Task extension in Package.appxmanifest:

 <Extension Category="windows.updateTask" EntryPoint="Foo.BackgroundTasks.DefaultRegistrationBackgroundTask" />

Is the Pre-Installed Configuration Task somehow limited or needs other configuration? How can I debug this sort of issue? No Breakpoints are hit.

Code of Foo.BackgroundTasks.DefaultRegistrationBackgroundTask:

public sealed class DefaultRegistrationBackgroundTask : IBackgroundTask
{
    private BackgroundTaskDeferral _backgroundTaskDeferral;
    public void Run(IBackgroundTaskInstance taskInstance)
    {

        // Deferral is required if code uses any async call
        _backgroundTaskDeferral = taskInstance.GetDeferral();

        // Location Services
        BackgroundTaskHelper.RegisterBackgroundTask("Foo.BackgroundTasks.LocationBackgroundTask",
            "Foo.LocationBackgroundTask",
            new SystemTrigger(SystemTriggerType.UserPresent, false),
            null);

        // Referal releases
        _backgroundTaskDeferral.Complete();
    }  
}

Solution

  • PreinstalledConfigTask is limited to preinstalled apps, i.e. apps that come with the device from the OEM or Microsoft. It won't get triggered for apps that the user acquires from the Store (or via side-load).