protected override string GenerateCommandLineCommands()
        {
            var prefixes     = BundleResource.SplitResourcePrefixes(ResourcePrefix);
            var intermediate = Path.Combine(IntermediateOutputPath, ToolName);
            var logicalName  = BundleResource.GetLogicalName(ProjectDir, prefixes, SourceFile, !string.IsNullOrEmpty(SessionId));
            var path         = Path.Combine(intermediate, logicalName);
            var args         = new ProcessArgumentBuilder();
            var dir          = Path.GetDirectoryName(path);

            if (!Directory.Exists(dir))
            {
                Directory.CreateDirectory(dir);
            }

            OutputFile = new TaskItem(Path.ChangeExtension(path, ".air"));
            OutputFile.SetMetadata("LogicalName", Path.ChangeExtension(logicalName, ".air"));

            args.Add("-arch", "air64");
            args.Add("-emit-llvm");
            args.Add("-c");
            args.Add("-gline-tables-only");
            args.Add("-ffast-math");
            args.Add(string.Format("-std={0}-metal1.0", OperatingSystem));

            args.Add("-serialize-diagnostics");
            args.AddQuoted(Path.ChangeExtension(path, ".dia"));

            args.Add("-o");
            args.AddQuoted(Path.ChangeExtension(path, ".air"));

            args.AddQuoted(SourceFile.ItemSpec);

            return(args.ToString());
        }
Exemple #2
0
        internal string GetArguments(ScaffolderArgs args)
        {
            var argBuilder = new ProcessArgumentBuilder();

            argBuilder.Add("aspnet-codegenerator");
            argBuilder.Add("--project");
            argBuilder.AddQuoted(project.FileName);
            argBuilder.Add(args.Scaffolder.CommandLineName);

            foreach (var field in args.Scaffolder.Fields)
            {
                argBuilder.Add(field.CommandLineName);
                argBuilder.Add(field.SelectedValue);
            }

            argBuilder.Add("--no-build");
            argBuilder.Add("-outDir");
            argBuilder.AddQuoted(parentFolder);

            foreach (var arg in args.Scaffolder.DefaultArgs)
            {
                argBuilder.Add(arg.ToString());
            }

            return(argBuilder.ToString());
        }
        static ProcessArgumentBuilder Build7ZipExtractionArgs(string file, string contentDir, string user7ZipPath, bool ignoreTarSymLinks)
        {
            var args = new ProcessArgumentBuilder(Get7ZipPath(user7ZipPath));

            //if it's a tgz, we have a two-step extraction. for the gzipped layer, extract without paths
            if (file.EndsWith(".gz", StringComparison.OrdinalIgnoreCase) || file.EndsWith(".tgz", StringComparison.OrdinalIgnoreCase))
            {
                args.Add("e");
            }
            else
            {
                args.Add("x");
            }

            // Symbolic Links give us problems.  You need to run as admin to extract them.
            // Adding this flag will ignore links
            if (ignoreTarSymLinks)
            {
                args.Add("-snl-");
            }

            args.AddQuoted("-o" + contentDir);
            args.AddQuoted(file);
            return(args);
        }
Exemple #4
0
        string GenerateCommandLineArguments(string dylib)
        {
            var args = new ProcessArgumentBuilder();

            args.Add("-v");
            args.Add("--force");

            args.Add("--sign");
            args.AddQuoted(SigningKey);

            if (!string.IsNullOrEmpty(Keychain))
            {
                args.Add("--keychain");
                args.AddQuoted(Path.GetFullPath(Keychain));
            }

            if (DisableTimestamp)
            {
                args.Add("--timestamp=none");
            }

            if (!string.IsNullOrEmpty(ExtraArgs))
            {
                args.Add(ExtraArgs);
            }

            args.AddQuoted(dylib);

            return(args.ToString());
        }
Exemple #5
0
        protected override string GenerateCommandLineCommands()
        {
            var args = new ProcessArgumentBuilder();

            if (Recursive)
            {
                args.Add("-r");
            }

            if (Symlinks)
            {
                args.Add("-y");
            }

            args.AddQuoted(OutputFile.GetMetadata("FullPath"));

            var root = WorkingDirectory.GetMetadata("FullPath");

            for (int i = 0; i < Sources.Length; i++)
            {
                var relative = PathUtils.AbsoluteToRelative(root, Sources[i].GetMetadata("FullPath"));
                args.AddQuoted(relative);
            }

            return(args.ToString());
        }
Exemple #6
0
		public static BuildResult CompileXibFiles (IProgressMonitor monitor, IEnumerable<ProjectFile> files,
		                                           FilePath outputRoot)
		{
			var result = new BuildResult ();
			var ibfiles = GetIBFilePairs (files, outputRoot).Where (NeedsBuilding).ToList ();
			
			if (ibfiles.Count > 0) {
				monitor.BeginTask (GettextCatalog.GetString ("Compiling interface definitions"), 0);	
				foreach (var file in ibfiles) {
					file.EnsureOutputDirectory ();
					var args = new ProcessArgumentBuilder ();
					args.AddQuoted (file.Input);
					args.Add ("--compile");
					args.AddQuoted (file.Output);
					var psi = new ProcessStartInfo ("ibtool", args.ToString ());
					monitor.Log.WriteLine (psi.FileName + " " + psi.Arguments);
					psi.WorkingDirectory = outputRoot;
					string errorOutput;
					int code;
					try {
					code = ExecuteCommand (monitor, psi, out errorOutput);
					} catch (System.ComponentModel.Win32Exception ex) {
						LoggingService.LogError ("Error running ibtool", ex);
						result.AddError (null, 0, 0, null, "ibtool not found. Please ensure the Apple SDK is installed.");
						return result;
					}
					if (code != 0) {
						//FIXME: parse the plist that ibtool returns
						result.AddError (null, 0, 0, null, "ibtool returned error code " + code);
					}
				}
				monitor.EndTask ();
			}
			return result;
		}
