从 MSI 卸载扩展的正确方法是什么?

What is proper way to uninstall extension from MSI?

我开发了一个简单的 Visual Studio 包,它使用 MEF 声明了一个标记类型:

[Export(typeof(EditorFormatDefinition))]
[Name("MyMarkerDefinition")]
[UserVisible(true)]
public class MyMarkerDefinition : MarkerFormatDefinition
{
    // ...
}

安装程序(不是 VSIX)将扩展名复制到程序文件:

C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO 14.0\COMMON7\IDE\EXTENSIONS\

然后触摸(更改修改日期)"extensions.configurationchanged" 该文件夹中的文件,因此 Visual Studio 扫描扩展文件夹并加载我的扩展。

一切正常,但是当我卸载扩展时(删除文件夹并再次触摸 "extensions.configurationchanged")Visual Studio 仍然尝试从未安装的扩展加载组件。日志包含以下错误:

ERROR Still unable to load MEF component DLL: Could not load file or assembly 'YourAssembly.dll' or one of its dependencies. The system cannot find the file specified. C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO 14.0\COMMON7\IDE\EXTENSIONS\YourExtension\YourAssembly.dll Microsoft.VisualStudio.CommonIDE.ExtensibilityHosting.VsShellComponentModelHost 2016/10/12 15:57:30.669

ERROR Could not find a part of the path 'C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO 14.0\COMMON7\IDE\EXTENSIONS\YourExtension\YourAssembly.dll'. C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO 14.0\COMMON7\IDE\EXTENSIONS\YourExtension\YourAssembly.dll Microsoft.VisualStudio.CommonIDE.ExtensibilityHosting.VsShellComponentModelHost 2016/10/12 15:57:31.170

Visual Studio 2010、2012 和 2013 在相同情况下不记录任何错误。

只有清除 ComponentModelCache 才能消除 Visual Studio 2015 年的这些错误。

如何在自定义安装程序中完全删除我的扩展程序?

这是一个 Visual Studio 2015 年的错误。它在一个简单的 VSIX 扩展中被复制: https://connect.microsoft.com/VisualStudio/feedback/details/3106716

更新: 已在 Visual Studio 2017 年修复:
https://developercommunity.visualstudio.com/content/problem/66084/mef-cache-do-not-updates-when-assembly-version-cha.html