public override bool Execute() { Log.LogMessage(MessageImportance.Low, $"Task {nameof (AcceptAndroidSdkLicenses)}"); Log.LogMessage(MessageImportance.Low, $" {nameof (AndroidSdkDirectory)}: {AndroidSdkDirectory}"); Log.LogMessage(MessageImportance.Low, $" {nameof (JavaSdkDirectory)}: {JavaSdkDirectory}"); var licdir = Path.Combine(Path.Combine(AndroidSdkDirectory, "licenses")); Directory.CreateDirectory(licdir); if (!string.IsNullOrEmpty(JavaSdkDirectory)) { Environment.SetEnvironmentVariable("JAVA_HOME", JavaSdkDirectory); } string _; var path = Which.GetProgramLocation("sdkmanager", out _, new [] { Path.Combine(AndroidSdkDirectory, "tools", "bin") }); var psi = new ProcessStartInfo(path, "--licenses") { UseShellExecute = false, RedirectStandardInput = true }; var proc = Process.Start(psi); for (int i = 0; i < 10; i++) { proc.StandardInput.WriteLine('y'); } proc.WaitForExit(); return(true); }
void SetSudo() { if (!UseSudo || string.Equals("Windows", HostOS, StringComparison.OrdinalIgnoreCase)) { return; } Sudo = "sudo "; if (!string.Equals("Darwin", HostOS, StringComparison.OrdinalIgnoreCase)) { return; } string brewFilename; var brewPath = Which.GetProgramLocation("brew", out brewFilename); if (string.IsNullOrEmpty(brewPath)) { return; } var brewVersion = Which.GetProgramVersion(HostOS, $"{brewPath} --version"); if (brewVersion < new Version(1, 1)) { SudoBrew = "sudo "; return; } }
protected override string GenerateFullPathToTool() { var dirs = string.IsNullOrEmpty(ToolPath) ? null : new [] { ToolPath }; string filename; var path = Which.GetProgramLocation(ToolBaseName, out filename, dirs); return(path); }
public override bool Execute() { var licdir = Path.Combine(Path.Combine(AndroidSdkDirectory, "licenses")); Directory.CreateDirectory(licdir); string _; var path = Which.GetProgramLocation("sdkmanager", out _, new [] { Path.Combine(AndroidSdkDirectory, "tools", "bin") }); var psi = new ProcessStartInfo(path, "--licenses") { UseShellExecute = false, RedirectStandardInput = true }; var proc = Process.Start(psi); for (int i = 0; i < 10; i++) { proc.StandardInput.WriteLine('y'); } proc.WaitForExit(); return(true); }