How can I install MSBuild 17 on a Windows Server?

huangapple go评论78阅读模式
英文:

How can I install MSBuild 17 on a Windows Server?

问题

我正在尝试在一个将用于 CI/CD 流水线的 Windows 服务器(Windows Server 2016)上安装 MSBuild 17。据说 MS Build 17 是作为 .NET 6 SDK 的安装的一部分,但我没有发现这是真的。它也作为 VS 2022 Build Tools 下载的一部分进行安装,但该安装程序需要互联网连接,而目标 Windows Server 没有互联网连接。

有人能否提供其他在 Windows Server 上安装 MSBuild 17 的方法?

英文:

I'm trying to install MSBuild 17 on a Windows server (Windows Server 2016) that'll be used in a CI/CD pipeline. Supposedly MS Build 17 is installed as part of the installation of the .NET 6 SDK but I've not found that to be the case. It's also installed as part of the VS 2022 Build Tools download but that installer requires an internet connection and the target Windows Server has no internet connection.

Can anyone suggest any other way of installing MSBuild 17 on a Windows Server?

答案1

得分: 1

我成功地通过在桌面机器上创建一个离线安装文件夹,并使用下载的vs_BuildTools.exe进行安装,来安装了构建工具。以下是具体步骤:

  1. 在桌面机器上(具有互联网访问权限)执行以下命令:

    vs_BuildTools.exe --layout c:\dev\vs2022-build-tools-installer --add Microsoft.VisualStudio.Workload.MSBuildTools --add Microsoft.VisualStudio.Workload.ManagedDesktopBuildTools --add Microsoft.VisualStudio.Workload.WebBuildTools --includeRecommended --includeOptional
    

    这将创建一个输出文件夹(大约7GB),路径由--layout参数指定。

  2. 将输出文件夹复制到服务器上,并执行以下命令:

    vs_BuildTools.exe --noweb --add Microsoft.VisualStudio.Workload.MSBuildTools --add Microsoft.VisualStudio.Workload.ManagedDesktopBuildTools --add Microsoft.VisualStudio.Workload.WebBuildTools --includeRecommended
    
  3. 在弹出的对话框中选择要安装的组件时,确保.NET SDK被选中,然后点击安装。经过一段时间后,所有内容都成功安装。

我已经验证了安装了 MSBuild 17 并且可以正常工作,现在只剩下配置我要构建的 .NET 项目/解决方案,使得 NuGet 包从本地 NuGet 包主机下载,而不是从远程的 nuget.org(如果有任何建议,欢迎提供)。

英文:

I managed to install the build tools by creating an off-line installation folder using the downloaded vs_BuildTools.exe on a desktop machine (which has internet access) as follows:

vs_BuildTools.exe --layout c:\dev\vs2022-build-tools-installer --add Microsoft.VisualStudio.Workload.MSBuildTools --add Microsoft.VisualStudio.Workload.ManagedDesktopBuildTools --add Microsoft.VisualStudio.Workload.WebBuildTools --includeRecommended --includeOptional

I copied the output folder (size about 7GB) as specified by the --layout argument to my server and ran the command:

vs_BuildTools.exe --noweb --add Microsoft.VisualStudio.Workload.MSBuildTools --add Microsoft.VisualStudio.Workload.ManagedDesktopBuildTools --add Microsoft.VisualStudio.Workload.WebBuildTools --includeRecommended

From the resulting dialog for choosing which components will be installed, I made sure .NET SDK was ticked before hitting Install, after a number of long minutes everything successfully installed.

I've verified that MSBuild 17 was installed and works fine, the only thing left to do is configure the .NET project/solution I'm trying to build so that the Nuget packages are downloaded from a local Nuget package host rather than the remote nuget.org (any advice on that would be welcomed.

huangapple
  • 本文由 发表于 2023年7月27日 17:11:34
  • 转载请务必保留本文链接:https://go.coder-hub.com/76778200.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定