protected override void OnExecute (IProgressMonitor monitor, ExecutionContext context, ConfigurationSelector configSel) { var conf = (IPhoneProjectConfiguration) GetConfiguration (configSel); bool isDevice = conf.IsDevicePlatform; if (!Directory.Exists (conf.AppDirectory) || (isDevice && !File.Exists (conf.AppDirectory.Combine ("PkgInfo")))) { Gtk.Application.Invoke (delegate { MessageService.ShowError (GettextCatalog.GetString ("The application has not been built.")); }); return; } if (isDevice) { var deviceId = "default"; if (NeedsUploading (conf, deviceId)) { using (var opMon = new AggregatedOperationMonitor (monitor)) { using (var op = IPhoneUtility.Upload (TargetRuntime, TargetFramework, conf.AppDirectory)) { opMon.AddOperation (op); op.WaitForCompleted (); if (op.ExitCode != 0) return; } TouchUploadMarker (conf, deviceId); } } } base.OnExecute (monitor, context, configSel); }
protected override void OnExecute(IProgressMonitor monitor, ExecutionContext context, ConfigurationSelector configSel) { var conf = (IPhoneProjectConfiguration)GetConfiguration(configSel); if (!Directory.Exists(conf.AppDirectory)) { Gtk.Application.Invoke(delegate { MessageService.ShowError(GettextCatalog.GetString("The application has not been built.")); }); return; } if (conf.Platform == PLAT_IPHONE) { if (NeedsUploading(conf)) { using (var opMon = new AggregatedOperationMonitor(monitor)) { using (var op = IPhoneUtility.Upload(TargetRuntime, TargetFramework, conf.AppDirectory)) { opMon.AddOperation(op); op.WaitForCompleted(); if (op.ExitCode != 0) { return; } } TouchUploadMarker(conf); } } } base.OnExecute(monitor, context, configSel); }
protected override void Run() { if (IPhoneFramework.SimOnly) { IPhoneFramework.ShowSimOnlyDialog(); return; } var proj = GetActiveExecutableIPhoneProject(); var conf = (IPhoneProjectConfiguration)proj.GetConfiguration(IdeApp.Workspace.ActiveConfiguration); if (!IdeApp.Preferences.BuildBeforeExecuting) { IPhoneUtility.Upload(proj.TargetRuntime, proj.TargetFramework, conf.AppDirectory); return; } IdeApp.ProjectOperations.Build(proj).Completed += delegate(IAsyncOperation op) { if (!op.Success || (op.SuccessWithWarnings && !IdeApp.Preferences.RunWithWarnings)) { return; } IPhoneUtility.Upload(proj.TargetRuntime, proj.TargetFramework, conf.AppDirectory); }; }
public IProcessAsyncOperation Execute(ExecutionCommand command, IConsole console) { IPhoneExecutionCommand cmd = (IPhoneExecutionCommand)command; if (!cmd.Simulator) { if (IPhoneSettings.ShowStartOnDeviceMessage) { Gtk.Application.Invoke(delegate { TellUserToStartApplication(); }); } return(NullProcessAsyncOperation.Success); } var psi = CreateMtouchSimStartInfo(cmd, true, SimulatorTarget ?? cmd.SimulatorTarget);; psi.RedirectStandardOutput = true; psi.RedirectStandardError = true; psi.RedirectStandardInput = true; LineInterceptingTextWriter intercepter = null; intercepter = new LineInterceptingTextWriter(null, delegate { if (intercepter.GetLine().StartsWith("Application launched")) { IPhoneUtility.MakeSimulatorGrabFocus(); intercepter.FinishedIntercepting = true; } else if (intercepter.LineCount > 20) { intercepter.FinishedIntercepting = true; } }); var outTail = new Tail(cmd.OutputLogPath, console.Out.Write); var errTail = new Tail(cmd.ErrorLogPath, console.Error.Write); outTail.Start(); errTail.Start(); var mtouchProcess = Runtime.ProcessService.StartProcess(psi, intercepter, console.Log, null); return(new IPhoneProcess(mtouchProcess, outTail, errTail)); }
void GenerateXCodeProject(IPhoneProject proj, IPhoneProjectConfiguration conf, ConfigurationSelector slnConf) { string mtouchPath = IPhoneUtility.GetMtouchPath(proj.TargetRuntime, proj.TargetFramework); var xcodeDir = conf.OutputDirectory.Combine("XcodeProject"); if (!Directory.Exists(xcodeDir)) { try { Directory.CreateDirectory(xcodeDir); } catch (IOException ex) { MessageService.ShowException(ex, "Failed to create directory '" + xcodeDir + "' for Xcode project"); return; } } var args = new System.Text.StringBuilder(); args.AppendFormat("-xcode=\"{0}\" -v", xcodeDir); foreach (ProjectFile pf in proj.Files) { if (pf.BuildAction == BuildAction.Content) { var rel = pf.ProjectVirtualPath; args.AppendFormat(" -res=\"{0}\",\"{1}\"", pf.FilePath, rel); //hack around mtouch 1.0 bug. create resource directories string subdir = rel.ParentDirectory; if (string.IsNullOrEmpty(subdir)) { continue; } subdir = xcodeDir.Combine(subdir); try { if (!Directory.Exists(subdir)) { Directory.CreateDirectory(subdir); } } catch (IOException ex) { MessageService.ShowException(ex, "Failed to create directory '" + subdir + "' for Xcode project"); return; } } else if (pf.BuildAction == BuildAction.Page) { args.AppendFormat(" -res=\"{0}\"", pf.FilePath); } } args.AppendFormat(" -res=\"{0}\",\"Info.plist\"", conf.AppDirectory.Combine("Info.plist")); foreach (string asm in proj.GetReferencedAssemblies(slnConf).Distinct()) { args.AppendFormat(" -r=\"{0}\"", asm); } IPhoneBuildExtension.AppendExtrasMtouchArgs(args, proj, conf); args.AppendFormat(" \"{0}\"", conf.CompiledOutputName); string argStr = args.ToString(); var console = (IConsole)IdeApp.Workbench.ProgressMonitors.GetOutputProgressMonitor( GettextCatalog.GetString("Generate Xcode project"), MonoDevelop.Ide.Gui.Stock.RunProgramIcon, true, true); console.Log.WriteLine(mtouchPath + " " + argStr); Runtime.ProcessService.StartConsoleProcess(mtouchPath, argStr, conf.OutputDirectory, console, null); }