管理 Powershell 模块的依赖项

csk*_*wrd 5 powershell

我有我的自定义 Powershell 脚本模块,我们称之为PsHandyCmdlets. 在其清单中找到以下行:RequiredModules = @('<Another module not necessarily installed yet>')

RequiredModules属性应该保证在导入当前模块之前将此处列出的任何模块导入到全局范围内。如果该模块不能位于机器上,这将失败。

Powershell 是否提供了确保这些模块在安装时PsHandyCmdlets安装的机制?如果没有,是否有处理这种情况的最佳实践?

Jim*_*Jim 2

Rene Hernandez 在他的博客上写了一篇很好的文章,讨论了这个主题并提供了一些解决方案。他还提供了可用于解决这一挑战的 PowerShell 模块 (PSDepend) 的链接。(链接消失了,但提供了示例链接)

https://github.com/renehernandez/powershell-dependency-example

PSDepend 模块由 RamblingCookieMonster 编写,我很欣赏他们的工作,因为他们的工作具有创新性和扎实性。

https://github.com/RamblingCookieMonster/PSDepend