Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions src/Microsoft.DotNet.Build.Tasks.Workloads/src/GenerateMsiBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,11 @@ public string SuppressIces
set;
}

/// <summary>
/// Used to synchronize access to the NuGet being extracted.
/// </summary>
private readonly object extractNuGetLock = new object();

/// <summary>
/// Generate a set of MSIs for the specified platforms using the specified NuGet package.
/// </summary>
Expand All @@ -118,7 +123,11 @@ public string SuppressIces
/// <param name="platforms"></param>
protected IEnumerable<ITaskItem> Generate(string sourcePackage, string swixPackageId, string outputPath, WorkloadPackKind kind, params string[] platforms)
{
NugetPackage nupkg = new(sourcePackage, Log);
NugetPackage nupkg = null;
lock (extractNuGetLock)
{
nupkg = new(sourcePackage, Log);
}
List<TaskItem> msis = new();

// MSI ProductName defaults to the package title and fallback to the package ID with a warning.
Expand All @@ -139,7 +148,10 @@ protected IEnumerable<ITaskItem> Generate(string sourcePackage, string swixPacka
if ((kind != WorkloadPackKind.Library) && (kind != WorkloadPackKind.Template))
{
Log.LogMessage(MessageImportance.Low, $"Extracting '{sourcePackage}' to '{packageContentsDirectory}'");
nupkg.Extract(packageContentsDirectory, exclusions);
lock (extractNuGetLock)
{
nupkg.Extract(packageContentsDirectory, exclusions);
}
}
else
{
Expand Down Expand Up @@ -188,9 +200,12 @@ protected IEnumerable<ITaskItem> Generate(string sourcePackage, string swixPacka
SourceDirectory = packageContentsDirectory
};

if (!heat.Execute())
lock (extractNuGetLock)
{
throw new Exception($"Failed to harvest package contents.");
if (!heat.Execute())
{
throw new Exception($"Failed to harvest package contents.");
}
}

// Compile the MSI sources
Expand Down