Exemple #7
0
        static Process StartPowerShellHost()
        {
            var programPath = Path.Combine(Path.GetDirectoryName(typeof(RemotePowerShellHost).Assembly.Location), "PowerShellConsoleHost", "MonoDevelop.PackageManagement.PowerShell.ConsoleHost.dll");

            var argumentBuilder = new ProcessArgumentBuilder();

            argumentBuilder.AddQuoted(programPath);
            argumentBuilder.AddQuoted(UserProfile.Current.LogDir);

            var info = new ProcessStartInfo {
                FileName               = DotNetCoreRuntime.FileName,
                Arguments              = argumentBuilder.ToString(),
                WorkingDirectory       = Path.GetDirectoryName(programPath),
                UseShellExecute        = false,
                RedirectStandardInput  = true,
                RedirectStandardOutput = true
            };

            var process = new Process {
                StartInfo = info
            };

            process.Start();

            return(process);
        }
        int Compile(ITaskItem item, string outputDir, string log, string partialPlist)
        {
            var environment = new Dictionary <string, string> ();
            var args        = new ProcessArgumentBuilder();

            args.Add("compile");
            args.AddQuoted(item.ItemSpec);
            args.AddQuoted(Path.GetFullPath(outputDir));
            args.Add("--output-partial-info-plist");
            args.AddQuoted(partialPlist);

            var startInfo = GetProcessStartInfo(environment, GetFullPathToTool(), args.ToString());
            var errors    = new StringBuilder();
            int exitCode;

            try {
                Log.LogMessage(MessageImportance.Normal, "Tool {0} execution started with arguments: {1}", startInfo.FileName, startInfo.Arguments);

                using (var stdout = File.CreateText(log)) {
                    using (var stderr = new StringWriter(errors)) {
                        using (var process = ProcessUtils.StartProcess(startInfo, stdout, stderr)) {
                            process.Wait();

                            exitCode = process.Result;
                        }
                    }

                    Log.LogMessage(MessageImportance.Low, "Tool {0} execution finished (exit code = {1}).", startInfo.FileName, exitCode);
                }
            } catch (Exception ex) {
                Log.LogError("Error executing tool '{0}': {1}", startInfo.FileName, ex.Message);
                File.Delete(log);
                return(-1);
            }

            if (exitCode != 0)
            {
                // Note: coremlc exited with an error. Dump everything we can to help the user
                // diagnose the issue and then delete the log file so that rebuilding tries
                // again.
                if (errors.Length > 0)
                {
                    Log.LogError(null, null, null, item.ItemSpec, 0, 0, 0, 0, "{0}", errors);
                }

                Log.LogError("{0} exited with code {1}", ToolName, exitCode);

                // Note: If the log file exists, log those warnings/errors as well...
                if (File.Exists(log))
                {
                    Log.LogError(null, null, null, item.ItemSpec, 0, 0, 0, 0, "{0}", File.ReadAllText(log));
                    File.Delete(log);
                }
            }

            return(exitCode);
        }
Exemple #9
0
        protected override string GenerateCommandLineCommands()
        {
            var args = new ProcessArgumentBuilder();

            args.Add("-rsrc");

            args.AddQuoted(Source.ItemSpec);
            args.AddQuoted(Destination.ItemSpec);

            return(args.ToString());
        }
        public IProcessAsyncOperation AlignPackage(string srcApk, string destApk, TextWriter outputLog, TextWriter errorLog)
        {
            var args = new ProcessArgumentBuilder();

            args.Add("-f");
            args.Add("4");
            args.AddQuoted(srcApk);
            args.AddQuoted(destApk);

            return(StartProcess(ZipAlignExe, args.ToString(), outputLog, errorLog));
        }
Exemple #11
0
        protected override string GenerateCommandLineCommands()
        {
            var args = new ProcessArgumentBuilder ();

            args.Add ("-rsrc");

            args.AddQuoted (Source.ItemSpec);
            args.AddQuoted (Destination.ItemSpec);

            return args.ToString ();
        }
Exemple #12
0
        protected override string GenerateCommandLineCommands()
        {
            var args = new ProcessArgumentBuilder();

            args.Add("--compress");
            args.AddQuoted(InputScene);
            args.Add("-o");
            args.AddQuoted(OutputScene);
            args.AddQuotedFormat("--sdk-root={0}", SdkRoot);
            args.AddQuotedFormat("--target-version-{0}={1}", OperatingSystem, SdkVersion);
            args.AddQuotedFormat("--target-build-dir={0}", IntermediateOutputPath);

            return(args.ToString());
        }
        public IProcessAsyncOperation VerifyKeypair(AndroidSigningOptions options, TextWriter outputLog, TextWriter errorLog)
        {
            var args = new ProcessArgumentBuilder();

            args.Add("-list");
            args.Add("-keystore");
            args.AddQuoted(options.KeyStore);
            args.Add("-storepass");
            args.AddQuoted(options.StorePass);
            args.Add("-alias");
            args.AddQuoted(options.KeyAlias);

            return(StartProcess(KeytoolExe, args.ToString(), outputLog, errorLog));
        }
        public StartAvdOperation StartAvd(AndroidVirtualDevice avd)
        {
            var args = new ProcessArgumentBuilder();

            args.Add("-partition-size", "512", "-avd");
            args.AddQuoted(avd.Name);
            args.Add("-prop");
            args.AddQuoted("monodroid.avdname=" + avd.Name);

            var error   = new StringWriter();
            var process = StartProcess(EmulatorExe, args.ToString(), null, error);

            return(new StartAvdOperation(process, error));
        }
