Skip to content
This repository was archived by the owner on Jul 14, 2020. It is now read-only.
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
20 changes: 8 additions & 12 deletions src/CBT.NuGet/Tasks/NuGetRestore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,26 +145,22 @@ public bool Execute(string file, string msBuildVersion, string packagesDirectory
{
ret = Execute();

if (enableOptimization)
if (enableOptimization && !String.IsNullOrWhiteSpace(markerPath))
{
Log.LogMessage(MessageImportance.Low, "Creating marker file for NuGet package restore optimization: '{0}'", markerPath);

string dir = Path.GetDirectoryName(markerPath);

using (Mutex mutex = new Mutex(false, markerPath.ToUpper().GetHashCode().ToString("X")))
if (!String.IsNullOrWhiteSpace(dir))
{
if (!mutex.WaitOne(TimeSpan.FromMinutes(30)))
{
return false;
}
Log.LogMessage(MessageImportance.Low, "Creating marker file for NuGet package restore optimization: '{0}'", markerPath);

if (!System.IO.File.Exists(markerPath))
using (Mutex mutex = new Mutex(false, markerPath.ToUpper().GetHashCode().ToString("X")))
{
if (!String.IsNullOrWhiteSpace(dir) && !Directory.Exists(dir))
if (!mutex.WaitOne(TimeSpan.FromMinutes(30)))
{
Directory.CreateDirectory(dir);
return false;
}

Directory.CreateDirectory(dir);

System.IO.File.WriteAllText(markerPath, String.Empty);
}
}
Expand Down