UWP APPX Deployment fails with 'Deployment failed. XmlException'

On the App Consult team we often work on several different applications in given day. The other day when using Visual Studio 2017 to deploy a UWP app I got the following error:

DEP0600: Deployment failed. XmlException - Data at the root level is invalid. Line 24, position 11.

After much debugging and Binging, an SDE pointed out that I was hitting a known bug in the OS - which will be fixed in the upcoming Fall Creators update. At install time, all of the installed package are enumerated to see if the package has already been installed. This enumeration fails if the installed app's AppxManifest.xml file is malformed.

I had several test apps installed on my machine, some deployed with Visual Studio, some installed with PowerShell using the command:

Add-AppxPackage -Register .\PackageLayout\AppxManifest.xml

After uninstalling several of the test apps, I was able to deploy my app with Visual Studio 2017 without problems.

 

Tip: Learn more about the Desktop Bridge from this excellent Microsoft Virtual Academy course: Developer's Guide to the Desktop Bridge.