diff options
author | Rob Mensching <rob@firegiant.com> | 2024-07-13 00:28:18 -0700 |
---|---|---|
committer | Rob Mensching <rob@firegiant.com> | 2024-07-15 15:21:20 -0700 |
commit | b5de0c02c811549d5e15bfc209a1fa9c1f1744d2 (patch) | |
tree | 3a945491279844cc59e98be3aaecd2d2b75ee932 | |
parent | ae8a1ba12b3ab3c7c3e7a8c8f69afff40b98310d (diff) | |
download | wix-b5de0c02c811549d5e15bfc209a1fa9c1f1744d2.tar.gz wix-b5de0c02c811549d5e15bfc209a1fa9c1f1744d2.tar.bz2 wix-b5de0c02c811549d5e15bfc209a1fa9c1f1744d2.zip |
Reset current directory so SFXCA directory can be cleaned up
Fixes 8630
-rw-r--r-- | src/dtf/WixToolset.Dtf.WindowsInstaller/CustomActionProxy.cs | 19 |
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 f58ff07d..fca15dbc 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> |