Exemple #15
0
        protected override string GenerateCommandLineCommands()
        {
            var args = new ProcessArgumentBuilder();

            args.Add("-r");
            args.AddQuoted(Archive.ItemSpec);

            foreach (var item in Items)
            {
                args.AddQuoted(item.ItemSpec);
            }

            return(args.ToString());
        }
        public BuildResult Build(IProgressMonitor monitor, ConfigurationSelector configuration)
        {
            BuildResult results = new BuildResult("", 0, 0);

            string moFileName  = GetOutFile(configuration);
            string moDirectory = Path.GetDirectoryName(moFileName);

            if (!Directory.Exists(moDirectory))
            {
                Directory.CreateDirectory(moDirectory);
            }

            var pb = new ProcessArgumentBuilder();

            pb.AddQuoted(PoFile);
            pb.Add("-o");
            pb.AddQuoted(moFileName);

            ProcessWrapper process = null;

            try
            {
                process = Runtime.ProcessService.StartProcess(GetTool("msgfmt"), pb.ToString(),
                                                              parentProject.BaseDirectory, monitor.Log, monitor.Log, null);
            }
            catch (System.ComponentModel.Win32Exception)
            {
                var msg = GettextCatalog.GetString("Did not find msgfmt. Please ensure that gettext tools are installed.");
                monitor.ReportError(msg, null);
                results.AddError(msg);
                return(results);
            }

            process.WaitForOutput();

            if (process.ExitCode == 0)
            {
                monitor.Log.WriteLine(GettextCatalog.GetString("Translation {0}: Compilation succeeded.", IsoCode));
            }
            else
            {
                string message = GettextCatalog.GetString("Translation {0}: Compilation failed. See log for details.", IsoCode);
                monitor.Log.WriteLine(message);
                results.AddError(PoFile, 1, 1, "", message);
                results.FailedBuildCount = 1;
            }
            return(results);
        }
        protected override void AppendCommandLineArguments(IDictionary <string, string> environment, ProcessArgumentBuilder args, ITaskItem[] items)
        {
            environment.Add("IBSC_MINIMUM_COMPATIBILITY_VERSION", minimumDeploymentTarget);
            environment.Add("IBC_MINIMUM_COMPATIBILITY_VERSION", minimumDeploymentTarget);

            if (AppleSdkSettings.XcodeVersion.Major >= 5)
            {
                args.Add("--minimum-deployment-target", minimumDeploymentTarget);
            }

            foreach (var targetDevice in GetTargetDevices(plist))
            {
                args.Add("--target-device", targetDevice);
            }

            if (AppleSdkSettings.XcodeVersion.Major >= 6 && AutoActivateCustomFonts)
            {
                args.Add("--auto-activate-custom-fonts");
            }

            if (!string.IsNullOrEmpty(SdkRoot))
            {
                args.Add("--sdk");
                args.AddQuoted(SdkRoot);
            }
        }
        public static ProcessWrapper StartMSBuild(string arguments, string workingDirectory, TextWriter outWriter, TextWriter errorWriter, EventHandler exited)
        {
            FilePath msbuildBinPath = GetMSBuildBinPath();
            string   command        = null;

            if (Platform.IsWindows)
            {
                command = msbuildBinPath;
            }
            else
            {
                command = GetMonoPath();
                var argumentsBuilder = new ProcessArgumentBuilder();
                argumentsBuilder.AddQuoted(msbuildBinPath);
                argumentsBuilder.Add(arguments);
                arguments = argumentsBuilder.ToString();
            }

            return(Runtime.ProcessService.StartProcess(
                       command,
                       arguments,
                       workingDirectory,
                       outWriter,
                       errorWriter,
                       exited));
        }
        public IProcessAsyncOperation SignPackage(AndroidSigningOptions options, string unsignedApk,
                                                  string signedApk, TextWriter outputLog, TextWriter errorLog)
        {
            var args = new ProcessArgumentBuilder();

            args.Add("-keystore");
            args.AddQuoted(options.KeyStore);
            args.Add("-storepass");
            args.AddQuoted(options.StorePass);
            args.Add("-keypass");
            args.AddQuoted(options.KeyPass);
            args.Add("-signedjar");
            args.AddQuoted(signedApk, unsignedApk, options.KeyAlias);

            return(StartProcess(JarsignerExe, args.ToString(), outputLog, errorLog));
        }
        string GenerateCommandLineArguments(ITaskItem item)
        {
            var args = new ProcessArgumentBuilder();

            args.Add("-v");
            args.Add("--force");

            if (IsAppExtension)
            {
                args.Add("--deep");
            }

            args.Add("--sign");
            args.AddQuoted(SigningKey);

            if (!string.IsNullOrEmpty(Keychain))
            {
                args.Add("--keychain");
                args.AddQuoted(Path.GetFullPath(Keychain));
            }

            if (!string.IsNullOrEmpty(ResourceRules))
            {
                args.Add("--resource-rules");
                args.AddQuoted(Path.GetFullPath(ResourceRules));
            }

            if (!string.IsNullOrEmpty(Entitlements))
            {
                args.Add("--entitlements");
                args.AddQuoted(Path.GetFullPath(Entitlements));
            }

            if (DisableTimestamp)
            {
                args.Add("--timestamp=none");
            }

            if (!string.IsNullOrEmpty(ExtraArgs))
            {
                args.Add(ExtraArgs);
            }

            args.AddQuoted(Path.GetFullPath(item.ItemSpec));

            return(args.ToString());
        }
Exemple #21
0
        static ProcessArgumentBuilder BuildTgzExtractionArgs(string file, string contentDir)
        {
            var args = new ProcessArgumentBuilder("/usr/bin/tar");

            args.Add("-x", "-f");
            args.AddQuoted(file);
            return(args);
        }
Exemple #22
0
        static ProcessArgumentBuilder BuildZipExtractionArgs(string file, string contentDir)
        {
            var args = new ProcessArgumentBuilder("/usr/bin/unzip");

            args.Add("-o", "-q");
            args.AddQuoted(file);
            return(args);
        }
