@joebigelow / wix / commits / 590c667a

Reset current directory so SFXCA directory can be cleaned up

Fixes 8630

Rob Mensching committed Jul 13, 2024 at 00:28 UTC 590c667a1ecd97a79056daf44dc75bdc7580cb9a
1 file changed +19
src/dtf/WixToolset.Dtf.WindowsInstaller/CustomActionProxy.cs
+19
@@ -101,8 +101,13 @@ namespace WixToolset.Dtf.WindowsInstaller
101 return (int) ActionResult.Failure;
102 }
103
104 + string originalDirectory = null;
105 +
106 try
107 {
108 + // Remember the original directory so we can restore it later.
109 + originalDirectory = Environment.CurrentDirectory;
110 +
111 // Set the current directory to the location of the extracted files.
112 Environment.CurrentDirectory =
113 AppDomain.CurrentDomain.BaseDirectory;
@@ -142,6 +147,20 @@ namespace WixToolset.Dtf.WindowsInstaller
147 session.Log(ex.ToString());
148 return (int) ActionResult.Failure;
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 + }
164 }
165
166 /// <summary>