From a140553dc148793660c93e2d267d06c11f517ce3 Mon Sep 17 00:00:00 2001 From: Jeff Kluge Date: Tue, 21 Mar 2017 13:48:02 -0700 Subject: [PATCH] Always write NuGet restoration marker --- src/CBT.NuGet/Tasks/NuGetRestore.cs | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/CBT.NuGet/Tasks/NuGetRestore.cs b/src/CBT.NuGet/Tasks/NuGetRestore.cs index 7778df3..5f32a17 100644 --- a/src/CBT.NuGet/Tasks/NuGetRestore.cs +++ b/src/CBT.NuGet/Tasks/NuGetRestore.cs @@ -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); } }