Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NuGet - install.ps1 does not get called

I'm trying to create my first NuGet package. I don't know why my install.ps1 script does not get called. This is directory structure

--Package
|
 - MyPackage.nuspec
 - tools
 |
  - Install.ps1
  - some_xml_file

I build package using this command line nuget.exe pack MyPackage.nuspec

When I Install-Package from VS Package Manager Console install.ps1 does not get called.

I thought that maybe I had some errors in script and that's the reason so I commented out everything but

param($installPath, $toolsPath, $package, $project)
"ECHO"

But I don't see ECHO appearing in Package Manager Console. What can be wrong?

like image 808
Piotr Perak Avatar asked Jul 31 '11 20:07

Piotr Perak


People also ask

Does NuGet automatically install dependencies?

Install NuGet packages without dependenciesBy default, when installing NuGet packages, corresponding package dependencies will also be installed in your project. To avoid the installation of dependent packages, choose the Ignore Dependencies option in the Dependency behavior drop-down in NuGet Package Manager.

What happens when a NuGet package is installed?

NuGet creates a subfolder for each package identifier, then creates subfolders for each installed version of the package. NuGet installs package dependencies as required. This process might update package versions in the process, as described in Dependency Resolution.


2 Answers

Install.ps will only be invoked if there is something in the \lib and/or \content folder, not for a "tools only" package, though. See here:

The package must have files in the content or lib folder for Install.ps1 to run. Just having something in the tools folder will not kick this off.

Use the Init.ps1 instead (however, this will be executed every time the solution is opened).

like image 145
mthierba Avatar answered Sep 22 '22 11:09

mthierba


Install.ps1 (and Uninstall.ps1) are no longer called in v3, but you can use Init.ps1. See here:

Powershell script support was modified to no longer execute install and uninstall scripts, but init scripts are still executed. Some of the reasoning for this is the inability to determine which package scripts need to be run when not all packages are directly referenced by a project.

like image 31
Jacco Avatar answered Sep 24 '22 11:09

Jacco