我最近发现了带有powershellget模块的an issue,该模块的测试版中似乎已经解决了这个问题。当我运行powershell时,它似乎会自动加载2.2.5版本的模块,但这个问题在3.0.0-beta10模块中得到了修复。当我手动将2.2.5版本从我的
%programfiles%\WindowsPowerShell\modules\PowerShellGet文件夹,然后使用Import-Module手动加载3.0.0版本,然后使用本地模块的完整路径,它会加载我想要的版本。因为我的命令位于一个我想公开使用的模块中,所以删除该文件夹实际上并不可行,所以我尝试让我的模块强制加载该版本的模块。我想知道做这件事的正确方法是什么。因为它是测试版模块,所以在使用时似乎不会受到尊重。
#Requires -Modules @{ ModuleName="PowerShellGet"; ModuleVersion="3.0.0" }在函数内部,我不确定下一步要做什么,因为PowerShellGet是一个非常核心的模块。
编辑:当我删除2.2.5和3.0.0两个版本时,我得到以下错误:
The script 'Publish-ToPSGallery.ps1' cannot be run because the following modules that are specified by the "#requires" statements of the script are missing: PowerShellGet.
At D:\Public\powershell\modules\xanderu.helpers\xanderu.helpers\xanderu.helpers.psm1:43 char:6
+             . $_.FullName
+               ~~~~~~~~~~~
    + CategoryInfo          : ResourceUnavailable: (Publish-ToPSGallery.ps1:String) [], ScriptRequiresException
    + FullyQualifiedErrorId : ScriptRequiresMissingModules当我使用命令时:
install-module Powershellget -force  -AllowPrerelease它安装了正确的版本(3.0.0),但我不知道如何在清单中设置它。
编辑2:在我的测试中,我认为v3.0.0实际上并没有解决这个问题,但是我覆盖的nuget权限确实一直存在,直到我开始一个新的会话。
编辑3:我最终解决了我正在处理的问题,我的传播在测试版中得到了修复:https://github.com/PowerShell/PowerShellGet/issues/85
上帝说..。如何在模块中强制使用v3.0.0beta ...仍然不能完全确定这一点。
发布于 2021-02-19 18:44:49
看起来这个问题已经在PowerShellGet的测试版中得到了修复:https://github.com/PowerShell/PowerShellGet/issues/85
https://stackoverflow.com/questions/66027942
复制相似问题