public void AppendSwitchSimple() { CommandLineBuilder c = new CommandLineBuilder(); c.AppendSwitch("/a"); c.AppendSwitch("-b"); Assert.Equal("/a -b", c.ToString()); }
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 android_dir = MonoDroid.MonoDroidSdk.GetAndroidProfileDirectory (TargetFrameworkDirectory); var cmd = new CommandLineBuilder (); cmd.AppendSwitchIfNotNull ("-J-Dfile.encoding=", "UTF8"); cmd.AppendSwitchIfNotNull ("-d ", ClassesOutputDirectory); cmd.AppendSwitchIfNotNull ("-classpath ", Jars == null || !Jars.Any () ? null : string.Join (Path.PathSeparator.ToString (), Jars.Select (i => i.ItemSpec))); cmd.AppendSwitchIfNotNull ("-bootclasspath ", JavaPlatformJarPath); cmd.AppendSwitchIfNotNull ("-encoding ", "UTF-8"); cmd.AppendFileNameIfNotNull (string.Format ("@{0}", TemporarySourceListFile)); cmd.AppendSwitchIfNotNull ("-target ", JavacTargetVersion); cmd.AppendSwitchIfNotNull ("-source ", JavacSourceVersion); return cmd.ToString (); }
protected override string GenerateCommandLineCommands () { var builder = new CommandLineBuilder (); builder.AppendSwitch("p"); builder.AppendSwitch("-f"); var resdir = Path.Combine (ProjectDir, "res"); var reszip = Path.Combine (ProjectDir, ProjectName + "-res.zip"); if (Directory.Exists (resdir)) { builder.AppendSwitch("-S"); builder.AppendFileNameIfNotNull (resdir); } builder.AppendSwitch("-F"); builder.AppendFileNameIfNotNull (reszip); builder.AppendSwitch("-J"); builder.AppendFileNameIfNotNull (ProjectDir); builder.AppendSwitch ("-M"); builder.AppendFileNameIfNotNull (AndroidManifest); builder.AppendSwitch ("-I"); builder.AppendFileNameIfNotNull (FrameworkApk); return builder.ToString (); }
protected override string GenerateCommandLineCommands() { CommandLineBuilder clb = new CommandLineBuilder(); clb.AppendSwitch("describe"); return clb.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 (); } }
public string Parse(ITaskItem taskItem, bool fullOutputName, string outputExtension) { CommandLineBuilder builder = new CommandLineBuilder(); foreach (string name in taskItem.MetadataNames) { string value = taskItem.GetMetadata(name); if (outputExtension != null && name == "OutputFile") { value = Path.ChangeExtension(value, outputExtension); } if (fullOutputName && name == "ObjectFileName") { if ((File.GetAttributes(value) & FileAttributes.Directory) != 0) { value = Path.Combine(value, Path.GetFileName(taskItem.ItemSpec)); value = Path.ChangeExtension(value, ".obj"); } } AppendArgumentForProperty(builder, name, value); } string result = builder.ToString(); result = result.Replace('\\', '/'); // posix paths return result; }
/// <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 builder = new CommandLineBuilder(); builder.AppendSwitchIfNotNull("/config:", ConfigFile); builder.AppendFileNameIfNotNull(ManifestFile); return builder.ToString(); }
protected override string GenerateCommandLineCommands() { var builder = new CommandLineBuilder(); builder.AppendFileNameIfNotNull(Source); if (Source != null) { OutputRes = Path.ChangeExtension(OutputIL, ".res"); } builder.AppendSwitch("/nobar"); builder.AppendSwitchIfNotNull("/output=", OutputIL); if (Encoding == null || Encoding.StartsWith("uni", StringComparison.InvariantCultureIgnoreCase)) { builder.AppendSwitch("/unicode"); } if (Encoding != null && Encoding.StartsWith("utf", StringComparison.InvariantCultureIgnoreCase)) { builder.AppendSwitch("/utf8"); } builder.AppendSwitchIfNotNull("/item:", Item); Log.LogMessage(MessageImportance.High, "Disassembling {0}...", Source); return builder.ToString(); }
/// <summary> /// Generates the command line commands. /// </summary> protected override string GenerateCommandLineCommands() { ////if (this.Assemblies.Length != 1) { //// throw new NotSupportedException("Exactly 1 assembly for signing is supported."); ////} CommandLineBuilder args = new CommandLineBuilder(); args.AppendSwitch("-q"); if (this.KeyFile != null) { args.AppendSwitch("-R"); } else if (this.KeyContainer != null) { args.AppendSwitch("-Rc"); } else { throw new InvalidOperationException("Either KeyFile or KeyContainer must be set."); } args.AppendFileNameIfNotNull(this.Assemblies[0]); if (this.KeyFile != null) { args.AppendFileNameIfNotNull(this.KeyFile); } else { args.AppendFileNameIfNotNull(this.KeyContainer); } return args.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 commandLine = new CommandLineBuilder(); GenerateCommand(commandLine); GenerateArguments(commandLine); return commandLine.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 builder = new CommandLineBuilder(); builder.AppendSwitchIfNotNull("/d:", ChmDirectory); builder.AppendSwitchIfNotNull("/l:", LanguageId ?? "1033"); return builder.ToString(); }
protected override string GenerateCommandLineCommands() { CommandLineBuilder builder = new CommandLineBuilder(); builder.AppendSwitch("pack"); if (!File.Exists(this.Target)) { throw new FileNotFoundException(string.Format("The file '{0}' could not be found.", this.Target), this.Target); } builder.AppendFileNameIfNotNull(this.Target); builder.AppendSwitchIfTrue("-Symbols", this.Symbols); builder.AppendSwitchIfTrue("-NoDefaultExcludes", this.NoDefaultExcludes); builder.AppendSwitchIfTrue("-NoPackageAnalysis", this.NoPackageAnalysis); builder.AppendSwitchIfTrue("-ExcludeEmptyDirectories", this.ExcludeEmptyDirectories); builder.AppendSwitchIfTrue("-IncludeReferencedProjects", this.IncludeReferencedProjects); builder.AppendSwitchIfNotNull("-Version ", this.Version); builder.AppendSwitchIfNotNull("-Properties ", this.Properties, ";"); builder.AppendSwitchIfNotNull("-Exclude ", this.Excluded, ";"); builder.AppendSwitchIfNotNull("-MinClientVersion ", this.MinClientVersion); builder.AppendSwitchIfNotNull("-BasePath ", this.BasePath); builder.AppendSwitchIfNotNull("-OutputDirectory ", this.OutputDirectory); builder.AppendSwitchIfNotNull("-Verbosity ", this.Verbosity); builder.AppendSwitch("-NonInteractive "); builder.AppendTextUnquotedIfNotNullOrEmpty(this.CustomSwitches); return builder.ToString(); }
protected override string GenerateCommandLineCommands() { var args = new CommandLineBuilder (); args.AppendFileNameIfNotNull (Input); return args.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("kill-server"); 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("wait-for-device"); 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("uninstall"); builder.AppendSwitch(PackageName); return builder.ToString(); }
protected override string GenerateCommandLineCommands() { var args = new CommandLineBuilder(); args.AppendSwitch("a"); args.AppendSwitch("--"); args.AppendFileNameIfNotNull(this.ZipFileName); return args.ToString(); }
protected override string GenerateCommandLineCommands() { var builder = new CommandLineBuilder(); builder.AppendSwitch(File); if (Args != null) builder.AppendSwitch(Args); return builder.ToString(); }
protected override string GenerateCommandLineCommands() { var builder = new CommandLineBuilder(); builder.AppendSwitchIfNotNull("/source:", SourceDirectory); builder.AppendSwitchIfNotNull("/target:", TargetDirectory); builder.AppendSwitchIfNotNull("/output:", OutputUpdateFile); return builder.ToString(); }
protected override string GenerateCommandLineCommands() { var builder = new CommandLineBuilder(); builder.AppendSwitch("/r"); builder.AppendFileNameIfNotNull(Source); Output = Path.ChangeExtension(Source.ItemSpec, ".res"); Log.LogMessage(MessageImportance.High, "Generate res file from {0}...", Source); return builder.ToString(); }
/// <summary> /// When overridden in a derived class, executes the task. /// </summary> /// <returns> /// true if the task successfully executed; otherwise, false. /// </returns> public override bool Execute() { try { // Get arguments var args = GenerateArguments(); if (null == args) { // If we get no result, the derived class should have set the log messages. return false; } else { if (0 == args.Length) { // If we get no parameters, we don't need to call the compiler. return true; } else { // Show arguments (low level) var builder = new CommandLineBuilder(); foreach (var arg in args) { if (arg.StartsWith("--")) builder.AppendSwitch(arg); else builder.AppendFileNameIfNotNull(arg); } Log.LogCommandLine(MessageImportance.Normal, builder.ToString()); // Invoke return CompilerService.Execute(args, Log); } } } catch (AggregateException agex) { foreach (var ex in agex.Flatten().InnerExceptions) { ErrorLog.DumpError(ex); Log.LogErrorFromException(ex); } return false; } catch (Exception ex) { ErrorLog.DumpError(ex); Log.LogErrorFromException(ex); return false; } }
/// <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); if (CreateOnly) builder.AppendSwitch("-CreateOnly"); return builder.ToString(); }
/// <summary> /// Generates the command line commands. /// </summary> protected override string GenerateCommandLineCommands() { CommandLineBuilder builder = new CommandLineBuilder(); builder.AppendSwitch("-q"); if (this.SkipVerification) { builder.AppendSwitch("-Vr"); } else { builder.AppendSwitch("-Vu"); } builder.AppendFileNameIfNotNull(this.AssemblyName + "," + this.PublicKeyToken); return builder.ToString(); }
/// <summary>See <see cref="ToolTask.GenerateCommandLineCommands"/>.</summary> protected override string GenerateCommandLineCommands() { CommandLineBuilder commandLineBuilder = new CommandLineBuilder(); commandLineBuilder.AppendSwitchIfNotNull(this.Uninstall ? "uninstall " : "install ", this.AssemblyName); if (this.NoDependencies) { commandLineBuilder.AppendSwitch("/NoDependencies"); } commandLineBuilder.AppendSwitch("/nologo"); commandLineBuilder.AppendSwitch("/verbose"); return commandLineBuilder.ToString(); }
protected override string GenerateCommandLineCommands() { var args = new CommandLineBuilder (); args.AppendSwitch ("-convert"); args.AppendSwitch ("binary1"); args.AppendSwitch ("-o"); args.AppendFileNameIfNotNull (Output.ItemSpec); args.AppendFileNameIfNotNull (Input.ItemSpec); return args.ToString (); }
protected override string GenerateCommandLineCommands() { CommandLineBuilder cb = new CommandLineBuilder(); //cb.AppendSwitch("-q"); cb.AppendSwitch("-nologo"); cb.AppendSwitch("--"); cb.AppendFileNamesIfNotNull(Sources, " "); return cb.ToString(); }
protected override string GenerateCommandLineCommands() { CommandLineBuilder builder = new CommandLineBuilder(); builder.AppendSwitch("spec"); builder.AppendSwitchIfNotNull("-AssemblyPath ", this.AssemblyPath); builder.AppendSwitchIfNotNull("-Verbosity ", this.Verbosity); builder.AppendSwitchIfTrue("-Force", this.Force); builder.AppendSwitch("-NonInteractive"); return builder.ToString(); }
/// <summary>See <see cref="ToolTask.GenerateCommandLineCommands"/>.</summary> protected override string GenerateCommandLineCommands() { CommandLineBuilder commandLineBuilder = new CommandLineBuilder(); commandLineBuilder.AppendSwitch("/nologo"); if (this.Force) { commandLineBuilder.AppendSwitch("/f"); } commandLineBuilder.AppendSwitch(this.Uninstall ? "/u" : "/i"); commandLineBuilder.AppendFileNameIfNotNull(this.Assembly); return commandLineBuilder.ToString(); }
/// <summary> /// Generates the command line commands. /// </summary> protected override string GenerateCommandLineCommands() { CommandLineBuilder builder = new CommandLineBuilder(); if (this.DelaySign) { builder.AppendSwitch("/delaysign"); } builder.AppendSwitchIfNotNull("/keyfile:", this.KeyFile); builder.AppendFileNameIfNotNull(this.Assembly); return builder.ToString(); }
protected override string GenerateCommandLineCommands() { CommandLineBuilder builder = new CommandLineBuilder(); builder.AppendSwitch("push"); builder.AppendFileNameIfNotNull(this.PackagePath); builder.AppendSwitchIfNotNull("-ApiKey ", this.ApiKey); builder.AppendSwitchIfNotNull("-ConfigFile ", this.ConfigFile); builder.AppendSwitchIfNotNull("-Source ", this.Source); builder.AppendSwitchIfNotNull("-Verbosity ", this.Verbosity); builder.AppendSwitch("-NonInteractive"); return builder.ToString(); }
/// <summary> /// This method constructs the correct Tracker.exe response file arguments from its parameters /// </summary> /// <param name="dllName">The name of the dll that will do the tracking</param> /// <param name="intermediateDirectory">Intermediate directory where tracking logs will be written</param> /// <param name="rootFiles">Rooting marker</param> /// <param name="cancelEventName">If a cancel event has been created that Tracker should be listening for, its name is passed here</param> /// <returns>The arguments as a string</returns> public static string TrackerResponseFileArguments(string dllName, string intermediateDirectory, string rootFiles, string cancelEventName) { CommandLineBuilder builder = new CommandLineBuilder(); builder.AppendSwitchIfNotNull("/d ", dllName); if (!String.IsNullOrEmpty(intermediateDirectory)) { intermediateDirectory = FileUtilities.NormalizePath(intermediateDirectory); // If the intermediate directory ends up with a trailing slash, then be rid of it! if (FileUtilities.EndsWithSlash(intermediateDirectory)) { intermediateDirectory = Path.GetDirectoryName(intermediateDirectory); } builder.AppendSwitchIfNotNull("/i ", intermediateDirectory); } builder.AppendSwitchIfNotNull("/r ", rootFiles); builder.AppendSwitchIfNotNull("/b ", cancelEventName); // b for break return(builder.ToString() + " "); }
/// <summary> /// Generates command line arguments for msdeploy.exe /// </summary> protected override string GenerateCommandLineCommands() { Utilities.CommandLineBuilder commandLine = new Utilities.CommandLineBuilder(); AddDestinationProviderSettingToObject(commandLine, "-source:", this.Source, m_strValueQuote, null, this); AddDestinationProviderSettingToObject(commandLine, "-dest:", this.Destination, m_strValueQuote, AdditionalDestinationProviderOptions, this); commandLine.AppendSwitchUnquotedIfNotNull("-verb:", m_verb); commandLine.AppendSwitchUnquotedIfNotNull("-failureLevel:", m_failureLevel); commandLine.AppendSwitchUnquotedIfNotNull("-xpath:", m_xpath); commandLine.AppendSwitchUnquotedIfNotNull("-replace:", m_replace); commandLine.AppendSwitchUnquotedIfNotNull("-skip:", m_skip); GenerateSwitchPerItem(commandLine, "-enableRule:", m_enableRule); GenerateSwitchPerItem(commandLine, "-disableRule:", m_disableRule); GenerateSwitchPerItem(commandLine, "-enableLink:", m_enableLink); GenerateSwitchPerItem(commandLine, "-disableLink:", m_disableLink); GenerateSwitchPerItem(commandLine, "-disableSkipDirective:", m_disableSkipDirective); GenerateSwitchPerItem(commandLine, "-enableSkipDirective:", m_enableSkipDirective); // this allow multiple replace rule to happen, we should consider do the same thing for skip: AddReplaceRulesToOptions(commandLine, m_replaceRuleItemsITaskItem, m_strValueQuote); AddSkipDirectiveToBaseOptions(commandLine, m_skipRuleItemsITaskItem, m_strValueQuote); AddImportDeclareParametersFilesOptions(commandLine, m_importDeclareParametersItems); AddDeclareParametersOptions(commandLine, m_declareParameterItems, m_strValueQuote, OptimisticParameterDefaultValue); AddImportSetParametersFilesOptions(commandLine, m_importSetParametersItems); AddSimpleSetParametersToObject(commandLine, m_simpleSetParamterItems, m_strValueQuote, OptimisticParameterDefaultValue); AddSetParametersToObject(commandLine, m_setParamterItems, m_strValueQuote, OptimisticParameterDefaultValue); if (m_xml) { commandLine.AppendSwitch("-xml"); } if (m_whatif) { commandLine.AppendSwitch("-whatif"); } if (m_verbose) { commandLine.AppendSwitch("-verbose"); } if (m_allowUntrusted) { commandLine.AppendSwitch("-allowUntrusted"); } if (m_useChecksum) { commandLine.AppendSwitch("-useChecksum"); } if (m_enableTransaction) { commandLine.AppendSwitch("-enableTransaction"); } if (m_retryAttempts > 0) { commandLine.AppendSwitchUnquotedIfNotNull("-retryAttempts=", m_retryAttempts.ToString(CultureInfo.InvariantCulture)); } if (m_retryInterval > 0) { commandLine.AppendSwitchUnquotedIfNotNull("-retryInterval=", m_retryInterval.ToString(CultureInfo.InvariantCulture)); } if (!string.IsNullOrEmpty(UserAgent)) { commandLine.AppendSwitchUnquotedIfNotNull("-userAgent=", string.Concat("\"", UserAgent, "\"")); } //IISExpress support //public const string AppHostConfigDirectory = "-appHostConfigDir"; // * public const string WebServerDirectory = "-webServerDir"; // public const string WebServerManifest = "-webServerManifest"; commandLine.AppendSwitchIfNotNull("-appHostConfigDir:", WebServerAppHostConfigDirectory); commandLine.AppendSwitchIfNotNull("-webServerDir:", WebServerDirectory); // bug in msdeploy.exe currently only take the file name commandLine.AppendSwitchIfNotNull("-webServerManifest:", System.IO.Path.GetFileName(WebServerManifest)); m_lastCommandLine = commandLine.ToString(); // show arguments in the output Log.LogMessage(Framework.MessageImportance.Low, string.Concat("\"", GenerateFullPathToTool(), "\" ", m_lastCommandLine)); return(m_lastCommandLine); }