[英]Running Terraform from PowerShell in an Azure DevOps Pipeline
[英]Start Developer PowerShell for VS 2019 from Azure DevOps pipeline
我們已經配置了一個 Windows 虛擬機並在那里部署了一個代理來構建我們的代碼和運行腳本。
在我們的 VM 中,我們有兩種不同風格的 PowerShell 命令提示符:
我們如何從管道 YAML 腳本啟動“Developer PowerShell for VS 2019”並在那里執行我們簽出的.ps1
文件?
不過,有幾種類型的 PowerShell 任務可以從管道啟動,但不確定其中哪一種可以達到目的。 它們是:
以上哪項代表“VS 2019 的開發人員 PowerShell”?
這種特殊風格的 PowerShell 背后的原因是:
VS 2019 的 Developer PowerShell是一個導入了模塊的常規 PowerShell,您可以通過這種方式確切地看到:
現在再次右鍵單擊Developer PowerShell for VS 2019快捷方式和Properties 。
您將在使用某些命令運行常規 PowerShell 的位置看到:
C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe -noe -c "&{Import-Module """C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\Tools\Microsoft.VisualStudio.DevShell.dll"""; Enter-VsDevShell bc97b47b}"
現在,如果您打開 PowerShell 並在那里運行腳本:
&{Import-Module "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\Tools\Microsoft.VisualStudio.DevShell.dll"; Enter-VsDevShell bc97b47b}
您將獲得適用於 VS 2019 的 Developer PowerShell,並且 CoreFlags.exe 將起作用:
因此,您需要使用常規 PowerShell 任務(您的選項 2)並在腳本開頭運行上述命令。
注意:您應該准確復制您在Properties中看到的命令,在每台機器上它可能不同。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.