You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Azure Pipelines的Windows 2022环境中安装Winget?

在Azure Pipelines Windows 2022环境中安装Winget的问题

已尝试的方法及报错

方法一:使用第三方安装脚本

执行后触发如下错误:

##[error]Test-IsAdmin : The term 'Test-IsAdmin' is not recognized as the name of a cmdlet, function, script file, or operable 
program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At D:\a\1\s\installwinget.ps1:2 char:11
+ if (-not (Test-IsAdmin)) {
+           ~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Test-IsAdmin:String) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : CommandNotFoundException
##[error]PowerShell exited with code '1'.

方法二:直接下载并运行安装程序

执行命令:

Invoke-WebRequest -Uri https://aka.ms/getwinget -OutFile winget.appinstaller.exe; Start-Process winget.appinstaller.exe

得到报错:

##[error]Start-Process : This command cannot be run due to the error: The specified executable is not a valid application for 
this OS platform..
At D:\a\1\s\sqlserverinstall.ps1:23 char:83
+ ... utFile winget.appinstaller.exe; Start-Process winget.appinstaller.exe
+                                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Start-Process], InvalidOperationException
    + FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.Commands.StartProcessCommand

需求

需要一个能直接在Azure Pipelines(windows-2022)环境中开箱即用的Winget安装解决方案。

内容的提问来源于stack exchange,提问作者Daan

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.22 04:44:57