Register  
Tuesday, February 09, 2010
Blogs  


Latest Blogs
  
ActiReq Preview
  
Latest Articles
  
Archive
  
Featured Blogs
  
29

In a Windows Mobile project I'm currently working on I experienced a very slow compilation, and I've been struggling with this problem for weeks, until I found a very simple solution.

The project is an order entry application targeted for compact framework 2.0. As of now, it is a solution made up of 7 projects, 2 of which are executables and the other ones are libraries. The first thing I noticed is that slowness occurred on one project only: the data layer. I am using LLBLGen Pro, a powerful O/R mapper that simplifies data layer development taking advantage of its visual designer and code generator. The complete list of assemblies referenced by my project is shown below:

Project References

I'm not sure whether the slowness is caused by the LLBLGen Pro or either of the System.Data.* assemblies, or maybe both. I just know that the same issue happened on Windows XP, Vista 64, using either Visual Studio 2005 and 2008. I've just reinstalled Vista Ultimate on my T61p yesterday, and at the first full build it took 30 to 60 seconds, whereas it should take just a few seconds. Fortunately I already know how to solve this issue, but I hope anyone having the same issue can find the solution here.

The most important hint came after enabling diagnostic build output (Tools menu, Options, Projects and Solutions, Build and Run, MSBuild project build output verbosity option). After setting this property to Diagnostic, on next build I found the following statistics:

Task Performance Summary:
        0 ms  RemoveDuplicates                           2 calls
        0 ms  GetDeviceFrameworkPath                     1 calls
        0 ms  Message                                    5 calls
        0 ms  AssignCulture                              1 calls
        0 ms  FindAppConfigFile                          1 calls
        0 ms  AssignTargetPath                          10 calls
        0 ms  MakeDir                                    1 calls
        0 ms  ResolveNonMSBuildProjectOutput             1 calls
        0 ms  GetFrameworkPath                           1 calls
        0 ms  Delete                                     1 calls
        1 ms  CreateProperty                             1 calls
        1 ms  ConvertToAbsolutePath                      1 calls
        1 ms  ReadLinesFromFile                          1 calls
       12 ms  Copy                                       6 calls
       20 ms  FindUnderPath                              5 calls
       32 ms  Csc                                        1 calls
       47 ms  MSBuild                                    3 calls
      110 ms  ResolveAssemblyReference                   1 calls
    18382 ms  PlatformVerificationTask                   1 calls

Build succeeded.

Time Elapsed 00:00:18.64

So it looks like the build spends 18 seconds on the "Platform Verification Task". A good explanation about what this task is can be found in this blog post, along with the solution (although I came to this blog post after I found the solution elsewhere). In fact I simply need to disable the platform verification task, by editing the Microsoft.CompactFramework.common.targets file in the C:\Windows\Microsoft.NET\Framework\v3.5 folder. Once the file is opened using your favorite text editor (mine is Notepad++), locate the <target> tag having the name attribute set to PlatformVerificationTask

<Target
    Name="PlatformVerificationTask">
    <PlatformVerificationTask
        PlatformFamilyName="$(PlatformFamilyName)"
        PlatformID="$(PlatformID)"
        SourceAssembly="@(IntermediateAssembly)"
        ReferencePath="@(ReferencePath)"
        TreatWarningsAsErrors="$(TreatWarningsAsErrors)"
        PlatformVersion="$(TargetFrameworkVersion)"/>
</Target>

then add the Condition attribute to the PlatformVerificationTask tag as follows (the added line is the no. 102):

<Target  
    Name="PlatformVerificationTask">  
    <PlatformVerificationTask  
		Condition="'$(DoPlatformVerificationTask)'=='true'" <!-- Added -->
        PlatformFamilyName="$(PlatformFamilyName)"  
        PlatformID="$(PlatformID)"  
        SourceAssembly="@(IntermediateAssembly)"  
        ReferencePath="@(ReferencePath)"  
        TreatWarningsAsErrors="$(TreatWarningsAsErrors)"  
        PlatformVersion="$(TargetFrameworkVersion)"/>  
</Target>

Last, save and restart Visual Studio. Now the PlatformVerificationTask is not reported in the build log any longer, but most important, a normal build takes less than a second and a rebuild just a couple of seconds.

