Long build time due to duplicate link copying

I have a large WPF MEF PRISM application (over 100 projects), and the build time is about 2 minutes on quad-core 8 gigabyte machines.

I output all binaries to the same output path ".. \ Bin" so that our MEF loader can scan and find all assemblies.

As part of the build-time troubleshooting process, I noticed that every project that references the Infastructure base library will copy this binary to the output directory, resulting in multiple copies for the same file. I feel the actual compiler is running fast, but the number of duplicate copies is harming my build times.

Is there a way to tell the project not to copy links if the same version of the file already exists in the output directory? I already have secondary SLN files with a smaller collection of projects, and this helps most people reduce build time.

+4
source share
2 answers

Copying files in Windows is very fast, copying memory to memory thanks to the file system cache. This happens especially in the assembly, because the files have just been created, so their data is always present in the cache. Actual writing to disk occurs no later than when the cache manager lazily writes file data to disk. Which runs in the background and cannot slow down the build. The only time a copy of a file is slow is when the file system cache is full and must wait for a slow disk to write to make more space.

Copying the same file more than once, even if it was not created by the assembly, is similarly fast. You pay only for reading the file for the first time. After that, any subsequent copy always uses the data of the cached file.

There is no reasonable scenario where a .NET solution can fill the cache and increase it on a machine with 8 gigabytes of RAM. The cache must be at least 2 gigabytes. Writing a .NET solution that generates 2 gigabytes of code and resources is not a reasonable option.

You are trying to solve the wrong problem.

+3
source

I donโ€™t think this is a pretty acceptable solution, but you can let your infrastructure copy to the output directory and everywhere you refer to, you can set the CopyLocal attribute of a specific link to False. I am not saying that this is the only option, but it can do what you want. I just want to help.

EDIT:

I do not know if you do this, but if you do not, you can xcopy in post-build copy these DLL files necessary for MEF to this output directory. In this case, you could avoid these difficulties.

+1
source

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


All Articles