Can’t download apps on Microsoft Store with error 0x80080204

Can’t download apps on Microsoft Store with error 0x80080204

TL;DR: Fall creator update SDK cause major issues if your application uses an background audio agent.

There is nothing more frustrating than receive a lot of bad reviews, not because your app crashes or is buggy but because users are not able to update or download your app because of Microsoft…

Here is my last (bad) experience with the Microsoft Store, but this time the culprit is… Visual Studio itself.

During the last few days, I’ve received several messages (1-star reviews, reddit, forums, Facebook) telling me that one of my applications is not downloadable from the Microsoft Store on Windows 10 Mobile or that updates are blocked.

In tech companies, when major issues as this one happen and once fixed, we write postmortem documents, explaining all errors we made and listing all tasks to do in order to be sure it will not happen again.

Usually, we keep them internally, but I’ve decided to share a part of mine in order to help other developers having this issue and give more information to users.

Reason: what cause the 0x80080204 error?

 
In our case, the culprit is Visual Studio 2017 + the Fall Creator Update SDK.

If your application contains a background audio agent, each time you edit your AppxManifest via the App Manifest Designer (the default viewer of this type of file) when you change the version number of your app (when you create a package for example), the appxmanifest becomes corrupted.

Before:


<Extension Category="windows.backgroundTasks" EntryPoint="TestApp.Agent">
  <BackgroundTasks>
    <Task Type="audio" />
  </BackgroundTasks>
</Extension>

 

After:


<Extension Category="windows.backgroundTasks" EntryPoint="TestApp.Agent">
  <BackgroundTasks/>
</Extension>

So when the Microsoft Store tries to install the application, it doesn’t know the type of the background agent and fail the installation (without an explicit reason).

Why we failed to detect it:

 
This problem is almost impossible to detect, cause:

  • Even with this faulty manifest, applications can be debugged or deployed from Visual Studio
    • Visual Studio doesn’t display warnings or errors
  • The manifest can become faulty at the last second, once all tests done, cause happening when we generate the package for the Microsoft Store
  • The Microsoft Store accepts the upload of this faulty manifest, validate it and publish it without a single warning
  • The error message displayed by the Store is not clear

How to fix it?

 
Microsoft is 100% responsible, they should:

  • Very urgent (less than 2 days): modify the Dev Center to reject every packages with background agents without types.
  • Urgent (less than 10 days): Update the SDK and/or Visual Studio to fix the issue.
  • Check every apps using Fall Creator Update SDK and verify the appxmanifest of these apps.
    • Contact developers and give them a documentation/guide to fix the issue.

Waiting these patches, I’ve created a little command-line tool verifying your appxmanifest and fixing it if needed.

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;

namespace FixAudioAppManifest
{
    class Program
    {
        static void Main(string[] args)
        {
            if (args == null || args.Length != 2)
            {
                Console.WriteLine("FixAudioAppManifest.exe <file path> <entry point name>");
                return;
            }

            var xmlModified = false;

            var xmlFilePath = args[0];
            var entryPointName = args[1];

            Console.WriteLine("@xmlFilePath = " + xmlFilePath);
            Console.WriteLine("@entryPointName = " + entryPointName);

            if (!File.Exists(xmlFilePath))
            {
                Console.WriteLine(xmlFilePath + " doesn't exist");
                return;
            }
            var xmlDoc = XDocument.Load(xmlFilePath);
            var windows10Namespace = XNamespace.Get("http://schemas.microsoft.com/appx/manifest/foundation/windows10");
            var nodeAgentToFix = xmlDoc.Descendants().Where(element => element.Name == windows10Namespace + "Extension" && element.Attribute("Category")?.Value == "windows.backgroundTasks" && element.Attribute("EntryPoint")?.Value == entryPointName).FirstOrDefault();
            if (nodeAgentToFix == null)
            {
                Console.WriteLine("Error: Entry point '" + entryPointName + "' not found");
                Console.WriteLine("FixAudioAppManifest.exe <file path> <entry point name>");
                return;
            }
            var backgroundTasksNode = nodeAgentToFix.Element(windows10Namespace + "BackgroundTasks");
            if (backgroundTasksNode == null)
            {
                Console.WriteLine("Error: BackgroundTasks element created cause missing");
                backgroundTasksNode = new XElement(windows10Namespace + "BackgroundTasks");
                nodeAgentToFix.Add(backgroundTasksNode);
                xmlModified = true;
            }

            var taskNode = backgroundTasksNode.Element(windows10Namespace + "Task");
            if (taskNode == null)
            {
                Console.WriteLine("Task element created cause missing");
                taskNode = new XElement(windows10Namespace + "Task");
                backgroundTasksNode.Add(taskNode);
                xmlModified = true;
            }

            if (taskNode.Attribute("Type") == null)
            {
                Console.WriteLine("Task:Type created cause missing");
                taskNode.SetAttributeValue("Type", "audio");
                xmlModified = true;
            }

            if (xmlModified)
            {
                xmlDoc.Save(xmlFilePath);
                Console.WriteLine("AppxManifest modified! The audio agent was correctly set.");
            }
            else
            {
                Console.WriteLine("AppxManifest not modified, the audio agent is correctly set.");
            }
        }
    }
}

Code available here:
FixAudioAppManifest.zip

To make sure your appxmanifest will not be corrupted by Visual Studio, first download the ZIP and compile the project inside.

Then, right click on your UWP project, select Properties, then Build events, and type in “Pre-build event command line”:

"c:\...\FixAudioAppManifest.exe" $(ProjectDir)Package.appxmanifest <entry_point_name>

Where entry_point_name is the name of the entry point in the appxmanifest related to your background audio agent.

Once done, the tool will check your appxmanifest every time you will compile your project, including when you will create your app package.

Comments are closed.