Skip to content

Commit

Permalink
[xibuild] Clean up temporary files when done. (dotnet#7508)
Browse files Browse the repository at this point in the history
  • Loading branch information
rolfbjarne authored Dec 3, 2019
1 parent cdfc36e commit 4586171
Showing 1 changed file with 23 additions and 17 deletions.
40 changes: 23 additions & 17 deletions tools/xibuild/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,23 +115,29 @@ static int RunTool (string toolPath, string combinedArgs, string baseConfigFile)
{
var tmpMSBuildExePathForConfig = Path.GetTempFileName ();
var configFilePath = tmpMSBuildExePathForConfig + ".config";

GenerateAppConfig (configFilePath, baseConfigFile, out string MSBuildSdksPath);

var psi = new ProcessStartInfo {
FileName = toolPath,
Arguments = combinedArgs,
UseShellExecute = false,
};
// Required so that msbuild can read the correct config file
psi.EnvironmentVariables ["MSBUILD_EXE_PATH"] = tmpMSBuildExePathForConfig;
// MSBuildSDKsPath only works via an env var
psi.EnvironmentVariables ["MSBuildSDKsPath"] = MSBuildSdksPath;

var p = Process.Start (psi);

p.WaitForExit ();
return p.ExitCode;
try {
GenerateAppConfig (configFilePath, baseConfigFile, out string MSBuildSdksPath);

var psi = new ProcessStartInfo {
FileName = toolPath,
Arguments = combinedArgs,
UseShellExecute = false,
};
// Required so that msbuild can read the correct config file
psi.EnvironmentVariables ["MSBUILD_EXE_PATH"] = tmpMSBuildExePathForConfig;
// MSBuildSDKsPath only works via an env var
psi.EnvironmentVariables ["MSBuildSDKsPath"] = MSBuildSdksPath;

var p = Process.Start (psi);

p.WaitForExit ();
return p.ExitCode;
} finally {
if (File.Exists (tmpMSBuildExePathForConfig))
File.Delete (tmpMSBuildExePathForConfig);
if (File.Exists (tmpMSBuildExePathForConfig))
File.Delete (configFilePath);
}
}

static void GenerateAppConfig (string targetConfigFile, string baseConfigFile, out string MSBuildSdksPath)
Expand Down

0 comments on commit 4586171

Please sign in to comment.