12

I have VS 2008 Professional and a Smart Device .NET C# project. I have ~100 cs files in total. The build takes a very long time, I have to wait for linker approx. 1min (60s) every time I compile the project. I have Core i3, 4GB RAM, 7200rpm disk.

What causes this and how can I optimize the build? Any Visual Studio options?

1
  • 2
    C# doesn't use a linker. Change the MSBuild output to diagnostic and paste the times you see into your question. Tools + Options, Project and Solutions, Build and Run. Oct 14, 2010 at 13:46

3 Answers 3

21

If you follow the advise from Hans Passant's comment and set MSBuild to diagnostic output it will give a clearer picture of just what is taking the time. If you find that your build is hanging on the Licensing Compiler (LC.exe) then this could be due to it trying to call a server and timing out. You can resolve this by altering your machine.config -

edit c:\windows\microsoft.net\framework\v2.0.50727\config\machine.config, and add the following key:

  <configuration>
    <runtime>
      <generatePublisherEvidence enabled="false"/>

EDIT://

Based on the comment below I did a little digging. The platform verification task has a known issue where it runs very slowly in VS2008. More detail on it can be found here:

http://blogs.msdn.com/b/vsdteam/archive/2006/09/15/756400.aspx

One way around this is to disable the task itself in your build. To do this

1) Open the file:

%windir%\Microsoft.NET\Framework\v2.0.50727\Microsoft.CompactFramework.Common.Targets

for editing.

2) Go to the line which reads:

Name="PlatformVerificationTask">

and change it to:

Name="PlatformVerificationTask" Condition="'$(SkipPlatformVerification)' != 'true'">

3) Add the SkipPlatformVerification environment variable to the system and set it to "true" (To re-enable Platform Verification set the environment variable to "false"). If you need help on setting up an environment variable read http://vlaurie.com/computers2/Articles/environment.htm. If you don't want to add an environment variable you can swap the condition for something that is always false (i.e. Condition="'true' == 'false'")

3
  • I checked the diagnostic level. In my case the PlatformVerificationTask takes 290174 ms. What is the reason?
    – cubesoft
    Oct 14, 2010 at 19:14
  • I found the Microsoft.CompactFramework.Common.Targets file in the 3.5 folder instead of 2.0 %windir%\Microsoft.NET\Framework\v3.5\Microsoft.CompactFramework.Common.targets
    – fefferoni
    Jul 4, 2016 at 12:48
  • 1
    Change <Target Name="PlatformVerificationTask"> to <Target Name="PlatformVerificationTask" Condition="0==1"> if you don't want to deal with environment variables. Aug 24, 2017 at 9:56
6

Just re-define an target in your .csproj file like this. Then it will works across the machine, Or of course you could copy the whole block of code with the conditional line added. Either way, you need not to modify the system file.

<Target Name="PlatformVerificationTask"></Target>
1
  • This is a great answer. The edit on Microsoft.CompactFramework.Common.Targets will get overwritten by Windows updates. This will work across machines.
    – mh__
    Oct 21, 2019 at 9:10
1

For windows 10 and framework 3.5,

in C:\Windows\Microsoft.NET\Framework\v3.5 folder, find Microsoft.CompactFramework.common.targets file.

In this section

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

change this, (add Condition="'$(DoPlatformVerificationTask)'=='true'" line)

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.