KB3007 - Resetting PowerShell Pro Tools (Visual Studio)

KB3007 - Resetting PowerShell Pro Tools (Visual Studio)

Scope

This article applies to Visual Studio 2017, 2019 and 2022 (Community, Professional and Enterprise)  with the PowerShell Tools for Visual Studio [2002] extension.

Problem

The PowerShell Tools for Visual Studio extension will not load

or

A known-working PowerShell project created previously in the same version of Visual Studio suddenly refuses to load  [📸 screenshot needed]

Cause

The cache or settings (or both) for that local  Visual Studio  installation have become corrupted.

Solution

Overview

This solution will suggest resetting the MEF component cache followed by deleting (or renaming/moving) the related Visual Studio local appdata directory.

Backup Settings

      1. Backup the Visual Studio settings to file [1] . An example filename would be  Exported-2023-09-01.vssettings .

     
       (figure shows the Import and Export Settings Wizard from Visual Studio )

Procedure 1 (optional)

      1. Clear the MEF component cache. The best way to do so is with the Clear MEF Component Cache  extension by Mads Kristensen [2] . You could also manually deleting the files [3] .


(figure shows the Clear MEF Component Cache feature added to the Visual Studio Tools menu)

Procedure 2

       1. Be sure you have exited Visual Studio completely and that the devenv.exe process is not running.
       2. Move/Rename/Delete the local cache directory (e.g. C:\Users\Username\AppData\Local\Microsoft\VisualStudio ) per example below.

      
          (figure shows a typical Visual Studio local appdata directory on a Windows workstation)

      3. Restart Visual Studio.
      4. Import the settings file you exported earlier.

Procedure 3

      1. If all else fails, re-installing Visual Studio is the next best option.
      2. If re-installing Visual Studio does not help, then consider trying a different workstation.