简体   繁体   English

使用nuget在用户计算机上安装PowerShell模块

[英]Use nuget to install PowerShell modules at user machine

I am looking for a way to distribute Powershell modules, and trying to use nuget. 我正在寻找一种方法来分发Powershell模块,并尝试使用nuget。

I have tested to make a commonstuff.pm1 file. 我已经测试过makestuff.pm1文件。 I have make a nuget package as: 我做了一个nuget包:

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 install.ps1是

$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. 它可以手动运行install.ps1,但作为nuget包运行不会:它只是将包下载到当前位置,即。

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

I have the latest version of nuget.exe 我有最新版本的nuget.exe

Is there a recommended way of installing PowerShell modules using nuget? 是否有推荐的方法使用nuget安装PowerShell模块? I can't find one. 我找不到一个。

When you installing a package via Nuget.exe, the powershell scripts will not be executed. 通过Nuget.exe安装程序包时,将不会执行powershell脚本。 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. 您必须从visual studio包管理器控制台安装它才能执行install.ps1脚本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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