Exemple #23
0
        static ProcessArgumentBuilder Build7ZipExtractionArgs(string file, string contentDir, string user7ZipPath)
        {
            var args = new ProcessArgumentBuilder(Get7ZipPath(user7ZipPath));

            //if it's a tgz, we have a two-step extraction. for the gzipped layer, extract without paths
            if (file.EndsWith(".gz", StringComparison.OrdinalIgnoreCase) || file.EndsWith(".tgz", StringComparison.OrdinalIgnoreCase))
            {
                args.Add("e");
            }
            else
            {
                args.Add("x");
            }
            args.AddQuoted("-o" + contentDir);
            args.AddQuoted(file);
            return(args);
        }
        int CopySceneKitAssets(string scnassets, string output, string intermediate)
        {
            var environment = new Dictionary <string, string> ();
            var args        = new ProcessArgumentBuilder();

            environment.Add("PATH", DeveloperRootBinDir);
            environment.Add("DEVELOPER_DIR", SdkDevPath);
            environment.Add("XCODE_DEVELOPER_USR_PATH", DeveloperRootBinDir);

            args.AddQuoted(Path.GetFullPath(scnassets));
            args.Add("-o");
            args.AddQuoted(Path.GetFullPath(output));
            args.AddQuotedFormat("--sdk-root={0}", SdkRoot);
            args.AddQuotedFormat("--target-version-{0}={1}", OperatingSystem, SdkVersion);
            args.AddQuotedFormat("--target-build-dir={0}", Path.GetFullPath(intermediate));

            var startInfo = GetProcessStartInfo(environment, GetFullPathToTool(), args.ToString());

            try {
                using (var process = new Process()) {
                    Log.LogMessage(MessageImportance.Normal, "Tool {0} execution started with arguments: {1}", startInfo.FileName, startInfo.Arguments);

                    process.StartInfo           = startInfo;
                    process.OutputDataReceived += (sender, e) => {
                        if (e.Data == null)
                        {
                            return;
                        }

                        Log.LogMessage(MessageImportance.Low, "{0}", e.Data);
                    };

                    process.Start();
                    process.BeginOutputReadLine();
                    process.WaitForExit();

                    Log.LogMessage(MessageImportance.Low, "Tool {0} execution finished.", startInfo.FileName);

                    return(process.ExitCode);
                }
            } catch (Exception ex) {
                Log.LogError("Error executing tool '{0}': {1}", startInfo.FileName, ex.Message);
                return(-1);
            }
        }
        public IProcessAsyncOperation Uninstall(AndroidDevice device, string package, TextWriter outputLog, TextWriter errorLog)
        {
            var args = new ProcessArgumentBuilder();

            args.Add("-s", device.ID, "uninstall");
            args.AddQuoted(package);

            return(StartProcess(AdbExe, args.ToString(), outputLog, errorLog));
        }
        public static BuildResult CompileXibFiles(IProgressMonitor monitor, IEnumerable <ProjectFile> files,
                                                  FilePath outputRoot)
        {
            var result  = new BuildResult();
            var ibfiles = GetIBFilePairs(files, outputRoot).Where(NeedsBuilding).ToList();

            if (ibfiles.Count > 0)
            {
                monitor.BeginTask(GettextCatalog.GetString("Compiling interface definitions"), 0);
                foreach (var file in ibfiles)
                {
                    file.EnsureOutputDirectory();
                    var args = new ProcessArgumentBuilder();
                    args.Add("--errors", "--warnings", "--notices", "--output-format", "human-readable-text");
                    args.AddQuoted(file.Input);
                    args.Add("--compile");
                    args.AddQuoted(file.Output);
                    var ibtoolPath = AppleSdkSettings.DeveloperRoot.Combine("usr", "bin", "ibtool");
                    var psi        = new ProcessStartInfo(ibtoolPath, args.ToString());
                    monitor.Log.WriteLine(psi.FileName + " " + psi.Arguments);
                    int code;
                    try {
                        code = MacBuildUtilities.ExecuteBuildCommand(monitor, psi);
                    } catch (System.ComponentModel.Win32Exception ex) {
                        LoggingService.LogError("Error running ibtool", ex);
                        result.AddError(null, 0, 0, null, "ibtool not found. Please ensure the Apple SDK is installed.");
                        return(result);
                    }
                    if (monitor.IsCancelRequested)
                    {
                        return(result);
                    }

                    if (code != 0)
                    {
                        result.AddError(null, 0, 0, null, "ibtool returned error code " + code);
                        return(result);
                    }
                }
                monitor.EndTask();
            }
            return(result);
        }
            public override void Launch(params string[] files)
            {
                var pab = new ProcessArgumentBuilder();

                foreach (string file in files)
                {
                    pab.AddQuoted(file);
                    Process.Start(ExePath, pab.ToString());
                }
            }
        public IProcessAsyncOperation PullFile(AndroidDevice device, string source, string destination,
                                               TextWriter outputLog, TextWriter errorLog)
        {
            var args = new ProcessArgumentBuilder();

            args.Add("-s", device.ID, "pull");
            args.AddQuoted(source, destination);

            return(StartProcess(AdbExe, args.ToString(), outputLog, errorLog));
        }
Exemple #29
0
        protected override string GenerateCommandLineCommands()
        {
            var args = new ProcessArgumentBuilder();

            args.Add("-v");
            args.Add("--force");

            if (IsAppExtension)
            {
                args.Add("--deep");
            }

            args.Add("--sign");
            args.AddQuoted(SigningKey);

            if (!string.IsNullOrEmpty(Keychain))
            {
                args.Add("--keychain");
                args.AddQuoted(Path.GetFullPath(Keychain));
            }

            if (!string.IsNullOrEmpty(ResourceRules))
            {
                args.Add("--resource-rules");
                args.AddQuoted(Path.GetFullPath(ResourceRules));
            }

            if (!string.IsNullOrEmpty(Entitlements))
            {
                args.Add("--entitlements");
                args.AddQuoted(Path.GetFullPath(Entitlements));
            }

            if (!string.IsNullOrEmpty(ExtraArgs))
            {
                args.Add(ExtraArgs);
            }

            args.AddQuoted(Path.GetFullPath(Resource));

            return(args.ToString());
        }