Task Performance Summary:
        0 ms  CreateProperty                             1 calls
        0 ms  ResolveNonMSBuildProjectOutput             1 calls
        0 ms  AssignTargetPath                          10 calls
        0 ms  ConvertToAbsolutePath                      1 calls
        0 ms  AssignCulture                              1 calls
        0 ms  FindAppConfigFile                          1 calls
        0 ms  Message                                    5 calls
        0 ms  RemoveDuplicates                           2 calls
        0 ms  Delete                                     1 calls
        0 ms  MakeDir                                    1 calls
        1 ms  GetDeviceFrameworkPath                     1 calls
        1 ms  GetFrameworkPath                           1 calls
        3 ms  Copy                                       6 calls
        6 ms  ReadLinesFromFile                          1 calls
       11 ms  FindUnderPath                              5 calls
       33 ms  Csc                                        1 calls
       53 ms  MSBuild                                    3 calls
       75 ms  ResolveAssemblyReference                   1 calls

Build succeeded.

Time Elapsed 00:00:00.22

References

Visual Studio For Devices blog: Platform Verification Task

Post Rating

Comments

Bruno
Sunday, March 01, 2009 4:32 PM
This works great! The slow rebuild drove me crazy!
MediMan
# MediMan
Monday, April 06, 2009 8:48 PM
Great Tip! Should be a switch in VS2008. Tremendous difference in my project's build time.
Oskar Mothander
Wednesday, May 13, 2009 11:27 PM
Thank you! I have an old computer and it was taking 5 minutes or more to run every time!! Now it takes about 2 minutes though, it's actually the deployment and not the build that takes time for me.

Allthough it was a nice and simple guide, I stupidly(?) added the html-comment to the config file () which made my VS not work.. so maybe you should be a bit more clear about that not being allowed there :)
Paul
# Paul
Monday, June 01, 2009 8:49 AM
Thanks, very useful.
Duncan
Sunday, August 23, 2009 3:22 AM
Thanks so much, my build time just dropped from 2min to under 1s
This has removed much frustration.
someguy198650
# someguy198650
Wednesday, September 02, 2009 12:11 AM
Thanks, it worked great.
Clemens
# Clemens
Friday, October 02, 2009 9:57 AM
Thanks for the tip!
If you want to skip the PlatformVerificationTask only for Debug-builds but not for Release-builds then use:
Condition="'$(Configuration)' != 'Debug'"
Goran Opacic
Wednesday, November 18, 2009 12:39 PM
Man! God bless you! After a year of suffering I finally dropped my build time from 4.5 minutes to 1.5 seconds!
Thanks Antonio
Gabo
Thursday, December 03, 2009 11:59 AM
Simplemente fenomenal!!!! God bless you!!!!
Christof Konstantinopoulos
# Christof Konstantinopoulos
Friday, January 29, 2010 4:55 PM
Only 18 Seconds delay? You are a lucky man!

Take a look on this Build Log (That are real values! I have not edited them!):
< start of Logfile >
Task Performance Summary:
0 ms ResolveNonMSBuildProjectOutput 1 calls
0 ms Message 6 calls
0 ms GetDeviceFrameworkPath 1 calls
0 ms AssignTargetPath 10 calls
0 ms FindAppConfigFile 1 calls
0 ms GetFrameworkPath 1 calls
0 ms CreateItem 1 calls
0 ms WriteLinesToFile 2 calls
0 ms AssignCulture 1 calls
0 ms PostSharp15GetCurrentProjectDirectory 1 calls
0 ms RemoveDuplicates 3 calls
0 ms ConvertToAbsolutePath 1 calls
0 ms CreateProperty 1 calls
31 ms CreateCSharpManifestResourceName 2 calls
31 ms MSBuild 3 calls
31 ms MakeDir 15 calls
47 ms ReadLinesFromFile 2 calls
78 ms FindUnderPath 7 calls
78 ms AddHighDPIResource 1 calls
109 ms ResolveAssemblyReference 1 calls
250 ms Delete 2 calls
500 ms Copy 7 calls
828 ms GenerateResource 1 calls
3172 ms AL 13 calls
4141 ms Csc 1 calls
4214226 ms PlatformVerificationTask 1 calls

Build succeeded.

Time Elapsed 01:10:23.77
< end of Logfile >

I hope you can understand, why I am so happy today. Many many Thanks!
Antonio Bello
# Antonio Bello
Saturday, January 30, 2010 1:51 AM
@Christof rotfl, that's the longest build time I've ever seen :) hope now you have a more reasonable build time
Christof
# Christof
Monday, February 01, 2010 2:38 AM
Yes, now it's OK. Only 20 seconds for a build (without Platform Verification Task).

FYI: The solution contains 110 files with 127662 code lines (without comments). The project was previously CF1 based. Now with WM6.1 I had to change to CF2 because I can't debug with VS2003 on a WM6 device.

Post Comment

Name (required)

Email (required)

Website

Enter the code shown above in the box below

 

stock icons

 

 

© 2006-2008 Developer's Corner - Powered by Elapsus   |  Privacy Statement  |  Terms Of Use