简体   繁体   English

加快ASP.NET中的构建时间

[英]Speeding up build times in ASP.NET

I am currently involved in a ASP.NET project with about 40 projects in the solution. 我目前参与了一个ASP.NET项目,该项目包含大约40个项目。 We are doing all our development in cloned Virtual PC environments so all developers have identical setups. 我们正在克隆的Virtual PC环境中进行所有开发,因此所有开发人员都具有相同的设置。 That's all good, managing dependencies is easy, however building the solution is horribly slow. 这一切都很好,管理依赖关系很容易,但构建解决方案的速度非常慢。 Virtual PC can only utilize one CPU so I'm really only using half of my computers resources. Virtual PC只能使用一个CPU,因此我实际上只使用了一半的计算机资源。

It takes a full 3 minutes from build to a complete page load.. and it's getting worse every day as the projects grow. 从构建到完整的页面加载需要整整3分钟......随着项目的增长,它每天都在变得越来越糟糕。 Fixing simple things is starting to take a long time and personally, I'm getting frustrated waiting all the time as I can't really work while the computer is compiling. 修复简单的事情开始花费很长时间并且个人而言,我一直在等待,因为我在计算机编译时无法真正工作。

Is there any way of distributing my build across several computers to speed up the build process? 有没有办法在多台计算机上分配我的构建以加快构建过程?

Would an SSD noticeably improve upon my build times? SSD会不会明显改善我的构建时间?

Are there any other way of speeding up the build? 有没有其他方法可以加快构建速度?

Note : I have tried precompiling static dependencies with ngen but later read that ASP.NET does not support ngen . 注意 :我尝试使用ngen预编译静态依赖项,但后来读到ASP.NET不支持ngen I use Visual Studio 2008 and there is no antivirus software present in the virtual environment. 我使用Visual Studio 2008,虚拟环境中没有防病毒软件。

You can greatly reduce the time you wait for a build with ASP.NET by doing the following: 通过执行以下操作,您可以大大减少等待ASP.NET构建的时间:

  • Use the new "optimizeCompilations" flag. 使用新的“optimizeCompilations”标志。 It will tell .NET to not rebuild the entire project just because you changed one project/dll. 它会告诉.NET不要因为你改变了一个项目/ dll而重建整个项目。 If you have 40 projects and you don't use this, every time you change a simple method in one project, .NET will try to compile all other projects and dlls. 如果你有40个项目并且不使用它,那么每次在一个项目中更改一个简单方法时,.NET将尝试编译所有其他项目和dll。 With the new flag (plus the installation of a hotfix) you will see a lot of increase overall performance during development. 使用新标志(加上修补程序的安装),您将看到在开发过程中大大提高了整体性能。 Check it out this blog post with details on how to speed up the build with this the optimizeCompilations flag: http://www.wagnerdanda.me/2009/11/optimizing-asp-net-build-time-with-dynamic-compilation-and-optimizecompilations/ 请查看此博客文章,详细了解如何使用optimizeCompilations标记加速构建: http//www.wagnerdanda.me/2009/11/optimizing-asp-net-build-time-with-dynamic-compilation -and-optimizecompilations /

Hope it helps! 希望能帮助到你!

Wagner Danda da Silva 瓦格纳丹达达席尔瓦

And here is another tip to speed up build times with ASP.NET: 以下是使用ASP.NET加快构建时间的另一个提示:

  • If you have enough memory, create a RamDisk and point your ASP.NET Temporary Files to this ram-based disk. 如果您有足够的内存,请创建一个RamDisk并将ASP.NET临时文件指向此基于ram的磁盘。 Check this blog post for more details on how to speed up the build time of ASP.NET projects with RamDisk: http://www.wagnerdanda.me/2009/11/speeding-up-build-times-in-asp-net-with-ramdisk/ 查看此博客文章,了解有关如何使用RamDisk加快ASP.NET项目构建时间的更多详细信息: http ://www.wagnerdanda.me/2009/11/speeding-up-build-times-in-asp-net -with-RAMDISK /

Hope it helps! 希望能帮助到你!

Wagner Danda da Silva 瓦格纳丹达达席尔瓦

Do you need to rebuild all 40 projects every time. 您是否每次都需要重建所有40个项目。

You can configure what gets built in the Solution Configuration settings. 您可以配置在“解决方案配置”设置中构建的内容。

Ie if you're changes are only in your WebUI Project, and the other 39 projects are unchanged, you can create a build configuration where only your web application is rebuilt. 即如果您的更改仅在您的WebUI项目中,并且其他39个项目未更改,则可以创建仅在重建Web应用程序的构建配置。

  • Look at the Configuration Drop Down 查看配置下拉菜单
  • Click "Configuration Manager" 单击“配置管理器”
  • In the "Active Solution Configuration" drop down click "New" 在“Active Solution Configuration”下拉菜单中单击“New”
  • Create a new Config copied from the Debug Configuration 创建从“调试配置”复制的新配置
  • In your new Configuration, uncheck all project builds except the ones you've made changes in 在新配置中,取消选中除已更改的项目之外的所有项目构建