Exemple #30
0
        protected override string GenerateCommandLineCommands()
        {
            var args = new ProcessArgumentBuilder ();

            if (Recursive)
                args.Add ("-r");

            if (Symlinks)
                args.Add ("-y");

            args.AddQuoted (OutputFile.GetMetadata ("FullPath"));

            var root = WorkingDirectory.GetMetadata ("FullPath");
            for (int i = 0; i < Sources.Length; i++) {
                var relative = PathUtils.AbsoluteToRelative (root, Sources[i].GetMetadata ("FullPath"));
                args.AddQuoted (relative);
            }

            return args.ToString ();
        }
        // Note: Xamarin.Mac and Xamarin.iOS should both override this method to do pass platform-specific verify rules
        protected override string GenerateCommandLineCommands()
        {
            var args = new ProcessArgumentBuilder();

            args.Add("--verify");
            args.Add("-vvvv");

            args.AddQuoted(Resource);

            return(args.ToString());
        }
Exemple #32
0
        protected override string GenerateCommandLineCommands()
        {
            var args = new ProcessArgumentBuilder();

            args.Add("--verify");
            args.Add("-vvvv");
            args.Add("-R='anchor apple generic and certificate 1[field.1.2.840.113635.100.6.2.1] exists and (certificate leaf[field.1.2.840.113635.100.6.1.2] exists or certificate leaf[field.1.2.840.113635.100.6.1.4] exists)'");

            args.AddQuoted(Resource);

            return(args.ToString());
        }
        public InstallPackageOperation Install(AndroidDevice device, string package, TextWriter outputLog, TextWriter errorLog)
        {
            var args = new ProcessArgumentBuilder();

            args.Add("-s", device.ID, "install");
            args.AddQuoted(package);

            var errorCapture = new StringWriter();
            var errorWriter  = TeeTextWriter.ForNonNull(errorCapture, errorCapture);

            return(new InstallPackageOperation(StartProcess(AdbExe, args.ToString(), outputLog, errorWriter), errorCapture));
        }
		protected override BuildResult Build (IProgressMonitor monitor, SolutionEntityItem item, ConfigurationSelector configuration)
		{
			IPhoneProject proj = item as IPhoneProject;
			if (proj == null || proj.CompileTarget != CompileTarget.Exe)
				return base.Build (monitor, item, configuration);
			
			//prebuild
			var conf = (IPhoneProjectConfiguration) proj.GetConfiguration (configuration);
			bool isDevice = conf.Platform == IPhoneProject.PLAT_IPHONE;
			
			if (IPhoneFramework.SimOnly && isDevice) {
				//if in the GUI, show a dialog too
				if (MonoDevelop.Ide.IdeApp.IsInitialized)
					Gtk.Application.Invoke (delegate { IPhoneFramework.ShowSimOnlyDialog (); } );
				return IPhoneFramework.GetSimOnlyError ();
			}
			
			var result = new BuildResult ();
			
			var sdkVersion = conf.MtouchSdkVersion.ResolveIfDefault ();
			
			if (!IPhoneFramework.SdkIsInstalled (sdkVersion)) {
				sdkVersion = IPhoneFramework.GetClosestInstalledSdk (sdkVersion);
				
				if (sdkVersion.IsUseDefault || !IPhoneFramework.SdkIsInstalled (sdkVersion)) {
					if (conf.MtouchSdkVersion.IsUseDefault)
						result.AddError (
							string.Format ("The Apple iPhone SDK is not installed."));
					else
						result.AddError (
							string.Format ("Apple iPhone SDK version '{0}' is not installed, and no newer version was found.",
							conf.MtouchSdkVersion));
					return result;
				}
					
				result.AddWarning (
					string.Format ("Apple iPhone SDK version '{0}' is not installed. Using newer version '{1}' instead'.",
					conf.MtouchSdkVersion, sdkVersion));
			}
			
			IPhoneAppIdentity identity = null;
			if (isDevice) {
				monitor.BeginTask (GettextCatalog.GetString ("Detecting signing identity..."), 0);
				if ((result = GetIdentity (monitor, proj, conf, out identity).Append (result)).ErrorCount > 0)
					return result;
				monitor.Log.WriteLine ("Provisioning profile: \"{0}\" ({1})", identity.Profile.Name, identity.Profile.Uuid);
				monitor.Log.WriteLine ("Signing Identity: \"{0}\"", Keychain.GetCertificateCommonName (identity.SigningKey));
				monitor.Log.WriteLine ("App ID: \"{0}\"", identity.AppID);
				monitor.EndTask ();
			} else {
				identity = new IPhoneAppIdentity () {
					BundleID = !string.IsNullOrEmpty (proj.BundleIdentifier)?
						proj.BundleIdentifier : GetDefaultBundleID (proj, null)
				};
			}
			
			result = base.Build (monitor, item, configuration).Append (result);
			if (result.ErrorCount > 0)
				return result;
			
			if (!Directory.Exists (conf.AppDirectory))
				Directory.CreateDirectory (conf.AppDirectory);
			
			var assemblyRefs = proj.GetReferencedAssemblies (configuration).Distinct ().ToList ();
			
			FilePath mtouchOutput = conf.NativeExe;
			if (new FilePair (conf.CompiledOutputName, mtouchOutput).NeedsBuilding ()) {
				BuildResult error;
				var mtouch = GetMTouch (proj, monitor, out error);
				if (error != null)
					return error.Append (result);
				
				var args = new ProcessArgumentBuilder ();
				//FIXME: make verbosity configurable?
				args.Add ("-v");
				
				args.Add ("--nomanifest", "--nosign");
					
				//FIXME: should we error out if the platform is invalid?
				if (conf.Platform == IPhoneProject.PLAT_IPHONE) {
					args.Add ("-dev");
					args.AddQuoted (conf.AppDirectory);
				} else {
					args.Add ("-sim");
					args.AddQuoted (conf.AppDirectory);
				}
				
				foreach (string asm in assemblyRefs)
					args.AddQuotedFormat ("-r={0}", asm);
				
				AppendExtrasMtouchArgs (args, sdkVersion, proj, conf);
				
				args.AddQuoted (conf.CompiledOutputName);
				
				mtouch.WorkingDirectory = conf.OutputDirectory;
				mtouch.Arguments = args.ToString ();
				
				monitor.BeginTask (GettextCatalog.GetString ("Compiling to native code"), 0);
				
				string output;
				int code;
				monitor.Log.WriteLine ("{0} {1}", mtouch.FileName, mtouch.Arguments);
				if ((code = MacBuildUtilities.ExecuteCommand (monitor, mtouch, out output)) != 0) {
					if (String.IsNullOrEmpty (output)) {
						result.AddError (null, 0, 0, code.ToString (), "mtouch failed with no output");
					} else {
						result.AddError (null, 0, 0, code.ToString (), "mtouch failed with the following message:\n" + output);
					}
					return result;
				}
				
				monitor.EndTask ();
			}
			
			if (result.Append (UnpackContent (monitor, conf, assemblyRefs)).ErrorCount > 0)
				return result;
			
			//create the info.plist, merging in the template if it exists
			var plistOut = conf.AppDirectory.Combine ("Info.plist");
			ProjectFile appInfoIn = proj.Files.GetFile (proj.BaseDirectory.Combine ("Info.plist"));
			if (new FilePair (proj.FileName, plistOut).NeedsBuilding () ||
			    	(appInfoIn != null && new FilePair (appInfoIn.FilePath, plistOut).NeedsBuilding ())) {
				try {
					monitor.BeginTask (GettextCatalog.GetString ("Updating application manifest"), 0);
					if (result.Append (UpdateInfoPlist (monitor, sdkVersion, proj, conf, identity, appInfoIn, plistOut)).ErrorCount > 0)
						return result;
				} finally {
					monitor.EndTask ();
				}
			}
			
			//create the Setting.bundle plist for debug settings, merging in the template if it exists
			try {
				monitor.BeginTask (GettextCatalog.GetString ("Updating debug settings manifest"), 0);
				var sbRootRel = Path.Combine ("Settings.bundle", "Root.plist");
				var sbRootOut = conf.AppDirectory.Combine (sbRootRel);
				var sbRootIn  = proj.Files.GetFile (proj.BaseDirectory.Combine (sbRootRel));
				if (result.Append (UpdateDebugSettingsPlist (monitor, conf, sbRootIn, sbRootOut)).ErrorCount > 0)
					return result;
			} finally {
				monitor.EndTask ();
			}
			
			try {
				if (result.Append (ProcessPackaging (monitor, sdkVersion, proj, conf, identity)).ErrorCount > 0)
					return result;
			} finally {
				//if packaging failed, make sure that it's marked as needing building
				if (result.ErrorCount > 0 && File.Exists (conf.AppDirectory.Combine ("PkgInfo")))
					File.Delete (conf.AppDirectory.Combine ("PkgInfo"));	
			}	
			
			//TODO: create/update the xcode project
			return result;
		}
