aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Mensching <rob@firegiant.com>2024-07-13 00:28:18 -0700
committerRob Mensching <rob@firegiant.com>2024-07-13 08:37:35 -0700
commit590c667a1ecd97a79056daf44dc75bdc7580cb9a (patch)
treedaf9ad0476cdacb9a04f08e3f8be556fdf9233cf
parent40df304afe43fcd546b5b817bcad63168ee31813 (diff)
downloadwix-590c667a1ecd97a79056daf44dc75bdc7580cb9a.tar.gz
wix-590c667a1ecd97a79056daf44dc75bdc7580cb9a.tar.bz2
wix-590c667a1ecd97a79056daf44dc75bdc7580cb9a.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 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>