Powershell
;includeRecommended 通過 powershell 安裝 Visual Studio Build Tools 2019 工作負載失敗
我正在嘗試使用 Powershell 在 Windows Server 2019 實例上自動安裝 VS Studio 2019 建構工具。假設建構工具引導程序與正常工具共享相同的命令行界面,我想通過 –add 安裝 2 個工作負載及其推薦的組件。MS 文件指定
;includeRecommended
了 WorkloadID 的後綴。由於 ; ,命令標誌的正確辨識似乎失敗了。在PowerShell中。我如何告訴引導程序包括工作負載的推薦組件?輸出:
PS C:\Users\Administrator> Invoke-WebRequest https://s3.eu-central-1.amazonaws.com/.../vs_buildtools __1986933399.1585486755.exe -OutFile c:\vs.exe PS C:\Users\Administrator> c:\vs.exe --passive --wait ` >> --add Microsoft.VisualStudio.Workload.MSBuildTools;includeRecommended ` >> --add Microsoft.VisualStudio.Workload.VCTools;includeRecommended ` >> --add Microsoft.Component.MSBuild ` >> includeRecommended : The term 'includeRecommended' 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 line:2 char:52 + ... add Microsoft.VisualStudio.Workload.MSBuildTools;includeRecommended ` + ~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (includeRecommended:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException includeRecommended : The term 'includeRecommended' 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 line:3 char:47 + --add Microsoft.VisualStudio.Workload.VCTools;includeRecommended ` + ~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (includeRecommended:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException includeRecommended flag for WorkloadId installment not reconized
在參數值周圍加上引號。
c:\vs.exe --passive --wait ` --add "Microsoft.VisualStudio.Workload.MSBuildTools;includeRecommended" ` --add "Microsoft.VisualStudio.Workload.VCTools;includeRecommended" ` --add Microsoft.Component.MSBuild `
在 Powershell 中,您可以在一行中執行多個命令,方法是用
;
. 因此,Powershell 認為命令以 結尾;
並蒐索具有下一個名稱的 cmdlet。或者,逃避它們也應該起作用:
--add Microsoft.VisualStudio.Workload.MSBuildTools`;includeRecommended `