我正在尝试使用 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
在参数值周围加上引号。
在 Powershell 中,您可以在一行中运行多个命令,方法是用
;
. 因此,Powershell 认为命令以 结尾;
并搜索具有下一个名称的 cmdlet。或者,逃避它们也应该起作用: