How to decrease MSBuild times

后端 未结 4 1198
温柔的废话
温柔的废话 2021-01-31 10:22

My situation

In the C# project I am now working on we have a fairly big solution (80+ projects). Now rebuild times of 5 minutes+ are really becoming qui

4条回答
  •  醉梦人生
    2021-01-31 10:47

    We also have huge solutions. Build and compilation is all about I/O.

    Solid-state drives are very promising. A co-worker put a solid-state drive in his laptop, and found that it is now much faster than his humongous main development box. Don't have the details, but he claims many times faster.

    We've been fiddling with solution folders to group parts of the project: This makes it easier for devs to unload projects they aren't working on.

    /m rarely helps with .NET debug builds. I ran a series of tests on this a few weeks ago and found minor differences. Findings:

    • Because my build is I/O constrained, using /m:2-4 makes debug builds slower for me.
    • Release builds usually much faster.
    • Code analysis adds a lot of time.

    Big picture: In reality, compilation is a pretty minor cost for me, compared to getting source and running unit tests. On our build server, the integration tests and packaging are almost all the time. For my development box, I schedule a batch file that gets source, builds, runs unit tests before I come to work and while I'm at lunch. Good enough.

    On the build server, it's more complicated. We're thinking of setting up chained parallel CruiseControl.NET builds on various machines. We are using VSTS build, but it is too expensive (and time consuming) to scale horizontally like this.

    My numbers for detail-oriented folks. Configurations from slowest to fastest, running msbuild "bigsolution.sln" /target:clean - between each.

    1. /m: 4, Debug with code analysis 1:38
    2. /m: 1, Debug with code analysis 1:30
    3. /m: 4, Debug with no code analysis 1:30
    4. /m: 1, Debug with no code analysis 1:30
    5. /m: 1, Release with code analysis: 1:30
    6. /m: 4, Release with code analysis: 1:05
    7. /m: 4, Release with no code analysis: 0:53

    Build time without rebuild or clean: ~ 4-10 seconds

提交回复
热议问题