I want to publish number of PowerShell scripts as Nuget package to be used on build systems.
I want to use PowerShellGet to do installation work for me and version management.
I don't want those scripts to be part of any Visual Studio solution, but as standalone scripts.
On any system, with configured Nuget provider user executes:
Install-Module MyModule
From that moment all exports from that module permanently available for this user. Also user can call that command again to update version of those scripts.
You can find current state of package here: GitHub
I've added and configured Nuget provider to our local Nuget server
To do this call Get-PackageProvider -Name NuGet -ForceBootstrap
and Set-PSRepository -Name My_Nuget_Repo -SourceLocation http://my-nuget/api -InstallationPolicy Trusted
Created proper module, which can be imported locally by Import-Module
Created and published Nuget package with that module
I can install that package by Install-Module
cmdlet and I can see it later in Get-InstalledModule
list.
But, no functions are available.
Also, no matter what, but Install-Module
not calling any of scripts from my package:
ScriptsToProcess
from MyModule.psd1
Install.ps1
from tools
folderInit.ps1
from tools
folderImport-Module
(Same package works properly when installed from Visual Studios Install-Package MyModule
, scripts are called, PowerShell module is imported).
Since PowerShellGet
is based on OneGet
it seems that problem is in Install-Package
cmdlet (which is called inside Install-Module
cmdlet).
When I'm executing Install-Package MyModule
from Visual Studio Install.ps1
and Init.ps1
are called. But same command from pure PowerShell doing nothing.
After long reverse engineering I've found the root cause
Magical tag PSModule
has to be added to <Tags>
in nuspec file.
You shouldn't create nuspec file and pack nuget package manually at all. Use Publish-Module
cmdlet instead.
I've updated powershellget-module GitHub with:
Check it out.