How to speed up Nant Builds?

We have several Nant scripts that compile .NET code. These builds take 5-10 minutes, and I would like to find a way to speed them up.

Our Nant script looks something like

<target name="compile.XYZ" description="Compiles the source code"> <msbuild project="${src.dir}\XYZ.sln" verbosity="${build.verbosity}"> <property name="Configuration" value="${build.config}" /> <property name="OutputPath" value="${build.fullpath}/${prefix.xyz}" /> <property name="ReferencePath" value="${assembly.dir}" /> </msbuild> </target> 

They are all very similar to this. I researched this for nant, but it looked a bit dated, so I hesitate to use it a bit, although it can be very convenient, since we have several goals in our assembly.

Any help you could provide in improving the performance of these assemblies would be greatly appreciated!

Thanks:)

+4
source share
4 answers

The more projects you have in your solution, the longer the assembly will take. Same thing with the number of solutions.

Nothing really you can do about it. By the way, this is not Nantes, here is slow, its msbuild.

You can try some of the suggestions of Scott Hanselmann:

http://www.hanselman.com/blog/FasterBuildsWithMSBuildUsingParallelBuildsAndMulticoreCPUs.aspx

Essentially, this requires you to complete the "BuildInParallel =" true "" task, although there are certain caveats.

This will allow us to simultaneously build projects within the same solution, but I do not see the possibility of creating multiple solutions in parallel.

To do this, you can make a meta-solution (supported only manually or auto-generated in nant until the build is completed), where you add all the different projects to it.

+3
source

One of the things you need to look for in any build system is to make it aware of all the dependencies. In your case, you mix build systems, and that's fine, but you have to make sure Nant and MSBuild know your dependencies. If you have two interdependent solutions, it may be useful to move these dependent projects into your own solution so that they are built only once during the build cycle.

Make sure you use incremental compilation. If you do not trust incremental strings for release candidates, use separate build goals for releases and tests and development. Also make sure that you use the appropriate compiler options for the type of assembly you are running.

Any solutions that do not have compile time dependencies on each other can be built in parallel. While MSBuild (3.5 and later) natively supports parallel assemblies on the same computer, Nantes does not (its Java affinity, Ant, the only way to compensate for this is to create a main solution file that is used only by the assembly. This will allow MSBuild to parallel independent Projects: This short MSDN-dated article shows the advantages and disadvantages of various project / project management methods.You can go to the next level by setting up a construction farm and building independent solutions on several machines: most continuous integration servers support this.

Another thing to consider is whether your projects comply with the DRY principle for multiple development projects. If two unrelated projects have classes with similar goals, you can combine them into one class and go to a shared library. By removing code duplication, you not only reduce maintenance costs, but also optimize the build process at the same time. Finding duplication in unrelated projects is time consuming if your developers specialize in specific projects.

+4
source

Assuming you have enough RAM, I would buy a RAM Disk application (I use this one with good results).

Install the source on this disk, install Nant. Install third-party libraries and other supporting infrastructure there. He must give at least 33% -50% high jump.

Also, get an SSD and install OS and .NET on it. Together you can cut it further.

+1
source

Another way is to separate the MSBuild tasks based on an understanding of your code. You can use the / m: x option to indicate how many processors can be used. Or just / m to use everything.

Some links for you:

+1
source

Source: https://habr.com/ru/post/1300832/


All Articles