Exemple #35
0
        protected override string GenerateCommandLineCommands()
        {
            var args = new ProcessArgumentBuilder ();

            args.Add ("--compress");
            args.AddQuoted (InputScene);
            args.Add ("-o");
            args.AddQuoted (OutputScene);
            args.AddQuotedFormat ("--sdk-root={0}", SdkRoot);
            args.AddQuotedFormat ("--target-version-{0}={1}", OperatingSystem, SdkVersion);
            args.AddQuotedFormat ("--target-build-dir={0}", IntermediateOutputPath);

            return args.ToString ();
        }
Exemple #36
0
		public IProcessAsyncOperation PullFile (AndroidDevice device, string source, string destination,
			TextWriter outputLog, TextWriter errorLog)
		{
			var args = new ProcessArgumentBuilder ();
			args.Add ("-s", device.ID, "pull");
			args.AddQuoted (source, destination);
			
			return StartProcess (AdbExe, args.ToString (), outputLog, errorLog);
		}
Exemple #37
0
		public InstallPackageOperation Install (AndroidDevice device, string package, TextWriter outputLog, TextWriter errorLog)
		{
			var args = new ProcessArgumentBuilder ();
			args.Add ("-s", device.ID, "install");
			args.AddQuoted (package);
			
			var errorCapture = new StringWriter ();
			var errorWriter = TeeTextWriter.ForNonNull (errorCapture, errorCapture);
			return new InstallPackageOperation (StartProcess (AdbExe, args.ToString (), outputLog, errorWriter), errorCapture);
		}
		public IProcessAsyncOperation AlignPackage (string srcApk, string destApk, TextWriter outputLog, TextWriter errorLog)
		{
			var args = new ProcessArgumentBuilder ();
			args.Add ("-f");
			args.Add ("4");
			args.AddQuoted (srcApk);
			args.AddQuoted (destApk);

			return StartProcess (ZipAlignExe, args.ToString (), outputLog, errorLog);
		}
Exemple #39
0
		public IProcessAsyncOperation SetProperty (AndroidDevice device, string property, string value, TextWriter outputLog, TextWriter errorLog)
		{
			if (property == null)
				throw new ArgumentNullException ("property");
			if (value == null)
				throw new ArgumentNullException ("value");
			
			var args = new ProcessArgumentBuilder ();
			args.Add ("-s", device.ID, "shell", "setprop");
			args.AddQuoted (property, value);
			
			return StartProcess (AdbExe, args.ToString (), outputLog, errorLog);
		}
