From 7f7413b3ebb780b77e20111299b7f7c20cd25ed3 Mon Sep 17 00:00:00 2001
From: Nate McMaster <nate.mcmaster@microsoft.com>
Date: Thu, 19 Jan 2017 16:51:13 -0800
Subject: [PATCH] Workaround issue in solution targets in MSBuild RC3

---
 graph.proj     |  7 +++++++
 makefile.shade | 14 +++++++++++---
 2 files changed, 18 insertions(+), 3 deletions(-)
 create mode 100644 graph.proj

diff --git a/graph.proj b/graph.proj
new file mode 100644
index 00000000000..c436c08d236
--- /dev/null
+++ b/graph.proj
@@ -0,0 +1,7 @@
+<!-- workaround https://github.com/Microsoft/msbuild/issues/1587 -->
+<Project>
+    <ItemGroup>
+        <RestoreGraphProjectInputItems Include="$(RepoDir)\**\*.csproj" />
+    </ItemGroup>
+    <Import Project="$(MSBuildToolsPath)\NuGet.targets" />
+</Project>
\ No newline at end of file
diff --git a/makefile.shade b/makefile.shade
index 7e5695cbc2a..fd09db22366 100644
--- a/makefile.shade
+++ b/makefile.shade
@@ -918,9 +918,15 @@ functions
         {
             public static MsBuildSolutionInfo LoadFromFile(string file)
             {
-                var info = new MsBuildSolutionInfo()
+                if (!Path.IsPathRooted(file))
                 {
-                    FilePath = file
+                    file = Path.Combine(System.IO.Directory.GetCurrentDirectory(), file);
+                }
+
+                var info = new MsBuildSolutionInfo
+                {
+                    FilePath = file,
+                    Directory = Path.GetDirectoryName(file)
                 };
 
                 var lines = File.ReadAllLines(file);
@@ -942,6 +948,7 @@ functions
             }
 
             public string FilePath { get; private set; }
+            public string Directory { get; private set; }
 
             public Version VisualStudioVersion { get; set; }
 
@@ -1054,7 +1061,8 @@ functions
                 {
                     UseShellExecute = false,
                     FileName = "dotnet",
-                    Arguments = "msbuild \"" + solution.FilePath + "\" /nologo /t:GenerateRestoreGraphFile \"/p:RestoreGraphOutputPath=" + dgJson + "\""
+                    // TODO revert to invoking on .sln file when https://github.com/Microsoft/msbuild/issues/1587 is resolve
+                    Arguments = "msbuild \"" + Path.Combine(Directory.GetCurrentDirectory(), "graph.proj") + "\" /v:q /p:WarningLevel=0 /p:RepoDir=\"" + solution.Directory + "\" /nologo /t:GenerateRestoreGraphFile \"/p:RestoreGraphOutputPath=" + dgJson + "\""
                 };
                 var p = Process.Start(psi);
                 p.WaitForExit();
-- 
GitLab