Scott Gu has an fairly helpful post about this: Scott Gu有一个相当有用的帖子:

Tip/Trick: Optimizing ASP.NET 2.0 Web Project Build Performance with VS 2005 提示/技巧:使用VS 2005优化ASP.NET 2.0 Web项目构建性能

Scott also has another article on the speed of this Hard Disk, which also has an impact on the general performance of Visual Studio: Scott还有另一篇关于此硬盘速度的文章,它也对Visual Studio的一般性能有影响:

Tip/Trick: Hard Drive Speed and Visual Studio Performance 提示/技巧:硬盘速度和Visual Studio性能

Do not put so many projects in your solutions. 不要在解决方案中放置太多项目。 Only create a new project when the code is run in a different process or on a different machine. 仅在代码在不同进程或不同计算机上运行时才创建新项目。 There is no use to create so many projects in most cases. 在大多数情况下,创建这么多项目是没有用的。 The number of projects is the most significant slow down in msbuild. 项目数量是msbuild中最显着的减速。

What we did at our company is to use file reference, so only the changed projects need to be built, and at any given time there is no more than 10 projects in my solution, mostly 2~3 gets built. 我们在公司所做的是使用文件引用,因此只需要构建已更改的项目,并且在任何给定时间我的解决方案中不超过10个项目,大多数是2~3个项目。

We also build our trunk for each check-in, and have batch file for developers to pull the most recent dlls. 我们还为每次签入构建我们的主干,并为开发人员提供批处理文件以提取最新的dll。

Of course, this doesn't stop the painful assembly reference error from happening, but they become more of a nuisance than problem after a while. 当然,这并不能阻止痛苦的装配参考错误的发生,但是它们在一段时间后变得比问题更令人讨厌。

You didn't mention your Visual Studio version, but if it's 2005 you might want to consider an upgrade to 2008. In my case this decreased build time on a largish (30+ projects) solution. 你没有提到你的Visual Studio版本,但如果它是2005年你可能想考虑升级到2008.在我的情况下,这减少了大型(30+项目)解决方案的构建时间。

Another option it to pre-build a number of libraries that do not change anymore and reference the compiled dll's in stead of the projects. 另一种选择是预先构建一些不再更改的库,并引用已编译的dll而不是项目。

We have a similar situation, and I found that our virtual machines were being heavily throttled, and so although they each ran on a single CPU, they weren't allowed to fully utilise that CPU. 我们有类似的情况,我发现我们的虚拟机受到严重限制,因此虽然它们每个都运行在一个CPU上,但是不允许它们充分利用该CPU。 I managed to get 3 virtuals running on one physical to all perform 100% faster. 我设法在一个物理上运行3个虚拟机,所有都执行速度提高100%。


I'd also look at trying to reduce your number of projects. 我还试着减少你的项目数量。 Our main solutions has 40 projefts, and I've been slowly consolidating these, and making sure new development fits in to existing projects where possible. 我们的主要解决方案有40个项目,我一直在慢慢整合这些项目,并确保新开发项目尽可能适应现有项目。 The main culprits for this were webservices, where each had originally been created in a separate project. 这方面的主要元凶是webservices,其中每个服务最初都是在一个单独的项目中创建的。 I am now adding all new webservices into a single project, and slowly moving the others across. 我现在将所有新的Web服务添加到一个项目中,然后慢慢移动其他项目。

You might also consider switching to VMware Workstation, which does utilize multiple processors. 您也可以考虑切换到VMware Workstation,它使用多个处理器。 I'm currently using a setup with two two-processor VMs, and all four do get used. 我目前正在使用具有两个双处理器VM的设置,并且所有四个都可以使用。

Have you tried tuning up virtual PC? 您是否尝试过调整虚拟PC?

http://www.windowsnetworking.com/articles_tutorials/Tuning-Virtual-PC-Performance.html http://www.windowsnetworking.com/articles_tutorials/Tuning-Virtual-PC-Performance.html

Old article but the gist is still correct. 旧文章,但要点仍然是正确的。

I found, in a similar situation, that having a separate hard disk for the VPC disk images sped up performance remarkably especially when removing some of the throttling. 我发现,在类似的情况下,为VPC磁盘映像配备一个单独的硬盘可以显着提高性能,尤其是在删除一些限制时。

Maybe the problem isn't Visual Studio, it's just the fact that compilation is resource intensive. 也许问题不是Visual Studio,只是编译是资源密集的事实。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM