From 65da9423beacd76d2c5ef60e4ca0306daac49f14 Mon Sep 17 00:00:00 2001
From: skaryshev <garbage4sergey@hotmail.com>
Date: Wed, 13 Jan 2016 15:26:13 -0800
Subject: [PATCH] MSI fix

---
 src/Squirrel/Utility.cs | 3 ++-
 src/Update/Program.cs   | 4 ++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/Squirrel/Utility.cs b/src/Squirrel/Utility.cs
index a0ea19cb2..2b693ff9a 100644
--- a/src/Squirrel/Utility.cs
+++ b/src/Squirrel/Utility.cs
@@ -177,7 +177,7 @@ public static T Retry<T>(this Func<T> block, int retries = 2)
             }
         }
 
-        public static Task<Tuple<int, string>> InvokeProcessAsync(string fileName, string arguments, CancellationToken ct)
+        public static Task<Tuple<int, string>> InvokeProcessAsync(string fileName, string arguments, CancellationToken ct, string workingDirectory = null)
         {
             var psi = new ProcessStartInfo(fileName, arguments);
             if (Environment.OSVersion.Platform != PlatformID.Win32NT && fileName.EndsWith (".exe", StringComparison.OrdinalIgnoreCase)) {
@@ -190,6 +190,7 @@ public static Task<Tuple<int, string>> InvokeProcessAsync(string fileName, strin
             psi.CreateNoWindow = true;
             psi.RedirectStandardOutput = true;
             psi.RedirectStandardError = true;
+            psi.WorkingDirectory = workingDirectory;
 
             return InvokeProcessAsync(psi, ct);
         }
diff --git a/src/Update/Program.cs b/src/Update/Program.cs
index 4d57dc94d..d6adde95e 100644
--- a/src/Update/Program.cs
+++ b/src/Update/Program.cs
@@ -663,7 +663,7 @@ static async Task createMsiPackage(string setupExe, IPackage package)
 
             var candleParams = String.Format("-nologo -ext WixNetFxExtension -out \"{0}\" \"{1}\"", wxsTarget.Replace(".wxs", ".wixobj"), wxsTarget);
             var processResult = await Utility.InvokeProcessAsync(
-                Path.Combine(pathToWix, "candle.exe"), candleParams, CancellationToken.None);
+                Path.Combine(pathToWix, "candle.exe"), candleParams, CancellationToken.None, setupExeDir);
 
             if (processResult.Item1 != 0) {
                 var msg = String.Format(
@@ -675,7 +675,7 @@ static async Task createMsiPackage(string setupExe, IPackage package)
 
             var lightParams = String.Format("-ext WixNetFxExtension -sval -out \"{0}\" \"{1}\"", wxsTarget.Replace(".wxs", ".msi"), wxsTarget.Replace(".wxs", ".wixobj"));
             processResult = await Utility.InvokeProcessAsync(
-                Path.Combine(pathToWix, "light.exe"), lightParams, CancellationToken.None);
+                Path.Combine(pathToWix, "light.exe"), lightParams, CancellationToken.None, setupExeDir);
 
             if (processResult.Item1 != 0) {
                 var msg = String.Format(