Skip to content

Commit

Permalink
Generate packs in parallel (#7764)
Browse files Browse the repository at this point in the history
  • Loading branch information
joeloff authored Aug 18, 2021
1 parent c24ccf5 commit c17de7f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ protected IEnumerable<ITaskItem> Generate(string sourcePackage, string swixPacka
File.Copy(sourcePackage, Path.Combine(packageContentsDirectory, Path.GetFileName(sourcePackage)));
}

foreach (string platform in platforms)
System.Threading.Tasks.Parallel.ForEach(platforms, platform =>
{
// Extract the MSI template and add it to the list of source files.
List<string> sourceFiles = new();
Expand Down Expand Up @@ -296,7 +296,7 @@ protected IEnumerable<ITaskItem> Generate(string sourcePackage, string swixPacka
msi.SetMetadata(Metadata.PackageProject, GeneratePackageProject(msi.ItemSpec, msiJsonPath, platform, nupkg));

msis.Add(msi);
}
});

return msis;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ public override bool Execute()
IEnumerable<WorkloadPack> workloadPacks = GetWorkloadPacks();
List<string> missingPackIds = new(workloadPacks.Select(p => $"{p.Id}"));

List<(string sourcePackage, string swixPackageId, string outputPath, WorkloadPackKind kind, string[] platforms)> packsToGenerate = new();

foreach (WorkloadPack pack in workloadPacks)
{
Log.LogMessage($"Processing workload pack: {pack.Id}, Version: {pack.Version}");
Expand All @@ -88,11 +90,15 @@ public override bool Execute()
string swixPackageId = $"{pack.Id.ToString().Replace(ShortNames)}.{pack.Version}";

// Always select the pack ID for the VS MSI package, even when aliased.
msis.AddRange(Generate(sourcePackage, swixPackageId,
OutputPath, pack.Kind, platforms));
packsToGenerate.Add(new(sourcePackage, swixPackageId, OutputPath, pack.Kind, platforms));
}
}

System.Threading.Tasks.Parallel.ForEach(packsToGenerate, p =>
{
msis.AddRange(Generate(p.sourcePackage, p.swixPackageId, p.outputPath, p.kind, p.platforms));
});

Msis = msis.ToArray();
MissingPacks = missingPacks.ToArray();
}
Expand Down

0 comments on commit c17de7f

Please sign in to comment.