private static string FindIOSDeploy() { var shellArgs = new ShellProcessArguments { Executable = "ls", Arguments = new[] { iOSDeployFolder }, ThrowOnError = false }; var output = ShellProcess.Run(shellArgs); var versionStr = "0.0.0"; if (output.ExitCode == 0) { var versions = output.FullOutput.Split('\n'); foreach (var v in versions) { if (v.Length > 0 && (new System.Version(v)).CompareTo(new System.Version(versionStr)) > 0) { versionStr = v; } } } if (versionStr == "0.0.0") { throw new Exception($"iOS deploy is required in order to install and launch the app, to install it simply run \"brew install ios-deploy\""); } return($"{iOSDeployFolder}/{versionStr}/bin/ios-deploy"); }
public static void Main() { foreach (ProcessComponent pc in ShellProcess.Make()) { Console.WriteLine(pc); } }
internal override ShellProcessOutput RunTestMode(string exeName, string workingDirPath, int timeout) { var app = $"{workingDirPath}/{exeName}{ExecutableExtension}"; if (!Directory.Exists(app)) { throw new Exception($"Couldn't find iOS app at: {app} "); } using (var progress = new BuildProgress("Running the iOS app", "Please wait...")) { var shellArgs = new ShellProcessArguments { Executable = FindIOSDeploy(), Arguments = new[] { "--noninteractive", "--debug", "--uninstall", "--bundle", app }, WorkingDirectory = new DirectoryInfo(workingDirPath) }; if (timeout > 0) { shellArgs.MaxIdleTimeInMilliseconds = timeout; shellArgs.MaxIdleKillIsAnError = false; } return(ShellProcess.Run(shellArgs)); } }
/// <summary> /// The main entry point to this program. /// </summary> public static void Main() { ProcessComponent p = ShellProcess.Make(); PrettyVisitor v = new PrettyVisitor(); Console.WriteLine(v.GetPretty(p)); }
private ShellProcessOutput InstallApk(string apkName, string buildDir) { return(ShellProcess.Run(new ShellProcessArguments() { ThrowOnError = false, Executable = AdbPath, Arguments = new string[] { "install", "\"" + apkName + "\"" }, WorkingDirectory = new DirectoryInfo(buildDir) })); }
private static Process StartPosixSocketBridgeProcess() { var shellArgs = new ShellProcessArguments { Executable = SocketBridgeExecutable, Arguments = new [] { "6690" }, }; var posixSocketBridgeProcess = ShellProcess.Start(shellArgs); return(posixSocketBridgeProcess.Process); }
public static ShellProcess RunShellProcess(ShellProcess shProcess) { if (LOGGER.IsDebugEnabled) { LOGGER.DebugFormat("Running Command: {0} {1}", shProcess.ProcStartInfo.FileName, shProcess.ProcStartInfo.Arguments); } shProcess.Run(); return shProcess; }
public static void Main() { CompositeEnumerator e = (CompositeEnumerator)ShellProcess.Make().GetEnumerator(); while (e.MoveNext()) { for (int i = 0; i < e.Depth(); i++) { Console.Write(" "); } Console.WriteLine(e.Current); } }
internal static ShellProcessOutput RunTestMode(ShellProcessArguments shellArgs, string workingDirPath, int timeout) { shellArgs.WorkingDirectory = new DirectoryInfo(workingDirPath); shellArgs.ThrowOnError = false; // samples should be killed on timeout if (timeout > 0) { shellArgs.MaxIdleTimeInMilliseconds = timeout; shellArgs.MaxIdleKillIsAnError = false; } return(ShellProcess.Run(shellArgs)); }
private ShellProcessOutput LaunchApp(string buildDir) { return(ShellProcess.Run(new ShellProcessArguments() { ThrowOnError = false, Executable = AdbPath, Arguments = new string[] { "shell", "am", "start", "-a", "android.intent.action.MAIN", "-c", "android.intent.category.LAUNCHER", "-f", "0x10200000", "-S", "-n", $"{PackageName}/com.unity3d.tinyplayer.UnityTinyActivity" }, WorkingDirectory = new DirectoryInfo(buildDir) })); }
public override bool Run(FileInfo buildTarget) { var buildDir = buildTarget.Directory.FullName; var result = UninstallApp(buildTarget.FullName, buildDir); if (ExportSettings?.TargetType == AndroidTargetType.AndroidAppBundle) { result = BuildApks(buildTarget.FullName, buildDir); // bundletool might write to stderr even if there are no errors if (result.ExitCode != 0) { throw new Exception($"Cannot build APKS : {result.FullOutput}"); } result = InstallApks(buildDir); if (result.ExitCode != 0) { throw new Exception($"Cannot install APKS : {result.FullOutput}"); } } else { result = InstallApk(buildTarget.FullName, buildDir); if (!result.FullOutput.Contains("Success")) { throw new Exception($"Cannot install APK : {result.FullOutput}"); } } result = LaunchApp(buildDir); // killing adb to unlock build folder ShellProcess.Run(new ShellProcessArguments() { ThrowOnError = false, Executable = AdbPath, Arguments = new string[] { "kill-server" } }); if (result.Succeeded) { return(true); } else { throw new Exception($"Cannot launch APK : {result.FullOutput}"); } }
private ShellProcessOutput InstallApks(string buildDir) { var apksName = GetApksName(buildDir); return(ShellProcess.Run(new ShellProcessArguments() { ThrowOnError = false, Executable = JavaPath, Arguments = new string[] { "-jar", $"\"{BundleToolJar}\"", "install-apks", $"--apks=\"{apksName}\"", $"--adb=\"{AdbPath}\"" }, WorkingDirectory = new DirectoryInfo(buildDir) })); }
private ShellProcessOutput BuildApks(string aabName, string buildDir) { var apksName = GetApksName(buildDir); //TODO check for mutliple device installing string keystorePassFile = null; string keyaliasPassFile = null; if (UseKeystore) { keystorePassFile = Path.Combine(buildDir, "keystore.pass"); keyaliasPassFile = Path.Combine(buildDir, "keyalias.pass"); File.WriteAllText(keystorePassFile, Keystore.KeystorePass); File.WriteAllText(keyaliasPassFile, Keystore.KeyaliasPass); } var result = ShellProcess.Run(new ShellProcessArguments() { ThrowOnError = false, Executable = JavaPath, Arguments = new string[] { "-jar", $"\"{BundleToolJar}\"", "build-apks", $"--bundle=\"{aabName}\"", $"--output=\"{apksName}\"", "--overwrite", (UseKeystore ? $"--ks=\"{Keystore.KeystoreFullPath}\" --ks-pass=file:\"{keystorePassFile}\" --ks-key-alias=\"{Keystore.KeyaliasName}\" --key-pass=file:\"{keyaliasPassFile}\"" : "") }, WorkingDirectory = new DirectoryInfo(buildDir) }); if (UseKeystore) { File.Delete(keystorePassFile); File.Delete(keyaliasPassFile); } return(result); }
private ShellProcessOutput UninstallApp(string apkName, string buildDir) { // checking that app is already installed var result = ShellProcess.Run(new ShellProcessArguments() { ThrowOnError = false, Executable = AdbPath, Arguments = new string[] { "shell", "pm", "list", "packages", PackageName }, WorkingDirectory = new DirectoryInfo(buildDir) }); if (result.FullOutput.Contains(PackageName)) { // uninstall previous version, it may be signed with different key, so re-installing is not possible result = ShellProcess.Run(new ShellProcessArguments() { ThrowOnError = false, Executable = AdbPath, Arguments = new string[] { "uninstall", PackageName }, WorkingDirectory = new DirectoryInfo(buildDir) }); } return(result); }
static IEnumerator <BeeProgressInfo> Run(string arguments, StringBuilder command, StringBuilder output, DirectoryInfo workingDirectory = null) { var beeExe = Path.GetFullPath($"{Constants.DotsRuntimePackagePath}/bee~/bee.exe"); var executable = beeExe; arguments = "--no-colors " + arguments; #if !UNITY_EDITOR_WIN arguments = "\"" + executable + "\" " + arguments; executable = Path.Combine(UnityEditor.EditorApplication.applicationContentsPath, "MonoBleedingEdge/bin/mono"); #endif command.Append(executable); command.Append(" "); command.Append(arguments); var progressInfo = new BeeProgressInfo() { Progress = 0.0f, Info = null }; void ProgressHandler(object sender, DataReceivedEventArgs args) { if (string.IsNullOrWhiteSpace(args.Data)) { return; } var match = BeeProgressRegex.Match(args.Data); if (match.Success) { var num = match.Groups["nominator"].Value; var den = match.Groups["denominator"].Value; if (int.TryParse(num, out var numInt) && int.TryParse(den, out var denInt)) { progressInfo.Progress = (float)numInt / denInt; } progressInfo.Info = ShortenAnnotation(match.Groups["annotation"].Value); } var busyMatch = BeeBusyRegex.Match(args.Data); if (busyMatch.Success) { progressInfo.Info = ShortenAnnotation(busyMatch.Groups["annotation"].Value); } progressInfo.FullInfo = args.Data; lock (output) { output.AppendLine(args.Data); } } var config = new ShellProcessArguments() { Executable = executable, Arguments = new[] { arguments }, WorkingDirectory = workingDirectory, #if !UNITY_EDITOR_WIN // bee requires external programs to perform build actions EnvironmentVariables = new Dictionary <string, string>() { { "PATH", string.Join(":", Path.Combine(UnityEditor.EditorApplication.applicationContentsPath, "MonoBleedingEdge/bin"), "/bin", "/usr/bin", "/usr/local/bin") } }, #else EnvironmentVariables = null, #endif OutputDataReceived = ProgressHandler, ErrorDataReceived = ProgressHandler }; var bee = ShellProcess.Start(config); progressInfo.Process = bee; yield return(progressInfo); const int maxBuildTimeInMs = 30 * 60 * 1000; // 30 minutes var statusEnum = bee.WaitForProcess(maxBuildTimeInMs); while (statusEnum.MoveNext()) { yield return(progressInfo); } progressInfo.Progress = 1.0f; progressInfo.IsDone = true; progressInfo.ExitCode = bee.Process.ExitCode; progressInfo.Info = "Build completed"; yield return(progressInfo); }
/// <summary> /// Test liczenia etapów dla procesu produkcji petardy powietrznej. /// </summary> public void TestShell() { Assertion.AssertEquals(4, ShellProcess.Make().GetStepCount()); }
public int Release(ShellProcess process) { process.Close(); return(process.ExitCode); }
internal override ShellProcessOutput RunTestMode(string exeName, string workingDirPath, int timeout) { var executable = $"{workingDirPath}/{exeName}{ExecutableExtension}"; var output = UninstallApp(executable, workingDirPath); if (ExportSettings?.TargetType == AndroidTargetType.AndroidAppBundle) { output = BuildApks(executable, workingDirPath); // bundletool might write to stderr even if there are no errors if (output.ExitCode != 0) { return(output); } output = InstallApks(workingDirPath); if (output.ExitCode != 0) { return(output); } } else { output = InstallApk(executable, workingDirPath); if (!output.FullOutput.Contains("Success")) { return(output); } } // clear logcat ShellProcess.Run(new ShellProcessArguments() { ThrowOnError = false, Executable = AdbPath, Arguments = new string[] { "logcat", "-c" }, WorkingDirectory = new DirectoryInfo(workingDirPath) }); output = LaunchApp(workingDirPath); System.Threading.Thread.Sleep(timeout == 0 ? 2000 : timeout); // to kill process anyway, // should be rewritten to support tests which quits after execution // killing on timeout ShellProcess.Run(new ShellProcessArguments() { ThrowOnError = false, Executable = AdbPath, Arguments = new string[] { "shell", "am", "force-stop", PackageName }, WorkingDirectory = new DirectoryInfo(workingDirPath) }); // get logcat output = ShellProcess.Run(new ShellProcessArguments() { ThrowOnError = false, Executable = AdbPath, Arguments = new string[] { "logcat", "-d" }, WorkingDirectory = new DirectoryInfo(workingDirPath) }); if (timeout == 0) // non-sample test, TODO invent something better { output.Succeeded = output.FullOutput.Contains("Test suite: SUCCESS"); } return(output); }
public void TestShell() { Assert.AreEqual(4, ShellProcess.Make().GetStepCount()); }