4. What we can do to improve build time?
• Get the latest hardware (CPU, RAM, SSD)
• Reduce lines of code
• Make your build parallel
• Code organization and MSBuild magics
• Where did we start?
• Reducing build time without code modification
• Change the architecture
• 3rd party tools to help
4
7. 1. Code Analysis
• We need code analysis but not for every build
• Code Analysis only runs on CI server or as a git hook
7
8. 2. Code Contracts
• Provides a design-by-contract programming model
• Runtime Checking (IL Rewrite – expensive)
• Static checking
• Document generation
• Code Contracts is an open source project now
https://github.com/Microsoft/CodeContracts
8
9. 2. Code Contracts
using System.Diagnostics.Contracts;
public Article GetArticle(int id)
{
Contract.Requires(id > 0);
Contract.Ensures(Contract.Results() != null);
// some work here
}
9
15. Why do we have so many I/O operations?
Library A
Library B
Library C
Web App
15
16. 1. CopyLocal = false
• Usually it is not a good idea because it does not work with
• top level projects
• second level dependencies
• reflection
• GAC-ed assemblies
• Runtime errors
16
17. 2. Common output folder
<OutputPath>..commonDebug</OutputPath>
• MSBuild does not have to copy existing files
• You might have unstable build
17
18. 3. Use hardlinks
…only in command line
/p:CreateHardLinksForAdditionalFilesIfPossible=true
/p:CreateHardLinksForCopyAdditionalFilesIfPossible=true
/p:CreateHardLinksForCopyFilesToOutputDirectoryIfPossible=true
/p:CreateHardLinksForCopyLocalIfPossible=true
/p:CreateHardLinksForPublishFilesIfPossible=true
18
20. 1. Create project only if …
• You need new deploy target (unit of deployment item)
• Plugin model
• Framework feature separation
• Think before you create a new one
• Merge your existing projects
Common
Framework
Utils
Extensions
Shared
Helpers
Configuration
Crypto
ErrorLogger
Cache Converters
20
26. Resharper Build
• Does not make your Rebuild faster...
… but it helps with the incremental builds
• All build management happens out of process
• Efficient timestamp monitoring
• Public API surface monitoring
26
27. So what we did?
• CodeAnalysis runs only on CI server
• Resharper Code Annotation instead of Code Contracts
• Automatic NuGet Restore instead of MSBuild based
• NuGet packages reorganization
• We’re testing the common output folder…
Time Elapsed 00:00:12.12
27
30. Start reducing the build time
of your projects now!
Contact me if you have any questions
peter.takacs@windowslive.com
https://www.linkedin.com/in/petertakacs1