How to abort installation from install.ps1 when prerequisites aren't satisfied?

Feb 11, 2011 at 3:32 PM
Is there some guideline on how to do that properly?


Daniel Cazzulino | Developer Lead | XML MVP | Clarius Consulting | +1 425.329.3471

Feb 11, 2011 at 5:54 PM

Can't do this today since install.ps1 gets called after installation happens. We need a preinstall.ps1...

Then we'll have a diagram of the NuGet script lifecycle :D.

Feb 11, 2011 at 6:10 PM

not good. I can check much more complex preconditions for installing my package via powershell (i.e. do you have IIS? is this a web project? do you have WIF installed?)
Feb 11, 2011 at 6:21 PM
dfowler wrote:

Then we'll have a diagram of the NuGet script lifecycle :D.

I like this.

May 2, 2011 at 1:13 PM

It seems as though install.ps1 should also be able to 'abort' the installation and cause it to rollback when it fails (non-zero exit code, throw exception, etc).  When I have attempted to throw an exception in the install.ps1, it rolls back when you install via the package manager console, but not when you install via the GUI.  I agree with the need for a pre-install.ps1 along with read-host functionality and/or parameter collection functionality.

May 2, 2011 at 6:49 PM

It should rollback for both. Can you file a bug with a repro package?


May 3, 2011 at 7:16 PM

Very simple install.ps1 for demonstration and can be added to any package for testing.  See workitem 1016.  Use update-package first, and see it fail the upgrade and roll back.  Then, use the GUI to update the package and it will succeed.