protected void AppendAdbOptions(CommandLineBuilder cmd) { var adb = string.IsNullOrEmpty(AdbToolExe) ? AdbToolName : AdbToolExe; cmd.AppendSwitchIfNotNull("--adb ", Path.Combine(AdbToolPath, adb)); var adbTarget = AdbTarget; if (!string.IsNullOrEmpty(adbTarget)) { // Normally of the form "-s emulator-5554" int index = adbTarget.IndexOf(' '); if (index != -1) { adbTarget = adbTarget.Substring(index + 1, adbTarget.Length - index - 1); } cmd.AppendSwitchIfNotNull("--device-id ", adbTarget); } }
protected virtual void HandleReferences(CommandLineBuilder cmd) { if (References != null) { foreach (var item in References) { cmd.AppendSwitchIfNotNull("-r ", Path.GetFullPath(item.ItemSpec)); } } }
/// <summary> /// Appends an array of command line switches. The switch name is repeated for each value. /// </summary> /// <param name="builder"></param> /// <param name="switchName"></param> /// <param name="values"></param> public static void AppendArrayIfNotNull(this CommandLineBuilder builder, string switchName, string[] values) { if (values != null) { foreach (string value in values) { builder.AppendSwitchIfNotNull(switchName, value); } } }
/// <summary> /// Append a switch to the command line if any values in the array have been specified. /// </summary> /// <param name="commandLine">Command line builder.</param> /// <param name="switchName">Switch to append.</param> /// <param name="values">Values specified by the user.</param> internal static void AppendArrayIfNotNull(CommandLineBuilder commandLine, string switchName, ITaskItem[] values) { if (values != null) { foreach (ITaskItem value in values) { commandLine.AppendSwitchIfNotNull(switchName, value); } } }
protected override string GenerateCommandLineCommands() { CommandLineBuilder.AppendSwitchIfNotNull("-out ", OutputPath); // No trailing space, preprocessor definitions are passed as -d<Variable>=<Value> CommandLineBuilder.AppendArrayIfNotNull("-d", PreprocessorDefinitions.ToArray()); CommandLineBuilder.AppendArrayIfNotNull("-ext ", Extensions.ToArray()); CommandLineBuilder.AppendSwitchIfNotNull("-arch ", Arch); CommandLineBuilder.AppendFileNamesIfNotNull(SourceFiles.ToArray(), " "); return(CommandLineBuilder.ToString()); }
/// <summary> /// Returns a string value containing the command line arguments to pass directly to the executable file. /// </summary> /// <returns> /// A string value containing the command line arguments to pass directly to the executable file. /// </returns> protected override string GenerateCommandLineCommands() { var builder = new CommandLineBuilder(); builder.AppendSwitch("pack"); builder.AppendFileNameIfNotNull(File); builder.AppendSwitchIfNotNull("-OutputDirectory ", OutputDirectory); builder.AppendSwitchIfNotNull("-BasePath ", BasePath); builder.AppendSwitchIfNotNull("-Version ", Version); builder.AppendSwitchIfNotNull("-Verbosity ", Verbosity); builder.AppendSwitchIfNotNull("-MinClientVersion", MinClientVersion); if (ExcludeEmptyDirectories) { builder.AppendSwitch("-ExcludeEmptyDirectories"); } if (Build) { builder.AppendSwitch("-Build"); } if (Tool) { builder.AppendSwitch("-Tool"); } // backward compatible with old Verbose property if (Verbosity == null && Verbose) { builder.AppendSwitch("-Verbosity detailed"); } if (Symbols) { builder.AppendSwitch("-Symbols"); } if (NoDefaultExcludes) { builder.AppendSwitch("-NoDefaultExcludes"); } if (NoPackageAnalysis) { builder.AppendSwitch("-NoPackageAnalysis"); } if (IncludeReferencedProjects) { builder.AppendSwitch("-IncludeReferencedProjects"); } builder.AppendSwitchIfNotNull("-Exclude", Exclude); builder.AppendSwitchIfNotNull("-Properties ", Properties); return(builder.ToString()); }
void GenerateMainDexListBuilderCommands(CommandLineBuilder cmd) { var jars = JavaLibraries.Select(i => i.ItemSpec).Concat(new string [] { ClassesOutputDirectory }); cmd.AppendSwitchIfNotNull("-Djava.ext.dirs=", Path.Combine(AndroidSdkBuildToolsPath, "lib")); cmd.AppendSwitch("com.android.multidex.MainDexListBuilder"); cmd.AppendSwitch(tempJar); cmd.AppendSwitchUnquotedIfNotNull("", "\"" + string.Join($"{Path.PathSeparator}", jars) + "\""); writeOutputToKeepFile = true; }
/// <summary> /// Generates the svn arguments. /// </summary> /// <returns></returns> protected virtual void AppendArguments(CommandLineBuilder commandLine) { commandLine.AppendSwitchIfNotNull("--username ", Username); commandLine.AppendSwitchIfNotNull("--password ", Password); commandLine.AppendSwitchIfNotNull("--message ", Message); commandLine.AppendSwitchIfTrue("--force", Force); commandLine.AppendSwitchIfTrue("--verbose", Verbose); commandLine.AppendSwitchIfTrue("--xml", Xml); commandLine.AppendSwitchIfTrue("--non-interactive", NonInteractive); commandLine.AppendSwitchIfTrue("--no-auth-cache", NoAuthCache); // raw arguments if (!string.IsNullOrEmpty(Arguments)) { commandLine.AppendSwitch(Arguments); } }
/// <summary> /// Generates the commands for the switches that may have an array of arguments /// The switch may be empty. /// </summary> /// <remarks>For stringarray switches (e.g., Sources), the CommandLineToolSwitchName (if it exists) is emitted /// along with each and every one of the file names separately (if no separator is included), or with all of the /// file names separated by the separator. /// e.g., AdditionalIncludeDirectores = "@(Files)" where Files has File1, File2, and File3, the switch /// /IFile1 /IFile2 /IFile3 or the switch /IFile1;File2;File3 is emitted (the latter case has a separator /// ";" specified)</remarks> private static void EmitStringArraySwitch(CommandLineBuilder clb, CommandLineToolSwitch commandLineToolSwitch) { var stringList = new List <string>(commandLineToolSwitch.StringList.Length); for (int i = 0; i < commandLineToolSwitch.StringList.Length; ++i) { // Make sure the file doesn't contain escaped " (\") string value; if (commandLineToolSwitch.StringList[i].StartsWith("\"", StringComparison.OrdinalIgnoreCase) && commandLineToolSwitch.StringList[i].EndsWith("\"", StringComparison.OrdinalIgnoreCase)) { value = commandLineToolSwitch.StringList[i].Substring(1, commandLineToolSwitch.StringList[i].Length - 2).Trim(); } else { value = commandLineToolSwitch.StringList[i].Trim(); } if (!String.IsNullOrEmpty(value)) { stringList.Add(value); } } string[] arrTrimStringList = stringList.ToArray(); if (String.IsNullOrEmpty(commandLineToolSwitch.Separator)) { foreach (string fileName in arrTrimStringList) { if (!PerformSwitchValueSubstition(clb, commandLineToolSwitch, fileName)) { clb.AppendSwitchIfNotNull(commandLineToolSwitch.SwitchValue, fileName); } } } else { if (!PerformSwitchValueSubstition(clb, commandLineToolSwitch, String.Join(commandLineToolSwitch.Separator, arrTrimStringList))) { clb.AppendSwitchIfNotNull(commandLineToolSwitch.SwitchValue, arrTrimStringList, commandLineToolSwitch.Separator); } } }
protected override string GenerateCommandLineCommands() { CommandLineBuilder.AppendSwitchIfNotNull("-o ", OutputFile); CommandLineBuilder.AppendSwitchIfTrue("-fv", AddFileVersion); CommandLineBuilder.AppendArrayIfNotNull("-ext ", Extensions.ToArray()); CommandLineBuilder.AppendSwitchIfNotNull("-sice:", SuppressIces); CommandLineBuilder.AppendFileNamesIfNotNull(SourceFiles.ToArray(), " "); return(CommandLineBuilder.ToString()); }
/// <summary> /// Returns a string value containing the command line arguments to pass directly to the executable file. /// </summary> /// <returns>A string value containing the command line arguments to pass directly to the executable file.</returns> protected override string GenerateCommandLineCommands() { CommandLineBuilder commandLine = new CommandLineBuilder(); commandLine.AppendSwitchIfNotNull("-c:", this.HelpCompiler); commandLine.AppendFileNameIfNotNull(this.TableOfContents); commandLine.AppendFileNameIfNotNull(this.HelpFile); return(commandLine.ToString()); }
public void AppendSwitchWithParameterArrayQuoting() { CommandLineBuilder c = new CommandLineBuilder(); c.AppendSwitch("/something"); c.AppendSwitchIfNotNull("/switch:", new string[] { "Mer cury.cs", "Ve nus.cs", "Ear th.cs" }, ","); // Managed compilers use this function to append sources files. Assert.AreEqual("/something /switch:\"Mer cury.cs\",\"Ve nus.cs\",\"Ear th.cs\"", c.ToString()); }
public static void AppendSwitchIfAny(this CommandLineBuilder commandLineBuilder, string switchName, IEnumerable <ITaskItem> items) { if (items != null) { foreach (var item in items) { commandLineBuilder.AppendSwitchIfNotNull(switchName, item.ItemSpec); } } }
/// <summary> /// Append a switch to the command line if any values in the array have been specified. /// </summary> /// <param name="commandLine">Command line builder.</param> /// <param name="switchName">Switch to append.</param> /// <param name="values">Values specified by the user.</param> internal static void AppendArrayIfNotNull(CommandLineBuilder commandLine, string switchName, string[] values) { if (values != null) { for (int i = 0; i < values.Length; i++) { commandLine.AppendSwitchIfNotNull(switchName, values[i]); } } }
public void AppendSwitchWithParameterArrayQuotingTaskItem() { CommandLineBuilder c = new CommandLineBuilder(); c.AppendSwitch("/something"); c.AppendSwitchIfNotNull("/switch:", new[] { new TaskItem("Mer cury.cs"), null, new TaskItem("Ve nus.cs"), new TaskItem("Ear th.cs") }, ","); // Managed compilers use this function to append sources files. c.ShouldBe("/something /switch:\"Mer cury.cs\",,\"Ve nus.cs\",\"Ear th.cs\""); }
protected override string GenerateCommandLineCommands() { var cmd = new CommandLineBuilder(); cmd.AppendSwitch("--quiet"); if (ConfigFiles != null && ConfigFiles.Any()) { var config = MergeConfigFiles(); var configPath = Path.Combine(IntermediateOutputPath, "lint.xml"); config.Save(configPath); cmd.AppendSwitchIfNotNull("--config ", configPath); } cmd.AppendSwitchIfNotNull("--enable ", EnabledIssues); cmd.AppendSwitchIfNotNull("--disable ", DisabledIssues); cmd.AppendSwitchIfNotNull("--check ", CheckIssues); foreach (var item in ResourceDirectories) { cmd.AppendSwitchIfNotNull("--resources ", item.ItemSpec); } foreach (var item in SourceDirectories) { cmd.AppendSwitchIfNotNull("--sources ", item.ItemSpec); } foreach (var item in ClassDirectories) { cmd.AppendSwitchIfNotNull("--classpath ", item.ItemSpec); } foreach (var item in ClassPathJars) { cmd.AppendSwitchIfNotNull("--classpath ", item.ItemSpec); } foreach (var item in LibraryDirectories) { cmd.AppendSwitchIfNotNull("--libraries ", item.ItemSpec); } foreach (var item in LibraryJars) { cmd.AppendSwitchIfNotNull("--libraries ", item.ItemSpec); } cmd.AppendFileNameIfNotNull(TargetDirectory); return(cmd.ToString()); }
/// <summary> /// Returns a string value containing the command line arguments to pass directly to the executable file. /// </summary> /// <returns> /// A string value containing the command line arguments to pass directly to the executable file. /// </returns> protected override string GenerateCommandLineCommands() { // pdbstr -r/w -p:PdbFileName -i:StreamFileName -s:StreamName var builder = new CommandLineBuilder(); if (string.Equals("write", Command, StringComparison.OrdinalIgnoreCase)) { builder.AppendSwitch("-w"); } else { builder.AppendSwitch("-r"); } builder.AppendSwitchIfNotNull("-p:", PdbFile); builder.AppendSwitchIfNotNull("-i:", StreamFile); builder.AppendSwitchIfNotNull("-s:", StreamName); return(builder.ToString()); }
void GenerateMainDexListBuilderCommands(CommandLineBuilder cmd) { var enclosingChar = OS.IsWindows ? "\"" : "'"; var jars = JavaLibraries.Select(i => i.ItemSpec).Concat(new string [] { Path.Combine(ClassesOutputDirectory, "classes.zip") }); cmd.AppendSwitchIfNotNull("-Djava.ext.dirs=", Path.Combine(AndroidSdkBuildToolsPath, "lib")); cmd.AppendSwitch("com.android.multidex.MainDexListBuilder"); cmd.AppendSwitchUnquotedIfNotNull("", $"{enclosingChar}{tempJar}{enclosingChar}"); cmd.AppendSwitchUnquotedIfNotNull("", enclosingChar + string.Join($"{enclosingChar}{Path.PathSeparator}{enclosingChar}", jars) + enclosingChar); writeOutputToKeepFile = true; }
/// <summary> /// Returns a string value containing the command line arguments to pass directly to the executable file. /// </summary> /// <returns> /// A string value containing the command line arguments to pass directly to the executable file. /// </returns> protected override string GenerateCommandLineCommands() { var builder = new CommandLineBuilder(); builder.AppendSwitch("pack"); builder.AppendFileNameIfNotNull(File); builder.AppendSwitchIfNotNull("-OutputDirectory ", OutputDirectory); builder.AppendSwitchIfNotNull("-BasePath ", BasePath); builder.AppendSwitchIfNotNull("-Version ", Version); if (Verbose) { builder.AppendSwitch("-Verbose"); } if (Symbols) { builder.AppendSwitch("-Symbols"); } return(builder.ToString()); }
public static void AppendSwitchIfNotNullOrEmpty(this CommandLineBuilder commandLine, string switchName, string parameter) { Contract.Requires <ArgumentNullException>(commandLine != null, "commandLine"); Contract.Requires <ArgumentNullException>(switchName != null, "switchName"); Contract.Requires <ArgumentException>(!string.IsNullOrEmpty(switchName)); if (!string.IsNullOrEmpty(parameter)) { commandLine.AppendSwitchIfNotNull(switchName, parameter); } }
protected override string GenerateCommandLineCommands() { // Running command: C:\Program Files (x86)\Java\jdk1.6.0_20\bin\javac.exe // "-J-Dfile.encoding=UTF8" // "-d" "bin\classes" // "-classpath" "C:\Users\Jonathan\Documents\Visual Studio 2010\Projects\AndroidMSBuildTest\AndroidMSBuildTest\obj\Debug\android\bin\mono.android.jar" // "-bootclasspath" "C:\Program Files (x86)\Android\android-sdk-windows\platforms\android-8\android.jar" // "-encoding" "UTF-8" // "@C:\Users\Jonathan\AppData\Local\Temp\tmp79c4ac38.tmp" var cmd = new CommandLineBuilder(); cmd.AppendSwitchIfNotNull("-J-Dfile.encoding=", "UTF8"); cmd.AppendFileNameIfNotNull(string.Format("@{0}", TemporarySourceListFile)); cmd.AppendSwitchIfNotNull("-target ", JavacTargetVersion); cmd.AppendSwitchIfNotNull("-source ", JavacSourceVersion); return(cmd.ToString()); }
/// <inheritdoc/> protected override string GenerateCommandLineCommands() { var commandLineBuilder = new CommandLineBuilder(); commandLineBuilder.AppendFileNameIfNotNull(this.Assembly); commandLineBuilder.AppendSwitchIfNotNull("/regfile:", RegAsm.GetRegFileTaskItem(this.Assembly)); var result = commandLineBuilder.ToString(); return(result); }
protected virtual CommandLineBuilder GetCommandLineBuilder() { var cmd = new CommandLineBuilder(); if (!string.IsNullOrEmpty(JavaOptions)) { cmd.AppendSwitch(JavaOptions); } cmd.AppendSwitchIfNotNull("-Xmx", JavaMaximumHeapSize); cmd.AppendSwitchIfNotNull("-cp ", $"{ManifestMergerJarPath}"); cmd.AppendSwitch("com.xamarin.manifestmerger.Main"); StringBuilder sb = new StringBuilder(); sb.AppendLine("--main"); sb.AppendLine(AndroidManifest); if (LibraryManifestFiles != null) { sb.AppendLine("--libs"); sb.AppendLine($"{string.Join ($"{Path.PathSeparator}", LibraryManifestFiles)}"); } if (ManifestPlaceholders != null) { foreach (var entry in ManifestPlaceholders.Select(e => e.Split(new char [] { '=' }, 2, StringSplitOptions.None))) { if (entry.Length == 2) { sb.AppendLine("--placeholder"); sb.AppendLine($"{entry [0]}={entry [1]}"); } else { Log.LogCodedWarning("XA1010", string.Format(Properties.Resources.XA1010, string.Join(";", ManifestPlaceholders))); } } } sb.AppendLine("--out"); sb.AppendLine(tempFile); File.WriteAllText(responseFile, sb.ToString()); cmd.AppendFileNameIfNotNull(responseFile); return(cmd); }
protected virtual CommandLineBuilder GetCommandLineBuilder() { var cmd = new CommandLineBuilder(); if (!string.IsNullOrEmpty(JavaOptions)) { cmd.AppendSwitch(JavaOptions); } cmd.AppendSwitchIfNotNull("-Xmx", JavaMaximumHeapSize); cmd.AppendSwitchIfNotNull("-cp ", $"{ManifestMergerJarPath}"); cmd.AppendSwitch("com.xamarin.manifestmerger.Main"); StringBuilder sb = new StringBuilder(); sb.AppendLine("--main"); sb.AppendLine(AndroidManifest); if (LibraryManifestFiles != null) { sb.AppendLine("--libs"); sb.AppendLine($"{string.Join ($"{Path.PathSeparator}", LibraryManifestFiles)}"); } if (ManifestPlaceholders != null) { foreach (var entry in ManifestPlaceholders.Select(e => e.Split(new char [] { '=' }, 2, StringSplitOptions.None))) { if (entry.Length == 2) { sb.AppendLine("--placeholder"); sb.AppendLine($"{entry [0]}={entry [1]}"); } else { Log.LogWarning("Invalid application placeholders (AndroidApplicationPlaceholders) value. Use 'key1=value1;key2=value2, ...' format. The specified value was: " + ManifestPlaceholders); } } } sb.AppendLine("--out"); sb.AppendLine(tempFile); File.WriteAllText(responseFile, sb.ToString()); cmd.AppendFileNameIfNotNull(responseFile); return(cmd); }
protected override string GenerateResponseFileCommands() { var builder = new CommandLineBuilder(); var staticLibs = this.GetStaticLibs(); if (staticLibs.Length > 0) { builder.AppendSwitchIfNotNull("--staticLibs ", staticLibs, " "); } return(builder.ToString()); }
protected string GenerateCommandLineCommands(ITaskItem dir, string outputArchive) { var cmd = new CommandLineBuilder(); cmd.AppendSwitch("compile"); cmd.AppendSwitchIfNotNull("-o ", outputArchive); if (!string.IsNullOrEmpty(ResourceSymbolsTextFile)) { cmd.AppendSwitchIfNotNull("--output-text-symbols ", ResourceSymbolsTextFile); } cmd.AppendSwitchIfNotNull("--dir ", ResourceDirectoryFullPath(dir.ItemSpec)); if (ExplicitCrunch) { cmd.AppendSwitch("--no-crunch"); } if (MonoAndroidHelper.LogInternalExceptions) { cmd.AppendSwitch("-v"); } return(cmd.ToString()); }
/// <summary> /// Returns a string value containing the command line arguments to pass directly to the executable file. /// </summary> /// <returns> /// A string value containing the command line arguments to pass directly to the executable file. /// </returns> protected override string GenerateCommandLineCommands() { var builder = new CommandLineBuilder(); builder.AppendSwitch("delete"); builder.AppendFileNameIfNotNull(Package); builder.AppendFileNameIfNotNull(Version); builder.AppendSwitchIfNotNull("-ApiKey ", ApiKey); builder.AppendSwitchIfNotNull("-Source ", Source); builder.AppendSwitchIfNotNull("-Verbosity ", Verbosity); builder.AppendSwitchIfNotNull("-ConfigFile ", ConfigFile); if (ForceEnglishOutput) { builder.AppendSwitch("-ForceEnglishOutput"); } builder.AppendSwitch("-NonInteractive"); return(builder.ToString()); }
/// <summary> /// Returns a string value containing the command line arguments to pass directly to the executable file. /// </summary> /// <returns> /// A string value containing the command line arguments to pass directly to the executable file. /// </returns> protected override string GenerateCommandLineCommands() { var builder = new CommandLineBuilder(); builder.AppendSwitch("push"); builder.AppendFileNameIfNotNull(File); builder.AppendFileNameIfNotNull(APIKey); builder.AppendSwitchIfNotNull("-Source ", Source); builder.AppendSwitchIfNotNull("-Verbosity ", Verbosity); builder.AppendSwitchIfNotNull("-ConfigFile ", ConfigFile); if (CreateOnly) { builder.AppendSwitch("-CreateOnly"); } if (ForceEnglishOutput) { builder.AppendSwitch("-ForceEnglishOutput"); } return(builder.ToString()); }
protected string GenerateCommandLineCommands(ITaskItem dir, string outputArchive) { var cmd = new CommandLineBuilder(); cmd.AppendSwitch("compile"); cmd.AppendSwitchIfNotNull("-o ", outputArchive); if (!string.IsNullOrEmpty(ResourceSymbolsTextFile)) { cmd.AppendSwitchIfNotNull("--output-text-symbols ", ResourceSymbolsTextFile); } cmd.AppendSwitchIfNotNull("--dir ", dir.ItemSpec.TrimEnd('\\')); if (!string.IsNullOrEmpty(ExtraArgs)) { cmd.AppendSwitch(ExtraArgs); } if (MonoAndroidHelper.LogInternalExceptions) { cmd.AppendSwitch("-v"); } return(cmd.ToString()); }
protected override string GenerateCommandLineCommands() { Log.LogDebugMessage("MDoc"); Log.LogDebugMessage(" RunExport: {0}", RunExport); Log.LogDebugMessage(" TargetAssembly: {0}", TargetAssembly); Log.LogDebugMessage(" References"); if (References != null) { foreach (var reference in References) { Log.LogDebugMessage(" {0}", reference); } } Log.LogDebugMessage(" OutputDocDirectory: {0}", OutputDocDirectory); if (RunExport) { var cmd = new CommandLineBuilder(); cmd.AppendSwitch("--debug"); cmd.AppendSwitch("export-msxdoc"); cmd.AppendSwitchIfNotNull("-o", Path.ChangeExtension(TargetAssembly, ".xml")); cmd.AppendSwitch(OutputDocDirectory); return(cmd.ToString()); } else { var refPaths = References.Select(Path.GetDirectoryName).Distinct(); var cmd = new CommandLineBuilder(); cmd.AppendSwitch("--debug"); cmd.AppendSwitch("update"); cmd.AppendSwitch("--delete"); cmd.AppendSwitchIfNotNull("-L", Path.GetDirectoryName(TargetAssembly)); foreach (var rp in refPaths) { cmd.AppendSwitchIfNotNull("-L", rp); } cmd.AppendSwitchIfNotNull("-o", OutputDocDirectory); cmd.AppendSwitch(Path.GetFullPath(TargetAssembly)); return(cmd.ToString()); } }
/// <summary> /// Generates the svn arguments. /// </summary> /// <returns></returns> protected virtual void AppendArguments(CommandLineBuilder commandLine) { commandLine.AppendSwitchIfNotNull("--username ", Username); commandLine.AppendSwitchIfNotNull("--password ", Password); commandLine.AppendSwitchIfNotNull("--message ", Message); commandLine.AppendSwitchIfTrue("--force", Force); commandLine.AppendSwitchIfTrue("--verbose", Verbose); commandLine.AppendSwitchIfTrue("--xml", Xml); commandLine.AppendSwitchIfTrue("--non-interactive", NonInteractive); commandLine.AppendSwitchIfTrue("--no-auth-cache", NoAuthCache); // raw arguments if (!string.IsNullOrEmpty(Arguments)) commandLine.AppendSwitch(Arguments); }
/// <summary> /// Generates the SvnAdmin arguments. /// </summary> /// <returns></returns> protected virtual void AppendArguments(CommandLineBuilder commandLine) { commandLine.AppendSwitchIfTrue("--quiet", Quiet); // raw arguments commandLine.AppendSwitchIfNotNull("", Arguments); }