What's the magic trick to get an Init.ps1 file to be loaded/executed when a package is added?

Oct 18, 2010 at 8:46 PM
This is a solution-level package. 
Installation succeeds. 
My custom functions are not recognized.

My Init.ps1 sits alongside the .nuspec, is successfully included in the .nupkg and properly unzipped when the package is installed with add-package.

Here's what it has, barely anything at all:

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

$global:funqletPath = $installPath
$global:funqletTools = $toolsPath

function global:Add-Funqlet {
    [CmdletBinding()]
    param ([string]$project)
    Process {
        # 
Write-Host Added to $project
    }
}

I'm adding a custom source pointing to a folder that contains the .nupkg 

Any tips?

/kzu

--
Daniel Cazzulino | Developer Lead | MS MVP | Clarius Consulting | +1 425.329.3471
Oct 19, 2010 at 12:24 AM

Init.ps1 needs to go in the Tools folder, not at the root.  See the MvcScaffold package for an example that uses this.

Jan 26, 2011 at 6:32 AM

May I suggest this to be added somewhere in the doc in bold ? It is mentioned that there is a "Tools" folder but the link with the Install.ps1 is not exactly straight forward. Thanks.