Microsoft Visual Studio 15.9 Known Issue

Since Visual Studio 15.9, many users of the IDE, including us, have been experiencing issues seemingly related to manifest generation.

Symptoms include errors like the following at build time:

Task 'GenerateAppxManifest' failed. An item with the same key has already been added

They also include runtime exceptions such as the following:

System.Runtime.InteropServices.COMException: 'Class not registered'

Or:

System.Exception: Class not registered

Microsoft has confirmed the issue and there is a fix that will be implemented in the upcoming Visual Studio 2019 release. Microsoft has also confirmed it will not be fixing this bug in any new releases of Visual Studio 2017.

Microsoft has also provided the following workaround, which uses an undocumented flag:

Add the following element to the topmost <PropertyGroup> in your app’s project file (the element without a Condition attribute):

1
<AppxWinMdCacheEnabled>false</AppxWinMdCacheEnabled>

This is not a permanent solution, but it will help until the fix is shipped in Visual Studio 2019.

The only other known workaround at this time is to do a clean rebuild of the application. Fortunately, it is not possible to accidentally ship an application with this problem, as such an application will not pass the WACK tests.