@@ -40,6 +40,7 @@ public sealed partial class DependencyManager : IDisposable
4040
4141 private readonly Lazy < Runtime > runtimeLazy ;
4242 private Runtime Runtime => runtimeLazy . Value ;
43+ private readonly int threads = EnvironmentVariables . GetDefaultNumberOfThreads ( ) ;
4344
4445 /// <summary>
4546 /// Performs C# dependency fetching.
@@ -752,7 +753,7 @@ private void ResolveConflicts(IEnumerable<string> frameworkPaths)
752753
753754 private void AnalyseSolutions ( IEnumerable < string > solutions )
754755 {
755- Parallel . ForEach ( solutions , new ParallelOptions { MaxDegreeOfParallelism = EnvironmentVariables . GetDefaultNumberOfThreads ( ) } , solutionFile =>
756+ Parallel . ForEach ( solutions , new ParallelOptions { MaxDegreeOfParallelism = threads } , solutionFile =>
756757 {
757758 try
758759 {
@@ -842,7 +843,7 @@ private void RestoreProjects(IEnumerable<string> projects, out IEnumerable<strin
842843 var successCount = 0 ;
843844 var assetFiles = new List < string > ( ) ;
844845 var sync = new object ( ) ;
845- Parallel . ForEach ( projects , new ParallelOptions { MaxDegreeOfParallelism = EnvironmentVariables . GetDefaultNumberOfThreads ( ) } , project =>
846+ Parallel . ForEach ( projects , new ParallelOptions { MaxDegreeOfParallelism = threads } , project =>
846847 {
847848 logger . LogInfo ( $ "Restoring project { project } ...") ;
848849 var res = dotnet . Restore ( new ( project , packageDirectory . DirInfo . FullName , ForceDotnetRefAssemblyFetching : true ) ) ;
@@ -942,7 +943,7 @@ private void DownloadMissingPackages(List<FileInfo> allFiles, ISet<string> dllPa
942943 var successCount = 0 ;
943944 var sync = new object ( ) ;
944945
945- Parallel . ForEach ( notYetDownloadedPackages , new ParallelOptions { MaxDegreeOfParallelism = EnvironmentVariables . GetDefaultNumberOfThreads ( ) } , package =>
946+ Parallel . ForEach ( notYetDownloadedPackages , new ParallelOptions { MaxDegreeOfParallelism = threads } , package =>
946947 {
947948 var success = TryRestorePackageManually ( package . Name , nugetConfig , package . PackageReferenceSource ) ;
948949 if ( ! success )
0 commit comments