从私有 DevOps 源使用 PowerShell 模块失败

问题描述 投票:0回答:1

我已遵循本指南:https://learn.microsoft.com/en-us/azure/devops/artifacts/tutorials/private-powershell-library?view=azure-devops并配置了 PowerShell 模块 MyModule,在 Azure DevOps 源中。

我已经使用 PAT 令牌和一个名为 MyRepo 的私有、受信任的 PSRepository 设置了本地计算机。

当我运行

Find-Module -Name MyModule -Repository MyRepo
时,它会找到 MyModule,但是如果我将其通过管道传输到
Install-Module
中,我会收到以下错误:

Install-Package: Cannot find the path 'C:\Users\Me\AppData\Local\Temp\355836562\MyModule.0.0.2\MyModule.psd1' because it does not exist.

Install-Module 命令的详细输出:

VERBOSE: Downloading module 'MyModule' with version '0.0.2' from the repository 'https://pkgs.dev.azure.com/MyOrg/MyProject/_packaging/MyModule/nuget/v2'.
VERBOSE: Searching repository 'https://pkgs.dev.azure.com/MyOrg/MyProject/_packaging/MyModule/nuget/v2/FindPackagesById()?id='MyModule'' for ''.
VERBOSE: InstallPackage' - name='MyModule', version='0.0.2',destination='C:\Users\Me\AppData\Local\Temp\1414719836'
VERBOSE: DownloadPackage' - name='MyModule', version='0.0.2',destination='C:\Users\Ax\AppData\Local\Temp\1414719836\MyModule.0.0.2\MyModule.0.0.2.nupkg', uri='https://pkgs.dev.azure.com/MyOrg/MyProject/_packaging/MyModule/nuget/v2?id=mymodule&version=0.0.2'
VERBOSE: Downloading 'https://pkgs.dev.azure.com/MyOrg/MyProject/_packaging/MyModule/nuget/v2?id=mymodule&version=0.0.2'.
VERBOSE: Completed downloading 'https://pkgs.dev.azure.com/MyOrg/MyProject/_packaging/MyModule/nuget/v2?id=mymodule&version=0.0.2'.
VERBOSE: Completed downloading 'MyModule'.
VERBOSE: Hash not found for the package 'MyModule'.
VERBOSE: InstallPackageLocal' - name='MyModule', version='0.0.2',destination='C:\Users\Me\AppData\Local\Temp\1414719836'
VERBOSE: Validating the 'MyModule' module contents under 'C:\Users\Me\AppData\Local\Temp\1414719836\MyModule.0.0.2' path.
Install-Package: Cannot find the path 'C:\Users\Me\AppData\Local\Temp\1414719836\MyModule.0.0.2\MyModule.psd1' because it does not exist.

我可以将相同的模块发布到 PowerShell Gallery 并从那里加载它。

我认为这可能与文件夹名称中的版本号有关,但目前我还一无所知。

有人遇到过类似的问题吗?

配置:

PS> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.3.7
PSEdition                      Core
GitCommitId                    7.3.7
OS                             Microsoft Windows 10.0.22621
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

PS> Get-Module powershellget -ListAvailable

    Directory: C:\program files\powershell\7\Modules

ModuleType Version    PreRelease Name                                PSEdition ExportedCommands
---------- -------    ---------- ----                                --------- ----------------
Script     2.2.5                 PowerShellGet                       Desk      {Find-Command, Find-DSCResource, Find-M…

powershell azure-devops nuget
1个回答
0
投票

事实证明它不再受支持。按照此处所述更改为 PSResourceGet:https://devblogs.microsoft.com/powershell/psresourceget-preview-is-now-available/ 解决了我的问题。

© www.soinside.com 2019 - 2024. All rights reserved.