5

I have a small windows mobile app with roughly 25 forms and maybe 50 classes split into 3 projects. When I'm building the project it takes 25 to 40 minutes for a normal CTRL-SHIFT-B in debug mode.

I have tried the skip platform verification hack, but it doesn't seem to help.

The environment is VS 2008
Windows Mobile 6.5.3
Compact Framework 2.0

<ProductVersion>9.0.30729</ProductVersion>
<OSVersion>5.02</OSVersion>
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
<NativePlatformName>Windows Mobile 6.5.3 Professional DTK</NativePlatformName>

The computer is an HP EliteBook 8440p with a i3 @2,4Ghz, 4gb ram.
There is plenty Ram available (2,2 Gb used).
CPU usage around 25% during compilation.

When I build, visual studio and all of it's child windows goes blank for 95% of the time.

The eventviewer doesn't show any particular warnings like a bad hard disk or so.

Update 1

In the process monitor trace I can see that there's regular network activity in devenv.exe during the build. Could VSS have something to do with the build? (I reach the vss-repository through a vpn tunnel that I have had in bypass mode today.)

Carl R
  • 8,104
  • 5
  • 48
  • 80
  • Have you tried to disable your anti-virus software? We've successfully increased our build speed by disabling anti-virus for the specific folder where the solution resides. But our problems have never been as bad as yours! – Christoffer Lette Nov 16 '11 at 12:48
  • This is certainly environmental. I've never seen it take anywhere near this long. Have you tried using another PC to see if anything changes? – ctacke Nov 16 '11 at 13:53
  • It's a customer PC and I need to use it. The antivirus is Forefront and I can't disable the build folders as it's locked down. However I can verify from Process Explorer that it doesn't spike in any way, it sits on 0.1 % cpu usage. – Carl R Nov 16 '11 at 14:08
  • Under your Configuration Manager, are you also compiling the Setup project? If it is a laptop, can you configure it to run at 100%? –  Nov 16 '11 at 14:18
  • The (four) setup projects are skipped in the current configuration. It is a laptop, and it's connected to external power. There is plenty of processing power left, running process monitor and other stuff during the build doesn't affect at all. – Carl R Nov 16 '11 at 14:40

1 Answers1

2

First the good news: you can shorten long build times and
here we go with the "bad news", the work:

  1. Try building it with MSBuild to avoid VS2008 to interupt or freeze build
  2. Try than to figure out, why your build is slow, you can watch the log go while building.
  3. Write down the parts which are special slow
  4. Try to fix the "long build time issue" by speeding up the slowest Projects first. Do this as long as you want a better performance or until there is no more project to speed up.

Common issues during Build:

  1. Com References can slow down your build if tehy are not build seperatly (TLBIMP.exe)
    try to build the interop libraries first, and than use them whereever youe want
  2. Post/PreBuild events can do some usfull but slow stuff... Clean them up and remove them wherever possible
    Use the Run when build updates the project output in the BuildEvents Properties of the Project to call the PostBuild events only if the Build changes the binaries.
  3. References in Soultion File stop your MSBUILD build so you should definitly fix them up to be in the project files
  4. Try to deploy directly/once deploying after build of every Project is slower than deploying after build the solution, make a "dist.bat" which firsts Builds and then deploys.

You can use a Visual Studio Macro to start your MSBUILD for the curently opened solution:

Public Module Builder

    Sub BuildSolutionDebug()
        SaveAll()
        Run("", "C:\WINDOWS\Microsoft.NET\Framework\v3.5\MSBuild.exe", """" & GetSolutionName() & """ /t:ReBuild /p:Configuration=Debug /p:Platform=""Mixed Platforms""")
    End Sub

    Sub Run(ByVal folder As String, ByVal file As String, ByVal arguments As String)
        Dim process As New System.Diagnostics.Process()
        process.Start(System.IO.Path.Combine(folder, file), arguments)
        Try
            process.WaitForExit()
        Catch ex As Exception

        End Try

    End Sub

    Sub SaveAll()
        DTE.ExecuteCommand("File.SaveAll")
    End Sub

    Function GetSolutionName() As String
        Return DTE.Solution.FullName
    End Function

End Module

Please contact me if you have further questions or want to discuss a point. I would be glad helping you.
I would also enjoy reading your solution to the problem, and in which point your build was slow!

oberfreak
  • 1,799
  • 13
  • 20
  • Can MSBuild deploy from the command line, or do you use something else to deploy? – Carl R Nov 16 '11 at 15:31
  • There is a COM reference in one of the projects, should I include that in a separate project and then include the interop file in the real project, or how would you go about with the com reference? Would referencing the interop file cause need for changes in the setup projects? – Carl R Nov 16 '11 at 15:33
  • 1. The Interops can be created in a seperat Project and referenced from all other – oberfreak Nov 16 '11 at 15:54
  • 2. The Interop has to be in a folder with the DLL where you want to use it, so you should copy it to the desired folders – oberfreak Nov 16 '11 at 15:57
  • 3. The interop is the same as before you only create it once and copy it to its destinations – oberfreak Nov 16 '11 at 15:57
  • 4. As far as i can see, you wouldn't have to change your setup – oberfreak Nov 16 '11 at 15:58
  • @ MSBUILD Deployment: you can deploy with MSBuild if you use a "deploy" Project, but i perfere setting the Build OutputPath to a deploy Folder for all Projects so i don't have to copy anything. Would that be possible? – oberfreak Nov 16 '11 at 15:58
  • I don't understand about deploy to folder. I'm deploying to a windows mobile device from within visual studio with an underlying active sync connection. – Carl R Nov 16 '11 at 16:04
  • Ah, so you deploy directly... i thought you were deploying to a folder where you build a setup or something like that. Maybe this can help: http://stackoverflow.com/questions/2130985/problems-using-msbuild-using-command-line-for-publish-click-once – oberfreak Nov 16 '11 at 16:08
  • Using MSBuild from the command prompt, the build time is down to less than 40 seconds. I'll deploy manually until I find a way to incorporate it. Thank you very much! :) – Carl R Nov 16 '11 at 16:38