Improving CI build time (.NET)(改进 CI 构建时间 (.NET))
问题描述
我们正在开发使用 TeamCity 作为 CI 服务器的应用程序框架 +插件".
We are developing an application framework + "plugins" using TeamCity as a CI server.
- 4 个 Visual Studio 解决方案
- ~70 个项目(并且还在增加)
- 目前使用 TeamCity 运行 2 个构建:CI 和 FULL 构建.
CI - 在每次提交时触发.
CI - triggered on every commit.
FULL - 每晚运行.
我想提高两个构建的性能(尤其是 CI 构建,因为它需要尽快提供输出).
I would like to improve the performance of both builds (especially the CI build, as it needs to give its output as quickly as possible).
对于可以有效且轻松改进的方面是否有一般性指导?
Are there any guidelines in general on what can be effectively and easily improved?
构建过程只是构建一个 .sln 文件并运行一些单元测试.
The build process simply builds a .sln file and runs some unit tests.
- MSBuild 并行化
- 覆盖 CopyFilesToLocal
不确定这些是否适用/是否会带来性能提升.
Not sure these are applicable/will result in a performance gain.
我正在寻找更多方法来缩短构建时间(大约需要 3-4 分钟).
I am looking for more ways to improve the build time (which takes around 3-4 minutes).
推荐答案
尽量减少 ci 构建的工作量.
Minimise the work your ci builds do.
设置工作区,隐藏所有不需要的文件夹,以尽量减少需要从源代码管理中获取的文件数量.如有必要,重新组织您的源结构,以便通过隐藏功能轻松将整个数据文件夹从构建中剔除.
set up the workspace with any unneeded folders cloaked, to minimise the number of files you need to get from source control. If necessary reorganise your source structure so that it's easy to knock whole folders of data out of the build with cloaking.
确保 ci 构建使用增量获取和增量构建.
make sure the ci build uses incremental get and incremental build.
只构建您需要的解决方案/项目.如果您的库只是不经常更改,您可以预编译它们并将二进制文件检查到源代码控制中吗?如果一个项目当前没有被积极开发,请不要费心在 ci 构建中构建它.
only build solutions/projects that you need to. If your libraries only get changed infrequently, can you precompile them and check the binaries into source control? If a project is not currently being actively developed, don't bother building it in ci builds.
您是否需要为每次签入运行单元测试?我们只运行一个简单的 ci 代码构建,一个单独的测试构建作为 ci 运行,但频率不超过每小时一次.这减少了我们的 ci 构建时间,但如果我们破坏了任何单元测试,仍然可以在一小时内让我们知道.
do you need to run unit tests for every check in? We run a simple ci build of code only, with a separate test build running as ci, but no more frequently than once per hour. This slashes our ci build time but still lets us know within one hour if we break any unit tests.
同样,不要构建文档、混淆、构建安装程序、使用证书签署程序集等,并禁用任何将输出复制到放置文件夹的构建过程.CI 构建会告诉您是否尽快破坏了构建,您不必关心生成有用的二进制输出.
Similarly, don't build documentation, obfuscate, build installers, sign assemblies with certificates, etc, and disable any build processes that copy the outputs to the drop folder. CI builds are there to tell you if you've broken the build asap, you don't care about generating useful binary outputs.
总体优化构建 - 将项目合并在一起,使用多线程构建,使用多个构建代理,因此 ci 构建不必等待其他构建类型完成.仅在一夜之间进行完整构建,因此您的构建服务器在您工作时专用于 ci.保持源文件整洁(删除未使用的代码而不是仅仅将其注释掉,删除未使用的 usings/includes 等)
optimise the build in general - merge projects together, use multi-threaded builds, use several build agents so ci builds don't have to wait for other build types to complete. Only do full builds overnight so your build server is dedicated to ci while you are working. Keep source files tidy (delete unused code rather than just commenting it out, remove unused usings/includes etc.)
投资于更好的构建服务器硬件.如果您没有顶级规格的机器,请将更多 RAM 和 SSD 放入其中以降低速度.确保您的构建服务器专用于 ci 构建,并且没有用于任何可能减慢它的速度.确保构建服务器和 tfs 服务器之间的网络是千兆的.确保您的服务器上没有运行任何防病毒软件,或者至少确保它的计划扫描在夜间运行,并且您的构建文件夹在实时扫描排除列表中.
invest in better build server hardware. If you don't have a top spec machine, drop more RAM and an SSD into it for a cheap speed boost. Make sure your build server is dedicated to ci builds, and isn't being used for anything else that might slow it down. Make sure the network between the build server and tfs sever is gigabit. Ensure you don't have any anti-virus software running on the server, or at least that its scheduled-scans are run overnight and your build folders are in the real-time-scan exclusion lists.
如果 ci 构建失败,请使用 tfs 签入策略阻止开发人员签入,以便您立即停止并修复损坏.
use tfs check in policies to stop devs checking in if the ci build has failed, so that you stop and fix breakages immediately.
这篇关于改进 CI 构建时间 (.NET)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:改进 CI 构建时间 (.NET)
基础教程推荐
- 有没有办法忽略 2GB 文件上传的 maxRequestLength 限制? 2022-01-01
- 将 XML 转换为通用列表 2022-01-01
- MS Visual Studio .NET 的替代品 2022-01-01
- 如何在 IDE 中获取 Xamarin Studio C# 输出? 2022-01-01
- rabbitmq 的 REST API 2022-01-01
- 如何激活MC67中的红灯 2022-01-01
- SSE 浮点算术是否可重现? 2022-01-01
- c# Math.Sqrt 实现 2022-01-01
- 将 Office 安装到 Windows 容器 (servercore:ltsc2019) 失败,错误代码为 17002 2022-01-01
- 为什么Flurl.Http DownloadFileAsync/Http客户端GetAsync需要 2022-09-30