通过命令行在 VS Installer 中启用 NuGet 包管理器。 (作为自动化脚本的一部分)

Enable NuGet package manager in VS Installer through command line. (as part of automated script)

我想通过命令行启用 NuGet 包管理器,但我不知道该怎么做。

我们有一个安装 MSBuild15 BuildTools 的 Jenkins 管道(使用 choco 命令),我需要启用 NuGet 包管理器作为自动化脚本的一部分。

如果我直接在 server/agent 上启用它,那么解决方案的编译会成功,但我需要自动执行此步骤。

我已经通过 vs_installer 附上了它的外观图片 -> Image of VS Installer, what i need to enable through command line

这应该适用于 Powershell:

Start-Process "C:\Program Files (x86)\Microsoft Visual Studio\vs_installer.exe" -ArgumentList 'modify --installPath "C:\Program Files (x86)\Microsoft Visual Studio17\BuildTools" --quiet --add Microsoft.VisualStudio.Component.NuGet.BuildTools --add Microsoft.Net.Component.4.5.TargetingPack --norestart --force' -Wait -PassThru

在此处找到:https://developercommunity.visualstudio.com/content/problem/137779/the-getreferencenearesttargetframeworktask-task-wa.html#reply-160786