使用nuget在用户计算机上安装PowerShell模块 [英] Use nuget to install PowerShell modules at user machine

查看:283
本文介绍了使用nuget在用户计算机上安装PowerShell模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种分发Powershell模块的方法,并尝试使用nuget.

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

我已经测试过要制作commonstuff.pm1文件. 我将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)

install.ps1是

The install.ps1 is

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

手动运行install.ps1可以很好地工作,但不能以nuget软件包的形式运行:它将软件包下载到当前位置即可.

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   

我拥有nuget.exe的最新版本

I have the latest version of nuget.exe

是否有使用nuget安装PowerShell模块的推荐方法?我找不到一个.

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

推荐答案

通过Nuget.exe安装软件包时,将不会执行Powershell脚本.程序包将被提取到指定的文件夹中.

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

您必须从Visual Studio程序包管理器控制台安装它以执行install.ps1脚本.

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

这篇关于使用nuget在用户计算机上安装PowerShell模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