Reputation: 1594
my dotnet code base is pretty big (so I don't feel like undertaking refactor into assemblies project) but doesn't change all that much. The build is real slow, although disk speed is fine - apparently it just takes awhile to compile the thing. So IMHO it would have made good sense for the compiler to cache compiled versions of files that haven't changed since last build in the optimistic expectation that no change in another file broke the module. Then if the optimistic assumption proved invalid, the full build could be undertaken. Well, I am pretty sure that things like that are often done while using Java and C++ compilers.
Could something like that be done here in dotnet? If not, why not :-) ?
Upvotes: 2
Views: 199
Reputation: 71591
Visual Studio doesn't rebuild an assembly unless it has to. It "has to" when any of the following change:
Also, build speed is less dependent on pure code count, or even class count, but the number of projects being built. Given a constant number of lines of code that must be fully rebuilt, a solution that builds into one assembly will build faster than a solution that builds into 10 assemblies, because there is a lot of overhead inherent in building an assembly that is repeated on each assembly.
Here are some basic tips to increase build speed:
Upvotes: 4
Reputation: 8008
Simple. Split the code into multiple smaller projects/assemblies. They will not get recompiled if no change detected. At source file level this is pretty impossible as a source file is hardly an independent unit of code
Upvotes: 0
Reputation: 9391
I assume you use Visual Studio and have all your projects in one solution? In that case the compiler usually builds only the projects where something has changed and the ones dependent from them.
If you compile all your code into one Assembly (you have only one project in the solution) then the compiler caches nothing. Each Dll is always build fully from all its source. There are no object files like in C/C++.
The proper way to go in that case is to break the code into multiple assemblies (one assembly per class is the rule of thumb/best practice).
Upvotes: 1