有没有一种方法可以加快Visual Studio团队服务(和TFS)的构建

编程入门 行业动态 更新时间:2024-10-23 13:23:16
本文介绍了有没有一种方法可以加快Visual Studio团队服务(和TFS)的构建的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我们的团队已使用Visual Studio在线建立了持续集成. 我们尝试通过付费构建限制提高对高级版的订阅,这是遥不可及的.但是,构建时间异常缓慢.

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之类的第三方服务的Package Management功能.
  • 并行化您的构建.如果您要构建多个项目或多个配置,请使用"MultiConfiguration"功能在多个代理上启动多个构建(在这种情况下,您确实需要分配多个托管代理)
  • 启用BuildInParallel以允许MsBuild启动多个实例,并启用MaxCpuCount=2以使用托管代理上可用的多个CPU内核.看起来它们在A3实例上运行,可以为您提供4个核心.如果同时使用BuildInParallel和MaxCpuCount,请不要使MaxCpuCount上的内核数最大化.
  • 使用OutputPath将所有输出构建到单个目录.
  • 使用构建任务上的复选框启用并行测试执行.
  • 尽可能地调整工作区映射.不需要的隐藏文件夹,仅映射您真正需要的文件夹.
  • 跳过构建CI真正不需要的所有内容.您可能想要关闭Code Analaysis并仅在每晚构建时运行完整的测试套件,以增加反馈时间,即使您正在降低反馈质量也是如此.
  • 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中的任何功能,这些功能将允许您进行增量构建或至少对工作区进行增量更新.并且无法删除代理的初始化时间和源检索.

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将为您带来最大的性能优势.使用您自己的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:

  • 关闭清理工作区".这将允许增量式源代码控制访存.
  • 关闭清理内部版本".这将使MsBuild能够执行增量构建.
  • 在具有足够CPU的同一台计算机上安装多个代理,以在同一VM上并行构建多个配置.
  • 如果要使用干净的工作空间进行构建,请在构建代理上为本地存储的文件安装TFVC代理(使用TFS 2013版本),但是可以利用TFVC更快的源检索优势.
  • 如果您使用的是Pre/Postbuild事件,请确保它们指定了输入和输出,以便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)的构建

本文发布于:2023-11-14 00:04:13,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1585662.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:团队   方法   Studio   Visual   TFS

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!