I understand how to create a package for NuGet. There's also nothing especially hard with creating a NuGet package or PowerShell package.
I'm aware it may be impossible to create PowerShell package with binary cmdlet in .NET Core, so wondering if it's possible to create a package with lifecycle hooks.
Say, in npm
, you can define scripts in package.json
to declare pre/post install/publish dependencies.
So, the question is:
How can I perform custom script after having my package added to the system via Install-Package
?
For example, I want to add executable to PATH (likely to be pretty common task)
Likely, this one will work: project.json#scripts Note, that valid values are allowed platform executables, so, as I got that, PowerShell is not allowed by default.
Quick workaround, as far as arguments are available:
runner.cmd
:
@powershell -File %1
and in project.json
:
"scripts": {
"postrestore": "%project:Directory%/scripts/runner.cmd %project:Directory%/scripts/install.ps1"
}