GenerateResource / CoreResGen suddenly taking almost 30 times as long
Starting a few weeks ago, compiling a project (VB.NET, .NET 2.0, VS 2010) has taken several times as long as before. In Task Manager, I noticed ResXtoResources.exe
taking lots of CPU for a while. I've finally been able to get some data on this using MSBuild's 'Diagnostic' output setting, and comparing that output to what I see in a branch from a few months back. Most striking are the final lines, which give timings. Before:
Target Performance Summary:
[..]
1395 ms CoreResGen 1 calls
1930 ms CompileLicxFiles 1 calls
2135 ms GenerateApplicationManifest 1 calls
2844 ms CoreCompile 1 calls
Task Performance Summary:
[..]
1391 ms GenerateResource 1 calls
1929 ms LC 1 calls
2134 ms GenerateApplicationManifest 1 calls
2843 ms Vbc 1 calls
Build succeeded.
Time Elapsed 00:00:09.50
========== Rebuild All: 5 succeeded, 0 failed, 0 skipped ==========
After:
Target Performance Summary:
1348 ms CompileLicxFiles 1 calls
1747 ms GenerateApplicationManifest 1 calls
2595 ms CoreCompile 1 calls
39575 ms CoreResGen 1 calls
Task Performance Summary:
1347 ms LC 1 calls
1745 ms GenerateApplicationManifest 1 calls
2593 ms Vbc 1 calls
39570 ms GenerateResource 1 calls
Build succeeded.
Time Elapsed 00:00:47.34
========== Rebuild All: 5 succeeded, 0 failed, 0 skipped ==========
Both projects were compiled on the same system with the same settings. We've made numerous changes, to be sure, but nothing to the order of magnitude that would justify such a change in timings (and only for this one task!). I assume resource generation is getting stuck on something — a circular reference, a missing one, etc. I have been unable, however, to find anything useful on how to trace such a problem down to what I assume is just a single resource file.
Short of looking through thousands of checkins or temporarily removing some forms (and thus, their resource files) from the project, is there anything else I can do to figure out the issue? I can't seem to find individual per-resource file timings.
Findings so far:
I've created a new, empty project with all the same .resx
files in place.
- The issue is not reproducible in .NET 4.0: compiling the exact same test project takes less than a second.
- The issue is reproducible in .NET 2.0 as soon as I also add one of the forms from the original project; apparently, it will otherwise not compile the resources "properly".
- Removing individual
.resx
fil开发者_如何学编程es will reduce the timings 'proportionally'; that is: I have unfortunately not found a single file that is the culprit.
Looks like this blog entry gives the answer.
In a nut, search your .resx
files for assembly references that don't actually exist (such as System.Windows.Forms, Version 4.0.0.0
), and replace them with ones that do (Version 2.0.0.0
). I used grepWin to accomplish this.
My CoreResGen
/ GenerateResource
timings are now roughly what they used to be. CruiseControl.NET says build time is down from 92 seconds to 40. :)
I found the reason here... the resources contained a png file save in special Adobe Fireworks format (PNG). I exported the file to png (without layer information) and now the compile takes 6 seconds.
精彩评论