Dylan Beattie
Dylan Beattie

Reputation: 54140

Is there a nuget.exe command-line equivalent of Uninstall-Package?

I'm working on a NuGet package that installs a bunch of content - views, scripts, CSS files - into a web application, and trying to improve the change-compile-test cycle. I have two projects - the framework itself ("Package") and the demo web app that consumes it ("Website")

What I need to do as part of the Visual Studio build process is:

  1. (as part of Package post-build) Nuget pack Package.nuspec -OutputDirectory ..\pkg\
  2. (as part of Website pre-build) Nuget uninstall Package
  3. (as part of Website pre-build) Nuget install package -source ..\pkg\

The problem is - there doesn't seem to be any command-line equivalent of doing Uninstall-Package from the NuGet Package Manager console. Am I missing something?

Upvotes: 17

Views: 6503

Answers (2)

Matt Ward
Matt Ward

Reputation: 47937

There is a way but using neither Visual Studio nor NuGet.exe. Using a custom build of SharpDevelop you can install and uninstall NuGet packages from the command line and have their PowerShell scripts run.

This custom build of SharpDevelop and its NuGet addin allows you to run the commands, such as Install-Package and Uninstall-Package, from PowerShell but outside of Visual Studio.

The limitations are that it needs SharpDevelop to be available and it also does not support any PowerShell scripts that are Visual Studio specific.

Upvotes: 2

Xavier Decoster
Xavier Decoster

Reputation: 14810

No there isn't currently.

Also, nuget.exe install doesn't really install anything. What nuget.exe install really does is nuget.exe restore: it restores the extracted package in the output directory. It doesn't run the PowerShell hooks (e.g. install.ps1) and it doesn't modify any target project (as there's none being targeted).

Upvotes: 11

Related Questions