Skip to content

Commit

Permalink
Reset current directory so SFXCA directory can be cleaned up
Browse files Browse the repository at this point in the history
Fixes 8630
  • Loading branch information
robmen committed Jul 13, 2024
1 parent 40df304 commit 590c667
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/dtf/WixToolset.Dtf.WindowsInstaller/CustomActionProxy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,13 @@ public static int InvokeCustomAction(int sessionHandle, string entryPoint,
return (int) ActionResult.Failure;
}

string originalDirectory = null;

try
{
// Remember the original directory so we can restore it later.
originalDirectory = Environment.CurrentDirectory;

// Set the current directory to the location of the extracted files.
Environment.CurrentDirectory =
AppDomain.CurrentDomain.BaseDirectory;
Expand Down Expand Up @@ -142,6 +147,20 @@ public static int InvokeCustomAction(int sessionHandle, string entryPoint,
session.Log(ex.ToString());
return (int) ActionResult.Failure;
}
finally
{
try
{
if (!String.IsNullOrEmpty(originalDirectory))
{
Environment.CurrentDirectory = originalDirectory;
}
}
catch (Exception ex)
{
session.Log("Failed to restore current directory after running custom action: {0}", ex.Message);
}
}
}

/// <summary>
Expand Down

0 comments on commit 590c667

Please sign in to comment.