Exemple #40
0
		public IProcessAsyncOperation StartActivity (AndroidDevice device, string activity,
			ProcessEventHandler outputLog, ProcessEventHandler errorLog)
		{
			var args = new ProcessArgumentBuilder ();
			args.Add ("-s", device.ID, "shell", "am", "start", "-a", "android.intent.action.MAIN", "-n");
			args.AddQuoted (activity);
			
			return StartProcess (AdbExe, args.ToString (), outputLog, errorLog);
		}
Exemple #41
0
		public IProcessAsyncOperation Uninstall (AndroidDevice device, string package, TextWriter outputLog, TextWriter errorLog)
		{
			var args = new ProcessArgumentBuilder ();
			args.Add ("-s", device.ID, "uninstall");
			args.AddQuoted (package);
			
			return StartProcess (AdbExe, args.ToString (), outputLog, errorLog);
		}
Exemple #42
0
		public IProcessAsyncOperation SignPackage (AndroidSigningOptions options, string unsignedApk,
			string signedApk, TextWriter outputLog, TextWriter errorLog)
		{
			var args = new ProcessArgumentBuilder ();
			args.Add ("-keystore");
			args.AddQuoted (options.KeyStore);
			args.Add ("-storepass");
			args.AddQuoted (options.StorePass);
			args.Add ("-keypass");
			args.AddQuoted (options.KeyPass);
			args.Add ("-signedjar");
			args.AddQuoted (signedApk, unsignedApk, options.KeyAlias);
			
			return StartProcess (JarsignerExe, args.ToString (), outputLog, errorLog);
		}
Exemple #43
0
		public StartAvdOperation StartAvd (AndroidVirtualDevice avd)
		{
			var args = new ProcessArgumentBuilder ();
			args.Add ("-partition-size", "512", "-avd");
			args.AddQuoted (avd.Name);
			args.Add ("-prop");
			args.AddQuoted ("monodroid.avdname=" + avd.Name);

			var error = new StringWriter ();
			var process = StartProcess (EmulatorExe, args.ToString (), null, error);
			return new StartAvdOperation (process, error);
		}
		static BuildResult SignAppBundle (IProgressMonitor monitor, IPhoneProject proj, IPhoneProjectConfiguration conf,
		                           X509Certificate2 key, string resRules, string xcent)
		{
			monitor.BeginTask (GettextCatalog.GetString ("Signing application"), 0);
			
			var args = new ProcessArgumentBuilder ();
			args.Add ("-v", "-f", "-s");
			args.AddQuoted (Keychain.GetCertificateCommonName (key));
			args.AddQuotedFormat ("--resource-rules={0}", resRules);
			args.Add ("--entitlements");
			args.AddQuoted (xcent);
			args.AddQuoted (conf.AppDirectory);
			
			AddExtraArgs (args, conf.CodesignExtraArgs, proj, conf);
				
			int signResultCode;
			var psi = new ProcessStartInfo ("codesign") {
				UseShellExecute = false,
				RedirectStandardError = true,
				RedirectStandardOutput = true,
				Arguments = args.ToString (),
			};
			
			monitor.Log.WriteLine ("codesign " + psi.Arguments);
			psi.EnvironmentVariables.Add ("CODESIGN_ALLOCATE",
				"/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate");
			string output;
			if ((signResultCode = MacBuildUtilities.ExecuteCommand (monitor, psi, out output)) != 0) {
				monitor.Log.WriteLine (output);
				return BuildError (string.Format ("Code signing failed with error code {0}. See output for details.", signResultCode));
			}
			monitor.EndTask ();
			
			return null;
		}
Exemple #45
0
        protected override string GenerateCommandLineCommands()
        {
            var args = new ProcessArgumentBuilder ();

            args.Add ("-v");
            args.Add ("--force");
            args.Add ("--sign");
            args.AddQuoted (SigningKey);

            if (!string.IsNullOrEmpty (Keychain)) {
                args.Add ("--keychain");
                args.AddQuoted (Path.GetFullPath (Keychain));
            }

            if (!string.IsNullOrEmpty (ResourceRules)) {
                args.Add ("--resource-rules");
                args.AddQuoted (Path.GetFullPath (ResourceRules));
            }

            if (!string.IsNullOrEmpty (Entitlements)) {
                args.Add ("--entitlements");
                args.AddQuoted (Path.GetFullPath (Entitlements));
            }

            if (!string.IsNullOrEmpty (ExtraArgs))
                args.Add (ExtraArgs);

            args.AddQuoted (Path.GetFullPath (Resource));

            return args.ToString ();
        }
