The content you're reading is getting on in years
This post is on the older side and its content may be out of date.
Be sure to visit our blogs homepage for our latest news, updates and information.
The time it takes to build your solution in Visual Studio could greatly hinder your performance. Especially if you got to some trial and error desperate measures which let's face it - everyone has to do from time to time.
Let's start with our experience. Few years back in SItefinity we managed to reduce the build times of the Telerik.Sitefinity.sln several times with some simple changes. When the solution started to rapidly grow on project numbers we noticed that the build times increase exponentially. Digging a bit got us to a bottleneck that once sorted out gave us improved build times by 5 minutes. Of course those times could be very different on your solution depending on its size the hardware you are using etc.
We achieved this by avoiding a lot of unnecessary .dll copy operations during the build. Those copy operations occur due to a setting on a project reference or assembly reference called CopyLocal.
By default all project references have their CopyLocal property set to true. If “Project A” references “Project B” and the reference is set to CopyLocal=true all output from “Project B” (dlls, pdbs, XML) will be copied to the output directory of “Project A”.
Here is a visual representation:
We had to change 2 things to avoid this:
Here a visual representation of the process after the change:
As you can see this is a much more fragile setup as it requires a manual settings for each new added project but I am sure you will agree this is an acceptable trade-off.
Another conclusion that can be made is that this setup will not work for solutions that have multiple starting projects like multiple websites, console applications, desktop apps etc. In this case another step will be required for example on after build that will take the resulting dlls from a specified folder and copy them to the startup projects.
Here is the ProjectReferenceModifier.targets that we wrote and included in every .csproj file of the solution:
<!--Set the copy local for project references to False only if the build is Inside Visual Studio or no OutDir was specified.-->
"$(BuildingInsideVisualStudio)=='True' OR ($(OutDirWasSpecified)!='True' AND $(WebProjectOutputDirInsideProject)!='True')"
Momchil Mitev is currently leading the Sitefinity R&D team at Telerik. He joined the company in 2008 as a web developer helping the internal business systems teams and later moved to the Sitefinity division. Previous responsibilities include leading the DevOps team in Telerik, helping with continuous delivery implementations.
Subscribe to get all the news, info and tutorials you need to build better business apps and sites
Copyright © 2019 Progress Software Corporation and/or its subsidiaries or affiliates.
All Rights Reserved.
Progress, Telerik, and certain product names used herein are trademarks or registered trademarks of Progress Software Corporation and/or one of its subsidiaries or affiliates in the U.S. and/or other countries. See Trademarks for appropriate markings.