Execute script at package restore

Topics: General
Apr 29, 2013 at 1:52 PM
Hi All,

I'm using NuGet 2.5.

I have a package with Install.ps1 script.
The script detects the operating system (32bit or 64bit) and copies a specific dll file to the project root.

I need this script to run not only at install time, but also during package restore.
I tried using Init.ps1 - but this one does not execute during package restore either.

The scenario:
I have customers using source control (subversion).
The Customer's packages.config file is in source control.
Consequently, when a developer checks out a fresh copy and get the packages from NuGet, this is considered a restore (instead of install) and so the install.ps1 script will not execute.

Customers cannot commit the dll file into source control because it changes per operating system.

Is there a way to execute a script when packages are restored?

Apr 29, 2013 at 6:51 PM
No, package restore won't execute init script.
Apr 30, 2013 at 5:58 AM
Hi dotnetjunky,


so, the only way way out is to instruct users to close and re-open Visual Studio after restoring the package?
(then the init.ps1 is executed)

Granted, this is only required the first time a user checkout a working copy from source control.
But, I really don't want to tell my clients to restart their visual studio if they use source control.

I can see other users encountered this:

Maybe someone found a smarter way to workaround this?
I would be grateful for any help here.