Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[xibuild] Clean up temporary files when done. #7508

Merged
merged 2 commits into from
Dec 3, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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