From b2a01607f2013d7978115eb2a02b0cc402f7bcd9 Mon Sep 17 00:00:00 2001
From: Pranav K <prkrishn@hotmail.com>
Date: Wed, 28 Sep 2016 15:24:48 -0700
Subject: [PATCH] Add a flag that allows producing non-coherent builds

---
 makefile.shade | 26 ++++++++++++++++----------
 1 file changed, 16 insertions(+), 10 deletions(-)

diff --git a/makefile.shade b/makefile.shade
index 69afd3fa4ac..438c90f1473 100644
--- a/makefile.shade
+++ b/makefile.shade
@@ -169,6 +169,9 @@ var buildTarget = "compile"
         var universeArtifacts = Path.Combine(Directory.GetCurrentDirectory(), "artifacts");
         var universeBuild = Path.Combine(universeArtifacts, "build");
         var packagesPublishDir = Path.Combine(Directory.GetCurrentDirectory(), ".nuget", "publishDir");
+        // Historically we've always produced coherent builds using this target. Unless specified otherwise,
+        // we'll continue to produce coherent builds here.
+        var createCoherentBuild = Environment.GetEnvironmentVariable("CREATE_COHERENT_BUILD") != "false";
 
         // Snapshot the .build folder
         if (!IsLinux)
@@ -193,18 +196,21 @@ var buildTarget = "compile"
         }
 
         Directory.CreateDirectory(universeBuild);
-        if (!IsLinux)
+        if (createCoherentBuild)
         {
-            // Publish to a directory and use that as a package source for later builds. This doesn't work in Linux due to
-            // https://github.com/NuGet/Home/issues/2383
+            if (!IsLinux)
+            {
+                // Publish to a directory and use that as a package source for later builds. This doesn't work in Linux due to
+                // https://github.com/NuGet/Home/issues/2383
 
-            Directory.CreateDirectory(packagesPublishDir);
-            Environment.SetEnvironmentVariable("NUGET_VOLATILE_FEED_ARTIFACTS", packagesPublishDir);
-            Environment.SetEnvironmentVariable("PACKAGES_PUBLISH_DIR", packagesPublishDir);
-        }
-        else
-        {
-            Environment.SetEnvironmentVariable("NUGET_VOLATILE_FEED_ARTIFACTS", universeBuild);
+                Directory.CreateDirectory(packagesPublishDir);
+                Environment.SetEnvironmentVariable("NUGET_VOLATILE_FEED_ARTIFACTS", packagesPublishDir);
+                Environment.SetEnvironmentVariable("PACKAGES_PUBLISH_DIR", packagesPublishDir);
+            }
+            else
+            {
+                Environment.SetEnvironmentVariable("NUGET_VOLATILE_FEED_ARTIFACTS", universeBuild);
+            }
         }
 
         foreach (var batch in batchedRepos)
-- 
GitLab