aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/dtf/WixToolset.Dtf.WindowsInstaller/CustomActionProxy.cs19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/dtf/WixToolset.Dtf.WindowsInstaller/CustomActionProxy.cs b/src/dtf/WixToolset.Dtf.WindowsInstaller/CustomActionProxy.cs
index d3fd7d1b..ae2673ca 100644
--- a/src/dtf/WixToolset.Dtf.WindowsInstaller/CustomActionProxy.cs
+++ b/src/dtf/WixToolset.Dtf.WindowsInstaller/CustomActionProxy.cs
@@ -101,8 +101,13 @@ namespace WixToolset.Dtf.WindowsInstaller
101 return (int) ActionResult.Failure; 101 return (int) ActionResult.Failure;
102 } 102 }
103 103
104 string originalDirectory = null;
105
104 try 106 try
105 { 107 {
108 // Remember the original directory so we can restore it later.
109 originalDirectory = Environment.CurrentDirectory;
110
106 // Set the current directory to the location of the extracted files. 111 // Set the current directory to the location of the extracted files.
107 Environment.CurrentDirectory = 112 Environment.CurrentDirectory =
108 AppDomain.CurrentDomain.BaseDirectory; 113 AppDomain.CurrentDomain.BaseDirectory;
@@ -142,6 +147,20 @@ namespace WixToolset.Dtf.WindowsInstaller
142 session.Log(ex.ToString()); 147 session.Log(ex.ToString());
143 return (int) ActionResult.Failure; 148 return (int) ActionResult.Failure;
144 } 149 }
150 finally
151 {
152 try
153 {
154 if (!String.IsNullOrEmpty(originalDirectory))
155 {
156 Environment.CurrentDirectory = originalDirectory;
157 }
158 }
159 catch (Exception ex)
160 {
161 session.Log("Failed to restore current directory after running custom action: {0}", ex.Message);
162 }
163 }
145 } 164 }
146 165
147 /// <summary> 166 /// <summary>