简体   繁体   中英

How can I create executable package for OneGet Install-Package?

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"
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM