Search code examples
visual-studio-2015windows-installermefvsix

What is proper way to uninstall extension from MSI?


I develop a simple Visual Studio package that declares a marker type using MEF:

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

The installer (it is not a VSIX) copies extension to program files:

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

and then touch (change modification date) "extensions.configurationchanged" file in that folder, so Visual Studio scan Extensions folder and loads my extension.

Everything works fine, but when I uninstall extension (delete folder and touch "extensions.configurationchanged" again) Visual Studio still try to load components from uninistalled extension. The log contains the following errors:

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 and 2013 do not log any errors in same case.

Only clearing of ComponentModelCache removes these errors in Visual Studio 2015.

How to remove my extension completely in custom installer?


Solution

  • This is a Visual Studio 2015 bug. It is reproduced in a simple VSIX extension: https://connect.microsoft.com/VisualStudio/feedback/details/3106716

    Upd: Fixed in Visual Studio 2017:
    https://developercommunity.visualstudio.com/content/problem/66084/mef-cache-do-not-updates-when-assembly-version-cha.html