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);
            }
        }
Exemple #2
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());
        }
        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);
        }
        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);
        }
        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));
        }
        // 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 #7
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 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 #10
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());
        }
        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 #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());
        }
Exemple #13
0
        ProcessStartInfo GetStartPlatformSpecificMonoDoc(string topic, params string[] extraArgs)
        {
            var builder = new ProcessArgumentBuilder();

            extraArgs = extraArgs ?? new string[0];

            if (Platform.IsMac)
            {
                var url   = topic != null ? "monodoc://" + System.Web.HttpUtility.UrlEncode(topic) : null;
                var mdapp = new FilePath(typeof(HelpOperations).Assembly.Location).ParentDirectory.Combine("..", "..", "..", "..", "MacOS", "MonoDoc.app").FullPath;
                if (Directory.Exists(mdapp))
                {
                    builder.Add("-a");
                    builder.AddQuoted(mdapp);
                    builder.Add("--args");
                    builder.AddQuoted(url);
                    AddDirArgs(builder);
                    builder.AddQuoted(extraArgs);
                }
                else
                {
                    LoggingService.LogWarning("MonoDoc.app folder not found at {0}.", mdapp);
                    builder.AddQuoted(url);
                    builder.AddQuoted(extraArgs);
                }
                return(new ProcessStartInfo("open", builder.ToString()));
            }
            else if (Platform.IsWindows)
            {
                string mdapp = new FilePath(typeof(HelpOperations).Assembly.Location).ParentDirectory.Combine("windoc", "WinDoc.exe").FullPath;
                if (topic != null)
                {
                    builder.AddQuoted("--url", topic);
                }
                AddDirArgs(builder);
                builder.AddQuoted(extraArgs);
                if (File.Exists(mdapp))
                {
                    return(new System.Diagnostics.ProcessStartInfo {
                        FileName = mdapp,
                        Arguments = builder.ToString(),
                        WorkingDirectory = Path.GetDirectoryName(mdapp),
                    });
                }
            }

            return(null);
        }
Exemple #14
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;
		}
        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));
        }
Exemple #16
0
 static void AddPropertyIfHasValue(ProcessArgumentBuilder args, string property, string value)
 {
     if (!string.IsNullOrEmpty(value))
     {
         args.Add(string.Format("/p:{0}={1}", property, ProcessArgumentBuilder.Quote(value)));
     }
 }
        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 #18
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 #19
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);
        }
Exemple #20
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 #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);
        }
        void StartLogTracking()
        {
            var args = new ProcessArgumentBuilder();

            args.Add("-v time");
            foreach (string tag in excludedLogTags)
            {
                args.Add(tag + ":S");
            }

            trackLogOp            = new AdbTrackLogOperation(device, ProcessLogLine, args.ToString());
            trackLogOp.Completed += delegate(IAsyncOperation op) {
                if (!op.Success)
                {
                    SetCompleted(false);
                }
            };
        }
        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 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));
        }
        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);
        }
Exemple #26
0
        static string BuildArguments(ConfigurationManager configurationManager, string shimSocket, string root, string onDemandSock)
        {
            var builder = new ProcessArgumentBuilder();

            builder.AddSingle(shimSocket, GetFastCgiCommand(configurationManager.FastCgiCommand));
            if (configurationManager.Verbose)
            {
                builder.Add("--verbose");
            }
            builder.Add("--ondemand");
            builder.AddFormatSafe("--applications /:'{0}'", root);
            builder.Add("--idle-time", configurationManager.ChildIdleTime);
            builder.AddFormatSafe("--ondemandsock 'unix://660@{0}'", onDemandSock);
            builder.AddFormat("--loglevels {0}", configurationManager.LogLevels);
            builder.AddFormatSafe("--name '{0}'", Path.GetFileName(root));
            var arguments = builder.ToString();

            return(arguments);
        }
        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 #28
0
        protected override string GenerateCommandLineCommands()
        {
            var args = new ProcessArgumentBuilder ();

            args.Add ("-rsrc");

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

            return args.ToString ();
        }
Exemple #29
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 #30
0
        protected override string GenerateCommandLineCommands()
        {
            var args = new ProcessArgumentBuilder();

            args.Add("-rsrc");

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

            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));
        }
