有没有办法加快 Visual Studio 团队服务(和 TFS)的构建速度 [英] Is there a way to speed up the builds in visual studio team services (and TFS)

查看:12
本文介绍了有没有办法加快 Visual Studio 团队服务(和 TFS)的构建速度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的团队已经使用 Visual Studio Online 建立了持续集成.我们已尝试通过付费构建限制来提高我们的订阅,但我们远未达到.但是,构建时间异常缓慢.

Our team has set up continuous integration using visual studio online. We have tried cranking up our subscription to advanced with a paid build limit that we are nowhere near reaching. However, build times are exceptionally slow.

构建将在队列中等待几分钟,然后需要几分钟才能运行 [即使在测试将 Nuget 包添加到源代码管理时].

The builds will sit in a queue for several minutes then take several minutes to run [even when testing adding Nuget packages to source control].

有什么方法可以加快 Visual Studio Online 中的构建速度?如果不是,有什么好的选择?

Is there any way to speed up builds in Visual Studio Online? If not what are some good alternatives?

我认为接受或在 Azure VM 上设置我们自己的持续集成服务器是最坏的回退情况.

I see acceptance or setting up our own continuous integration server on an Azure VM as a worst case fallback.

推荐答案

托管构建服务器存在一些缺陷.首先,它们总是干净的图像,没有任何保留,因此您的源、包和以前构建的二进制文件不可用.因此,进一步加快构建速度的唯一方法是:

The Hosted build servers suffer a few flaws. First, they're always clean images with nothing preserved, so your sources, packages and previously built binaries are not available. Because of this, the only way to further speed up the build is to:

  • 通过以 NuGet 包的形式重新使用以前的结果,减少您构建的项目数量.这需要您将解决方案分解为更小的部分,并使用 Visual Studio Team Services 或 MyGet 等第三方服务的包管理功能.
  • 并行化您的构建.如果您正在构建多个项目或多个配置,请利用 MultiConfiguration 选项在多个代理上启动多个构建(在这种情况下您确实需要分配多个托管代理)
  • 启用 BuildInParallel 以允许 MsBuild 启动多个实例并启用 MaxCpuCount=2 以使用托管代理上可用的多个 CPU 内核.看起来它们在 A3 实例上运行,它为您提供 4 个内核.如果您同时使用 BuildInParallelMaxCpuCount,请不要最大化 MaxCpuCount 上的内核数.
  • 使用 OutputPath 将所有输出构建到一个目录中.
  • 使用构建任务上的复选框启用并行测试执行.
  • 尽可能地调整您的工作区映射.隐藏不需要的文件夹,只映射你真正需要的.
  • 跳过 CI 构建不需要的所有内容.您可能希望关闭代码分析并仅在每晚构建时运行完整的测试套件以增加反馈时间,即使您降低了反馈质量.
  • Reduce the number of projects you build by re-using previous results in the form of NuGet packages. This would require you to break the solution into smaller bits and use the Package Management features of Visual Studio Team Services, or of a 3rd party service like MyGet.
  • Parallelize your builds. If you're building multiple projects or multiple configurations make use of the ability to MultiConfiguration option to spin up multiple builds on multiple agents (you do need to allocate multiple hosted agents in this case)
  • Enable BuildInParallel to allow MsBuild to spin up multiple instances and enable MaxCpuCount=2 to use multiple CPU cores available on the hosted agents. It looks like they run on an A3 instance, which gives you 4 cores to play with. If you're using both BuildInParallel and MaxCpuCount don't max out the number of cores on MaxCpuCount.
  • Build all output to a single directory using OutputPath.
  • Enable parallel test execution using the checkbox on the build task.
  • Tweak your workspace mappings as much as you can. Cloak folders that are not needed, map only what you really need.
  • Skip everything you don't really need for your CI build. You may want to turn off Code Analaysis and run your full test suite only on a nightly build to increase your feedback time, even though you're reducing your feedback quality.

这是你能做的.您不能在托管池中租用更快的 VM,也不能使用 MsBuild 中的任何功能,这些功能允许您对工作区进行增量构建或至少增量更新.并且没有办法去掉agent的初始化时间和source检索.

This is about as much as you can do. You can't rent faster VM's in the hosted pool and you can't use any of the features in MsBuild which would allow you to do incremental builds or at least incremental updates of the workspace. and there is no way to remove the initialization time of the agent and the source retrieval.

要真正加快速度,您需要设置自己的构建服务器.使用在永久性 SSD 上运行的 DS Azure VM 将为您带来最大的性能优势.使用您自己的虚拟机,您可以执行以下附加操作:

To really speed up, you'll need to setup your own build server. Using a DS Azure VM running on a permanent SSD will give you the most performance benefit. With your own VM you can do the following additional things:

  • 关闭 Clean Workspace.这将允许增量源代码控制提取.
  • 关闭 Clean Build.这将允许 MsBuild 执行增量构建.
  • 在具有足够 CPU 的同一台机器上安装多个代理,在同一虚拟机上并行构建多个配置.
  • 在构建代理上为本地存储的文件安装 TFVC 代理(使用 TFS 2013 版本),以防您想使用干净的工作区进行构建,同时利用 TFVC 更快的源检索.
  • 如果您使用的是 Pre/Postbuild 事件,请确保它们指定它们的 Inputs 和 Outputs,以便 MsBuild 推断是否可以跳过目标以进行增量构建.

您可以在强大的开发人员工作站或现有的本地服务器上安装本地构建代理,而不是在 Azure 上托管代理.

Instead of hosting the agent on Azure, you can install a local build agent on a beefy developer workstation or an existing local server as well.

您可以应用其他 MsBuild 提示和技巧来进一步提高 MsBuild 的性能.用这种方式可以节省多少时间,这可能会让您大吃一惊.

There are other MsBuild tips and tricks you could apply to further iprove performance of MsBuild. It may amaze you how much time you can shave off your builds that way.

这篇关于有没有办法加快 Visual Studio 团队服务(和 TFS)的构建速度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