App Crashes on Launch as Beta (Works Side-loaded)

I came across this issue with a test app which had been working fine either when debugging or deploying the XAP file directly. Then I set up a beta and when installed the app just starts and immediately stops. Since it took me some time to try a few things to identify the issue I thought I’d share it here. The problem was that the app uses a background task. The Agent is added to the solution using the project template, added as a reference in the application project and the code to schedule the task is set up in App.xaml.cs. As I discovered I had neglected to add in the ExtendedTask element to my WMAppManifest.xml. Presumably as the .dll was not specified here it was not being correctly signed as part of the store ingestion and so the published beta app was in a broken state. Here is what the entry should look like. Remember you can’t set this through the GUI you have to view the raw XML file and make edits there:-

      <DefaultTask Name="_default" NavigationPage="MainPage.xaml">
      <ExtendedTask Name="BackgroundTask">
        <BackgroundServiceAgent Specifier="ScheduledTaskAgent" Name="MyAgent" Source="MyAgent" Type="MyAgent.ScheduledAgent"/>