Exemple #32
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());
        }
        protected override string GenerateCommandLineCommands()
        {
            Log.LogMessage("Creating installer package");

            var args = new ProcessArgumentBuilder();

            if (!string.IsNullOrEmpty(ProductDefinition))
            {
                args.Add("--product");
                args.AddQuoted(ProductDefinition);
            }

            args.Add("--component");
            args.AddQuoted(Path.Combine(OutputDirectory, Path.GetFileName(AppBundleDir)));
            args.Add("/Applications");

            if (EnablePackageSigning)
            {
                args.Add("--sign");
                args.AddQuoted(GetPackageSigningCertificateCommonName());
            }

            if (!string.IsNullOrEmpty(PackagingExtraArgs))
            {
                try {
                    AppendExtraArgs(args, PackagingExtraArgs);
                } catch (FormatException) {
                    Log.LogError("Package creation failed. Could not parse extra arguments.");
                    return(string.Empty);
                }
            }

            string projectVersion = GetProjectVersion();
            string target         = string.Format("{0}{1}.pkg", Name, String.IsNullOrEmpty(projectVersion) ? "" : "-" + projectVersion);

            args.AddQuoted(Path.Combine(OutputDirectory, target));
            return(args.ToString());
        }
Exemple #34
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());
        }
Exemple #35
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);
		}
		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 #37
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 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 #39
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);
		}
Exemple #40
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);
		}
		void StartLogTracking ()
		{
			var args = new ProcessArgumentBuilder ();
			args.Add ("-v time");
			foreach (string tag in excludedLogTags)
				args.Add (tag + ":S");

			trackLogOp = new AdbTrackLogOperation (device, ProcessLogLine, args.ToString ());
			trackLogOp.Completed += delegate (IAsyncOperation op) {
				if (!op.Success) {
					SetCompleted (false);
				}
			};
		}
		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;
		}
		static void AddExtraArgs (ProcessArgumentBuilder args, string extraArgs, IPhoneProject proj,
			IPhoneProjectConfiguration conf)
		{
			if (!string.IsNullOrEmpty (extraArgs)) {
				var customTags = new Dictionary<string, string> (StringComparer.OrdinalIgnoreCase) {
					{ "projectdir",   ProcessArgumentBuilder.EscapeQuotes (proj.BaseDirectory) },
					{ "solutiondir",  ProcessArgumentBuilder.EscapeQuotes (proj.ParentSolution.BaseDirectory) },
					{ "appbundledir", ProcessArgumentBuilder.EscapeQuotes (conf.AppDirectory) },
					{ "targetpath",   ProcessArgumentBuilder.EscapeQuotes (conf.CompiledOutputName) },
					{ "targetdir",    ProcessArgumentBuilder.EscapeQuotes (conf.CompiledOutputName.ParentDirectory) },
					{ "targetname",   ProcessArgumentBuilder.EscapeQuotes (conf.CompiledOutputName.FileName) },
					{ "targetext",    ProcessArgumentBuilder.EscapeQuotes (conf.CompiledOutputName.Extension) },
				};
				args.Add (StringParserService.Parse (extraArgs, customTags));
			}
		}
Exemple #44
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 #45
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);
		}
		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;
		}
		static internal void AppendExtrasMtouchArgs (ProcessArgumentBuilder args, IPhoneSdkVersion sdkVersion, 
			IPhoneProject proj, IPhoneProjectConfiguration conf)
		{
			if (conf.MtouchDebug)
				args.Add ("-debug");
			
			switch (conf.MtouchLink) {
			case MtouchLinkMode.SdkOnly:
				args.Add ("-linksdkonly");
				break;
			case MtouchLinkMode.None:
				args.Add ("-nolink");
				break;
			case MtouchLinkMode.Full:
			default:
				break;
			}
			
			if (!string.IsNullOrEmpty (conf.MtouchI18n)) {
				args.AddQuotedFormat ("-i18n={0}", conf.MtouchI18n);
			}
			
			if (!sdkVersion.Equals (IPhoneSdkVersion.V3_0))
				args.AddQuotedFormat ("-sdk={0}", sdkVersion);
			
			if (conf.MtouchMinimumOSVersion != "3.0")
				args.AddQuotedFormat ("-targetver={0}", conf.MtouchMinimumOSVersion);
			
			
			AddExtraArgs (args, conf.MtouchExtraArgs, proj, conf);
		}
Exemple #48
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);
		}
Exemple #49
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 #50
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 ();
        }