aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Mensching <rob@firegiant.com>2024-07-13 00:28:18 -0700
committerRob Mensching <rob@firegiant.com>2024-10-04 12:53:20 -0700
commit123c7f022b5a5acd1a0ddcc8b38e21fe2e128462 (patch)
tree85b77702c8e283c36cc9f624650ce97545e23fda
parentd474b56ced25cabfacda8efea1e61f13644abd23 (diff)
downloadwix-123c7f022b5a5acd1a0ddcc8b38e21fe2e128462.tar.gz
wix-123c7f022b5a5acd1a0ddcc8b38e21fe2e128462.tar.bz2
wix-123c7f022b5a5acd1a0ddcc8b38e21fe2e128462.zip
Reset current directory so SFXCA directory can be cleaned up
Fixes 8630
-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>