roslyn: build is slow, any suggestions?

Issue Description

Recently members of our team have been complaining about the slow compilation process and I was wondering if there were any ideas/suggestions/guidance to help us solve this problem.

Data

Target Performance Summary:
        0 ms  GenerateFakes                              4 calls
        0 ms  PrepareResourceNames                      15 calls
        0 ms  CreateCustomManifestResourceNames         15 calls
        0 ms  CopyAdditionalFiles                       15 calls
        0 ms  FileClassification                        14 calls
        0 ms  AfterMarkupCompilePass1                   14 calls
        0 ms  ExpressionBuildExtension                  14 calls
        0 ms  ValidationExtension                       14 calls
        0 ms  GenerateBindingRedirectsUpdateAppConfig    5 calls
        0 ms  BeforeResGen                              15 calls
        0 ms  AfterResolveReferences                    15 calls
        0 ms  CoreBuild                                 15 calls
        0 ms  BeforeGenerateFakesAssemblies              4 calls
        0 ms  AfterRebuild                              15 calls
        0 ms  _CheckForUnsupportedNETStandardVersion     1 calls
        0 ms  ExpandSDKReferences                       15 calls
        0 ms  ResolveSDKReferences                      15 calls
        0 ms  RemoveManagedWinRTComponentWinMDReferences   4 calls
        0 ms  BeforeResolveReferences                   15 calls
        0 ms  _RemoveZipFileSuggestedRedirect           14 calls
        0 ms  AfterResGen                               15 calls
        0 ms  ResGen                                    15 calls
        0 ms  PrepareResources                          15 calls
        0 ms  _CopySourceItemsToOutputDirectory         15 calls
        0 ms  GetNativeManifest                         13 calls
        0 ms  _PopulateCommonStateForGetCopyToOutputDirectoryItems  15 calls
        0 ms  ValidateMSBuildToolsVersion               10 calls
        0 ms  GetTargetPath                             15 calls
        0 ms  Compile                                   15 calls
        0 ms  _AfterCompileWinFXInternal                14 calls
        0 ms  AfterCompileWinFX                         14 calls
        0 ms  AfterCompile                              15 calls
        0 ms  ComputeIntermediateSatelliteAssemblies     5 calls
        0 ms  AddImplicitDefineConstants                 4 calls
        0 ms  _BeforeVBCSCoreCompile                    15 calls
        0 ms  BeforeCompile                             15 calls
        0 ms  GenerateAssemblyInfo                       4 calls
        0 ms  AddSourceRevisionToInformationalVersion    4 calls
        0 ms  InitializeSourceControlInformation         4 calls
        0 ms  _SetTargetFrameworkMonikerAttribute       15 calls
        0 ms  GenerateMSBuildEditorConfigFile           15 calls
        0 ms  SetWin32ManifestProperties                15 calls
        0 ms  GetFrameworkPaths                         15 calls
        0 ms  BeforeBuild                               15 calls
        0 ms  PrepareForRun                             15 calls
        0 ms  _GetProjectJsonPath                        4 calls
        0 ms  _DefaultMicrosoftNETPlatformLibrary        4 calls
        0 ms  _SdkBeforeClean                            4 calls
        0 ms  ValidateCommandLineProperties              4 calls
        0 ms  EnableIntermediateOutputPathMismatchWarning   4 calls
        0 ms  _CheckForObsoleteDotNetCliToolReferences   4 calls
        0 ms  _CheckForLanguageAndFeatureCombinationSupport   4 calls
        0 ms  _ComputePackageReferencePublish            4 calls
        0 ms  _CheckForUnsupportedTargetFrameworkAndFeatureCombination   3 calls
        0 ms  ValidateToolsVersions                      1 calls
        0 ms  PrepareProjectReferences                  15 calls
        0 ms  _AddOutputPathToGlobalPropertiesToRemove  15 calls
        0 ms  _SdkBeforeRebuild                          4 calls
        0 ms  BeforeClean                               15 calls
        0 ms  BeforeRebuild                             15 calls
        0 ms  _CheckForUnsupportedCppNETCoreVersion      4 calls
        0 ms  _ComputeUserRuntimeAssemblies              1 calls
        0 ms  ValidateProjects                           1 calls
        0 ms  ResolveLockFileAnalyzers                   4 calls
        0 ms  Clean                                     15 calls
        0 ms  IncludeTransitiveProjectReferences         4 calls
        0 ms  ResolvePackageDependenciesForBuild         4 calls
        0 ms  AfterClean                                15 calls
        0 ms  CleanPublishFolder                        15 calls
        1 ms  _ComputeSkipAnalyzers                     15 calls
        1 ms  GetCopyToOutputDirectoryXamlAppDefs       14 calls
        1 ms  BuildOnlySettings                         15 calls
        1 ms  _ComputeReferenceAssemblies                1 calls
        1 ms  ResolveCodeAnalysisRuleSet                 1 calls
        1 ms  GenerateMSBuildEditorConfigFileShouldRun  15 calls
        1 ms  GetMSTestV2CultureHierarchy                4 calls
        1 ms  CopyNativeBinariesToOutputDirectory        2 calls
        1 ms  IncludeTargetingPackReference              3 calls
        1 ms  GetAssemblyVersion                         4 calls
        1 ms  Build                                     15 calls
        1 ms  GetTargetPathWithTargetPlatformMoniker    15 calls
        1 ms  CleanXsdCodeGen                           14 calls
        1 ms  GetAssemblyAttributes                      4 calls
        1 ms  _CheckForCompileOutputs                   15 calls
        2 ms  _ErrorOnUnresolvedWindowsSDKAssemblyConflict   1 calls
        2 ms  FixAL1703Warning                           1 calls
        2 ms  _GetRestoreProjectStyle                    4 calls
        2 ms  _GenerateSatelliteAssemblyInputs          15 calls
        2 ms  GetTargetFrameworks                       13 calls
        2 ms  _GenerateSuggestedBindingRedirectsCache    5 calls
        2 ms  _GenerateCompileInputs                    15 calls
        2 ms  CollectPackageReferences                   4 calls
        2 ms  ValidateExecutableReferences               3 calls
        2 ms  CleanSNIFiles                              1 calls
        2 ms  EmbeddingAssemblyInteropUIAutomationClient   1 calls
        2 ms  CreateManifestResourceNames                5 calls
        2 ms  CreateGeneratedAssemblyInfoInputsCacheFile   4 calls
        2 ms  CreateSatelliteAssemblies                 15 calls
        3 ms  _SplitProjectReferencesByFileExistence    15 calls
        3 ms  ResolveReferences                         15 calls
        3 ms  GenerateNETCompatibleDefineConstants       4 calls
        3 ms  ApplyImplicitVersions                      4 calls
        3 ms  CheckForImplicitPackageReferenceOverrides   4 calls
        4 ms  CheckForDuplicateItems                     4 calls
        4 ms  PrepareForBuild                           15 calls
        4 ms  GetReferenceAssemblyPaths                 15 calls
        4 ms  _SetEmbeddedWin32ManifestProperties       15 calls
        4 ms  SplitResourcesByCulture                   15 calls
        5 ms  ResolveLockFileReferences                  4 calls
        5 ms  AfterBuild                                15 calls
        5 ms  AssignProjectConfiguration                15 calls
        7 ms  _CollectTargetFrameworkForTelemetry        4 calls
        8 ms  PreXsdCodeGen                             14 calls
        8 ms  GenerateMSBuildEditorConfigFileCore        4 calls
        9 ms  ResolveLockFileCopyLocalFiles              4 calls
        9 ms  ImplicitlyExpandNETStandardFacades        14 calls
       10 ms  CoreGenerateAssemblyInfo                   4 calls
       10 ms  ValidateSolutionConfiguration              1 calls
       14 ms  GetTargetFrameworksWithPlatformForSingleTargetFramework  13 calls
       14 ms  CopyMSTestV2Resources                      4 calls
       15 ms  _CleanIsIncrementalFile                   15 calls
       17 ms  _CheckForInvalidConfigurationAndPlatform  15 calls
       18 ms  GenerateTargetFrameworkMonikerAttribute   15 calls
       18 ms  CopySNIFiles                               1 calls
       21 ms  GenerateBindingRedirects                   5 calls
       25 ms  _GetCopyToOutputDirectoryItemsFromThisProject  15 calls
       27 ms  _GenerateCompileDependencyCache           15 calls
       27 ms  _CopyAppConfigFile                         6 calls
       44 ms  _WriteTelemetryProperties                 15 calls
       44 ms  AssignTargetPaths                         15 calls
       46 ms  IncrementalClean                          15 calls
       87 ms  _CleanGetCurrentAndPriorFileWrites        15 calls
      125 ms  ImplicitlyExpandDesignTimeFacades         14 calls
      184 ms  _GetCopyToOutputDirectoryItemsFromTransitiveProjectReferences  15 calls
      188 ms  _HandlePackageFileConflicts               15 calls
      206 ms  ResolvePackageAssets                       4 calls
      244 ms  FindReferenceAssembliesForReferences      15 calls
      268 ms  GetCopyToOutputDirectoryItems             15 calls
      283 ms  GenerateBuildDependencyFile                1 calls
      439 ms  _GetProjectReferenceTargetFrameworkProperties  15 calls
      518 ms  ResolveNuGetPackageAssets                 10 calls
      554 ms  GenerateSatelliteAssemblies                4 calls
      836 ms  _CopyOutOfDateSourceItemsToOutputDirectoryAlways   7 calls
      905 ms  CopyFilesToOutputDirectory                15 calls
     1706 ms  _CopyOutOfDateSourceItemsToOutputDirectory  10 calls
     2576 ms  CoreClean                                 15 calls
     2598 ms  CleanReferencedProjects                   15 calls
     3319 ms  _CopyFilesMarkedCopyLocal                 15 calls
     4328 ms  CoreResGen                                15 calls
     4445 ms  ResolveAssemblyReferences                 15 calls
    57142 ms  CoreCompile                               15 calls
    62511 ms  ResolveProjectReferences                  15 calls
    78849 ms  Rebuild                                   16 calls