Exemple #46
0
		//string dname = "CN=Android Debug,O=Android,C=US";
		public IProcessAsyncOperation Genkeypair (AndroidSigningOptions options, string dname,
			TextWriter outputLog, TextWriter errorLog)
		{
			var args = new ProcessArgumentBuilder ();
			args.Add ("-genkeypair");
			args.Add ("-alias");
			args.AddQuoted (options.KeyAlias);
			args.Add ("-dname");
			args.AddQuoted (dname);
			args.Add ("-storepass");
			args.AddQuoted (options.StorePass);
			args.Add ("-keypass");
			args.AddQuoted (options.KeyPass);
			args.Add ("-keystore");
			args.AddQuoted (options.KeyStore);
			
			return StartProcess (KeytoolExe, args.ToString (), outputLog, errorLog);
		}
		static bool BuildPackage (IProgressMonitor monitor, MonoMacProject project,
			ConfigurationSelector conf, MonoMacPackagingSettings settings, FilePath target)
		{
			string bundleKey = settings.BundleSigningKey;
			string packageKey = settings.PackageSigningKey;
			
			if (settings.SignBundle || settings.SignPackage) {
				var identities = Keychain.GetAllSigningIdentities ();
				
				if (string.IsNullOrEmpty (bundleKey)) {
					bundleKey = identities.FirstOrDefault (k => k.StartsWith (MonoMacPackagingSettingsWidget.APPLICATION_PREFIX));
					if (string.IsNullOrEmpty (bundleKey)) {
						monitor.ReportError ("Did not find default app signing key", null);
						return false;
					} else if (!identities.Any (k => k == bundleKey)) {
						monitor.ReportError ("Did not find app signing key in keychain", null);
						return false;
					}
				}
				
				if (string.IsNullOrEmpty (packageKey)) {
					packageKey = identities.FirstOrDefault (k => k.StartsWith (MonoMacPackagingSettingsWidget.INSTALLER_PREFIX));
					if (string.IsNullOrEmpty (packageKey)) {
						monitor.ReportError ("Did not find default package signing key", null);
						return false;
					} else if (!identities.Any (k => k == packageKey)) {
						monitor.ReportError ("Did not find package signing key in keychain", null);
						return false;
					}
				}
			}
			
			if (project.NeedsBuilding (conf)) {
				BuildResult res = project.Build (monitor, conf);
				if (res.ErrorCount > 0) {
					foreach (BuildError e in res.Errors)
						monitor.ReportError (e.ToString (), null);
					monitor.ReportError (GettextCatalog.GetString ("The project failed to build."), null);
					return false;
				}
			}
			
			var cfg = (MonoMacProjectConfiguration) project.GetConfiguration (conf);
			
			FilePath tempDir = "/tmp/monomac-build-" + DateTime.Now.Ticks;
			FilePath workingApp = tempDir.Combine (cfg.AppDirectory.FileName);
			
			try {
				monitor.BeginTask (GettextCatalog.GetString ("Creating app bundle"), 0);
				var files = Directory.GetFiles (cfg.AppDirectory, "*", SearchOption.AllDirectories);
				HashSet<string> createdDirs = new HashSet<string> ();
				foreach (FilePath f in files) {
					var rel = f.ToRelative (cfg.AppDirectory);
					var parentDir = rel.ParentDirectory;
					if (settings.IncludeMono) {
						if (parentDir.IsNullOrEmpty || parentDir == "." || parentDir == "Contents/MacOS")
							continue;
						var ext = rel.Extension;
						if (ext == ".mdb" || ext == ".exe" || ext == ".dll")
							continue;
					}
					if (monitor.IsCancelRequested)
						return false;
					if (createdDirs.Add (parentDir))
						Directory.CreateDirectory (workingApp.Combine (parentDir));
					monitor.Log.WriteLine (rel);
					File.Copy (f, workingApp.Combine (rel));
				}
				monitor.EndTask ();
				
				if (settings.IncludeMono) {
					monitor.BeginTask (GettextCatalog.GetString ("Merging Mono into app bundle"), 0);
					
					var args = new ProcessArgumentBuilder ();
					args.Add ("-o");
					args.AddQuoted (tempDir);
					args.Add ("-n");
					args.AddQuoted (cfg.AppName);
					
					var assemblies = project.GetReferencedAssemblies (conf, true);
					foreach (var a in assemblies) {
						args.Add ("-a");
						args.AddQuoted (a);
					}
					args.AddQuoted (cfg.CompiledOutputName);
					
					string mmpPath = Mono.Addins.AddinManager.CurrentAddin.GetFilePath ("mmp");
					var psi = new ProcessStartInfo (mmpPath, args.ToString ());
					monitor.Log.WriteLine ("mmp " + psi.Arguments);
					
					string err;
					if (MacBuildUtilities.ExecuteCommand (monitor, psi, out err) != 0) {
						monitor.Log.WriteLine (err);
						monitor.ReportError ("Merging Mono failed", null);
						return false;
					}
					
					var plistFile = workingApp.Combine ("Contents", "Info.plist");
					var plistDoc = new PlistDocument ();
					plistDoc.LoadFromXmlFile (plistFile);
					((PlistDictionary)plistDoc.Root)["MonoBundleExecutable"] = cfg.CompiledOutputName.FileName;
					plistDoc.WriteToFile (plistFile);
					
					monitor.EndTask ();
				}
				
				//TODO: verify bundle details if for app store?
					
				if (settings.SignBundle) {
					monitor.BeginTask (GettextCatalog.GetString ("Signing app bundle"), 0);
					
					var args = new ProcessArgumentBuilder ();
					args.Add ("-v", "-f", "-s");
					args.AddQuoted (bundleKey, workingApp);
					
					var psi = new ProcessStartInfo ("codesign", args.ToString ());
					monitor.Log.WriteLine ("codesign " + psi.Arguments);
					
					string err;
					if (MacBuildUtilities.ExecuteCommand (monitor, psi, out err) != 0) {
						monitor.Log.WriteLine (err);
						monitor.ReportError ("Signing failed", null);
						return false;
					}
					
					monitor.EndTask ();
				}
				
				if (settings.CreatePackage) {
					monitor.BeginTask (GettextCatalog.GetString ("Creating installer"), 0);
					
					var args = new ProcessArgumentBuilder ();
					args.Add ("--component");
					args.AddQuoted (workingApp);
					args.Add ("/Applications", "--sign");
					args.AddQuoted (packageKey);
					if (!settings.ProductDefinition.IsNullOrEmpty) {
						args.Add ("--product");
						args.AddQuoted (settings.ProductDefinition);
					}
					args.AddQuoted (target);
					
					var psi = new ProcessStartInfo ("productbuild", args.ToString ());
					monitor.Log.WriteLine ("productbuild " + psi.Arguments);
					
					string err;
					if (MacBuildUtilities.ExecuteCommand (monitor, psi, out err) != 0) {
						monitor.Log.WriteLine (err);
						monitor.ReportError ("Package creation failed", null);
						return false;
					}
					monitor.EndTask ();
				} else {
					Directory.Move (workingApp, target);
				}
			} finally {
				try {
					if (Directory.Exists (tempDir))
						Directory.Delete (tempDir, true);
				} catch (Exception ex) {
					LoggingService.LogError ("Error removing temp directory", ex);
				}
			}
			
			return true;
		}