关于 Azure DevOps Msbuild 任务

发布于 2025-01-11 17:05:50 字数 390 浏览 2 评论 0原文

我们有一个专用的构建服务器,上面安装了 Visual Studio 2019。我们正在使用 MSbuild 任务从该构建服务器编译源代码。现在,我有以下问题:

  1. 我们真的需要在构建服务器上安装 Visual Studio 才能使 msbuild 任务正常工作吗?
  2. azure devops 市场中是否有任何任务可以动态安装 Visual Studio 组件并由 msbuild 任务使用?

我认为我在帖子中没有很好地解释我的要求。我的要求是,Azure DevOps 构建管道应动态安装所需的 Visual Studio 构建工具/编译器,并且构建管道中的 msbuild 任务应使用它们。这在 Azure DevOps 中可能吗?这样我就不需要在构建服务器上安装 Visual Studio。

We have a dedicated build server having visual studio 2019 installed on it. And We are using MSbuild task to compile the source code from this build server. Now, i have following questions:

  1. Do we really need visual studio installed on the build server to get the msbuild task to work?
  2. Is there any task available in azure devops market place which will install visual studio components on the fly and which will be used by msbuild task?

I think i didn't explained my requirement well in my post. my requirement is, the Azure DevOps build pipeline should install required visual studio build tools/compilers on the fly and they should be used by the msbuild task in the build pipeline. is this possible in Azure DevOps? so that i don't need to have visual studio installed on the build server.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

很糊涂小朋友 2025-01-18 17:05:51

您可以从 Visual Studio 下载 站点下载当前版本的构建工具。这将安装大多数编译器、SDK 和工具包来构建您的代码。不过,有些事情确实需要完整的 VS,例如 vstest 任务和收集代码覆盖率等。

手动安装所需的 .NET SDK 和您依赖的可能的其他语言框架也可以解决这一问题,但没有一个简单的下载链接,在这种情况下,这完全取决于您正在构建的解决方案的类型。

在大多数情况下,您仍然需要有效的 Visual Studio 许可证,但如果您的任何团队成员拥有 Visual Studio 订阅,则您可以在 CI 基础结构上安装 Visual Studio 或构建工具的额外副本。

输入图片此处描述

您可以下载拥有 Visual Studio 订阅的旧版本:

在此处输入图像描述

我不知道有哪个扩展可以在工作流程中进行安装,安装是仍然相当大,并下载多个附加组件,并可能触发重新启动要求。

您可以执行构建工具的无人值守安装。可以在此处找到示例 PowerShell 脚本:

function install-VS19BuildTools{
# add the workloads you want to install on your server

$AllArgs = "--quiet --add Microsoft.VisualStudio.Workload.ManagedDesktopBuildTools --add Microsoft.VisualStudio.Workload.WebBuildTools --add Microsoft.VisualStudio.Workload.NetCoreBuildTools --add Microsoft.VisualStudio.Component.Windows10SDK.18362 --add Microsoft.Net.Component.4.7.TargetingPack --includeRecommended --wait"

$scriptRootPath = $PSScriptRoot
$vsToolsPath = Join-Path $scriptRootPath "vs_buildtools.exe"

$Result = Start-Process $vsToolsPath -ArgumentList $AllArgs -Wait
return $Result
}

install-VS19BuildTools

Microsoft 使用 Packer 脚本为 Azure DevOps 托管代理预配 VHD。 构建代理的脚本已向公众共享专门安装 Visual 的那个Studio 在这里此处。您应该能够用构建工具安装程序替换完整的 Visual Studio 安装程序。

You can download the current version of the Build Tools from the Visual Studio Download site. That will install most compilers, sdks and toolkits to build your code. Some things do require full VS though, like the vstest task and gathering code coverage etc.

Manually installing the required .NET SDKs and possible other language frameworks you depend on will also do the trick, but there isn't one easy download link for that, in that case it all depends on the kind of solution you're building.

In most cases you'll still need a valid Visual Studio license, though if any of your team members own a Visual Studio Subscription, then you may install an extra copy of Visual Studio or the Build Tools on yous CI infrastructure.

enter image description here

You can download older versions of you have a Visual Studio Subscription:

enter image description here

I'm not aware of an extension that will do the installation in the workflow, the installation is still quite huge and downloads multiple additional components and may trigger a reboot requirement..

You can perform an unattended installation of the Build Tools. A sample PowerShell script can be found here:

function install-VS19BuildTools{
# add the workloads you want to install on your server

$AllArgs = "--quiet --add Microsoft.VisualStudio.Workload.ManagedDesktopBuildTools --add Microsoft.VisualStudio.Workload.WebBuildTools --add Microsoft.VisualStudio.Workload.NetCoreBuildTools --add Microsoft.VisualStudio.Component.Windows10SDK.18362 --add Microsoft.Net.Component.4.7.TargetingPack --includeRecommended --wait"

$scriptRootPath = $PSScriptRoot
$vsToolsPath = Join-Path $scriptRootPath "vs_buildtools.exe"

$Result = Start-Process $vsToolsPath -ArgumentList $AllArgs -Wait
return $Result
}

install-VS19BuildTools

Microsoft uses a Packer script to provision the VHD for the Azure DevOps Hosted Agents. The scripts that build up the agent are shared to the public. The one that specifically install Visual Studio is here and here. You should be able to substitute the full visual studio installer with the build tools installer.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文