Task Performance Summary:
        0 ms  GetAssemblyVersion                         4 calls
        0 ms  CreateCSharpManifestResourceName           7 calls
        0 ms  CombineXmlElements                        13 calls
        1 ms  MakeDir                                   34 calls
        1 ms  ResolveCodeAnalysisRuleSet                 1 calls
        1 ms  ValidateExecutableReferences               3 calls
        1 ms  AllowEmptyTelemetry                        4 calls
        1 ms  AssignCulture                             15 calls
        2 ms  GetRestoreProjectStyleTask                 4 calls
        2 ms  JoinItems                                  4 calls
        2 ms  CheckForDuplicateNuGetItemsTask            4 calls
        2 ms  ApplyImplicitVersions                      4 calls
        2 ms  FindAppConfigFile                         15 calls
        2 ms  GetFrameworkPath                          14 calls
        2 ms  CombineTargetFrameworkInfoProperties      13 calls
        3 ms  CheckForDuplicateItems                    12 calls
        3 ms  GetReferenceAssemblyPaths                 17 calls
        3 ms  CheckForImplicitPackageReferenceOverrides   4 calls
        5 ms  ConvertToAbsolutePath                     15 calls
        5 ms  AssignProjectConfiguration                15 calls
        6 ms  GenerateMSBuildEditorConfig                4 calls
       10 ms  WriteCodeFragment                          4 calls
       13 ms  Touch                                     15 calls
       14 ms  Hash                                      24 calls
       16 ms  RemoveDuplicates                          45 calls
       20 ms  GenerateBindingRedirects                   5 calls
       30 ms  WriteLinesToFile                          69 calls
       36 ms  GetReferenceNearestTargetFrameworkTask    11 calls
       40 ms  Message                                  912 calls
       41 ms  AssignTargetPath                         105 calls
       71 ms  ReadLinesFromFile                         30 calls
       73 ms  FindUnderPath                            105 calls
      150 ms  ResolvePackageFileConflicts               15 calls
      205 ms  ResolvePackageAssets                       4 calls
      223 ms  CallTarget                                44 calls
      283 ms  GenerateDepsFile                           1 calls
      367 ms  ResolveNuGetPackageAssets                 10 calls
      541 ms  AL                                         4 calls
     2444 ms  Delete                                    75 calls
     4319 ms  GenerateResource                           4 calls
     4438 ms  ResolveAssemblyReference                  15 calls
     6746 ms  Copy                                      75 calls
    57129 ms  Csc                                       15 calls
    144412 ms  MSBuild                                   63 calls

msbuild.binlog.zip

Versions & Configurations

MSBuild version : 17.4.0

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 16 (10 by maintainers)

Most upvoted comments

It would mean they all end up using the non-incremental source generator even if they have the roslyn version that supports incremental - right?

That’s a good point. I’ve opened https://github.com/dotnet/NuGet.BuildTasks/issues/152 to port this logic for non-SDK style projects.