简体   繁体   中英

Use nuget to install PowerShell modules at user machine

I am looking for a way to distribute Powershell modules, and trying to use nuget.

I have tested to make a commonstuff.pm1 file. I have make a nuget package as:

put commonstuff.pm1 > Content folder i package
add a install.ps1 in tools
Push:ed the packe to the nugetserver (A internal ProGet server)

The install.ps1 is

$p = $env:PSModulePath.split(';')[0] + "\\commonstuff"
mkdir $p
copy ./commonstuff.pm1 $p

It works fine to run the install.ps1 manually, but running as a nuget package doesn't: it just downloads the package to the current location and that is.

To download i use the command
nuget.exe install commonstuff -Source http://companysvr/nuget/test   

I have the latest version of nuget.exe

Is there a recommended way of installing PowerShell modules using nuget? I can't find one.

When you installing a package via Nuget.exe, the powershell scripts will not be executed. The package will just extracted in the specified folder.

You have to install it from visual studio package manager console to execute the install.ps1 scripts.

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