Profile picture
Sidharth R
  • Home
  • Posts
  • Journal
  • Home
  • Posts
  • Journal
  • Search

How to Uninstall the NuGet Package Provider: PowerShell Guide

Updated: 13 Sep 2023 ⚬ Page views: 328

Introduction

I happened to install the NuGet Package Provider on my Windows 10 machine. I was prompted to install it when I tried to install the Tree module (using the Install-Module cmdlet). But later I realised that I didn’t need the Tree module. So I wanted to uninstall it. I couldn’t find any documentation on how to uninstall it. So I decided to write this article to help others who might be facing the same problem.

Little background on this issue

While installation of the NuGet Package Provider can be achieved using Install-PackageProvider -Name NuGet , there seems to be no cmdlet to uninstall it. You can argue that there should be a Uninstall-PackageProvider cmdlet. But there isn’t. As software developers, we expect that install commands should come with matching uninstall commands. However that’s not the case here.

Infact you can see a GitHub issue on this topic. The issue was opened in 2016 and is still open.

Trying to use the Uninstall-PackageProvider resulted in the following error message. This proves that there is no Uninstall-PackageProvider cmdlet.

Uninstall-PackageProvider : The term 'Uninstall-PackageProvider' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

How to uninstall the NuGet Package Provider

So how to uninstall the NuGet Package Provider? The answer is simple. Find the location of the NuGet Package Provider folder. Then delete the files (dll or exe files) from that folder.

To list all the installed Package Providers, you can use the following PowerShell command:

Get-PackageProvider

The output of the above command will be something like this:

Name                     Version          DynamicOptions
msi                      3.0.0.0          AdditionalArguments
msu                      3.0.0.0
NuGet                    2.8.5.208        Destination, ExcludeVersion, Scope, ...
PowerShellGet            1.0.0.1          PackageManagementProvider, Type, Scope, ...
Programs                 3.0.0.0          IncludeWindowsInstaller, IncludeSystemComponent

To find the location of the NuGet Package Provider folder, you can use the following PowerShell command:

(Get-PackageProvider NuGet).ProviderPath

The output of the above command will be something like this:

C:\Program Files\PackageManagement\ProviderAssemblies\nuget\2.8.5.208\Microsoft.PackageManagement.NuGetProvider.dll

You may now navigate to the above location and delete the NuGet Package Provider folder manually.

NuGet Package Provider folder

You can also delete it using the PowerShell Remove-Item cmdlet. To do so open an elevated (with administrator rights) PowerShell console and run the following command:

(Get-PackageProvider NuGet).ProviderPath | Remove-Item -force

You will encounter the Access to the path is denied error message, if you don’t run the above command in an elevated PowerShell console.

If you are on a (non-elevated) session, you can use the follwoing command to lauch an elevated PowerShell console and run the above command. You may want the console to stay open after the command is executed. So you can use the -NoExit switch.

powershell -NoExit -Command "Start-Process powershell -Verb RunAs -ArgumentList '-NoExit -Command `"`(Get-PackageProvider NuGet).ProviderPath | Remove-Item -force`"`'"

Note: you must ensure that the NuGet Package Provider dll file is not in use by any other process. If it is, you will encounter the Access to the path is denied error message.

How to verify that the NuGet Package Provider is uninstalled

To verify that the NuGet Package Provider is uninstalled, you can see the list of installed Package Providers using the following PowerShell command:

Get-PackageProvider

The output of the above command will be something like this:

Name                     Version          DynamicOptions
----                     -------          --------------
msi                      3.0.0.0          AdditionalArguments
msu                      3.0.0.0
NuGet                    2.8.5.208        Destination, ExcludeVersion, Scope, SkipDependencies, Headers, FilterOnTag...
PowerShellGet            1.0.0.1          PackageManagementProvider, Type, Scope, AllowClobber, SkipPublisherCheck, ...
Programs                 3.0.0.0          IncludeWindowsInstaller, IncludeSystemComponent

You can see that the NuGet Package Provider is still listed. Now, let’s check the location of the NuGet Package Provider folder:

(Get-PackageProvider NuGet).ProviderPath

This time the output was something like this:

C:\Users\<user>\AppData\Local\PackageManagement\ProviderAssemblies\nuget\2.8.5.208\Microsoft.PackageManagement.NuGetProvider.dll

Default NuGet Package Provider folder

Now this installation dates back to 2021 (2 years ago). So, this NuGet provider is not the one that I installed recently. This is the one that was installed by default when I installed Windows 10.

Conclusion

In this article, you learnt how to uninstall the NuGet Package Provider using PowerShell.

Nerdsid.com

Links
  • Home
  • Contact
  • About
  • Posts
  • Journal
  • Quotes
© 2025 Sidharth R.
All content on this website is licensed under CC BY-NC-SA 4.0.