[英]PowerShell Install-Module Command fails in Azure DevOps Pipeline
我有以下 PowerShell cmdlet 在執行管道時安裝 PowerShell 模塊
steps:
- powershell: |
Install-PackageProvider Nuget -Scope CurrentUser -Force
Install-module PSScriptAnalyzer -force -Scope CurrentUser
Install-module PSPesterTest -force -Scope CurrentUser
displayName: 'Install required PowerShell modules'
然而,這會引發錯誤"No repository with the name 'PSGallery' was found"
。 請任何人都可以為我指出有關此問題的解決方法嗎?
您的腳本語法有問題,請嘗試以下腳本:
pool:
vmImage: 'windows-2019'
steps:
- task: PowerShell@2
inputs:
targetType: 'inline'
script: |
Install-PackageProvider -Name NuGet -Force -Scope CurrentUser
Install-Module -Name PSScriptAnalyzer -Force -Scope CurrentUser
Install-Module -Name PSPesterTest -Force -Scope CurrentUser
這里是官方文檔,大家可以參考。
編輯:
Install-module
應該是Install-Module
。 此外,通過將 PSRespository 恢復為默認值,您的問題有望得到解決:)
Register-PSRepository -Default
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.