public void AppendSwitchSimple()
 {
     CommandLineBuilder c = new CommandLineBuilder();
     c.AppendSwitch("/a");
     c.AppendSwitch("-b");
     Assert.Equal("/a -b", c.ToString());
 }
        protected override void GenerateCommandLineCommands(CommandLineBuilder commandLineBuilder)
        {
            if (Source != null)
            {
                foreach (var item in Source)
                {
                    commandLineBuilder.AppendSwitchIfNotNull("-Source ", item.ItemSpec);
                }
            }

            if (FallbackSource != null)
            {
                foreach (var item in FallbackSource)
                {
                    commandLineBuilder.AppendSwitchIfNotNull("-FallbackSource ", item.ItemSpec);
                }
            }

            if (NoCache)
            {
                commandLineBuilder.AppendSwitch("-NoCache");
            }

            if (DisableParallelProcessing)
            {
                commandLineBuilder.AppendSwitch("-DisableParallelProcessing");
            }

            commandLineBuilder.AppendSwitchIfNotNull("-PackageSaveMode ", PackageSaveMode);
        }
예제 #3
0
        protected override string GenerateCommandLineCommands()
        {
            CommandLineBuilder clb = new CommandLineBuilder();
            clb.AppendSwitch("describe");

            return clb.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();
        }
예제 #5
0
        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;
        }
예제 #6
0
        /// <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("update");
            builder.AppendFileNameIfNotNull(Package);
            builder.AppendSwitchIfNotNull("-Version ", Version);
            builder.AppendSwitchIfNotNull("-Source ", Source);
            builder.AppendSwitchIfNotNull("-OutputDirectory ", OutputDirectory);
            builder.AppendSwitchIfNotNull("-RepositoryPath ", RepositoryPath);
            builder.AppendSwitchIfNotNull("-OutputDirectory ", OutputDirectory);
            builder.AppendSwitchIfNotNull("-FileConflictAction ", FileConflictAction);
            builder.AppendSwitchIfNotNull("-Verbosity ", Verbosity);
            builder.AppendSwitchIfNotNull("-ConfigFile ", ConfigFile);

            if (Prerelease)
                builder.AppendSwitch("-Prerelease");
            if (Safe)
                builder.AppendSwitch("-Safe");
            if (Self)
                builder.AppendSwitch("-Self");

            builder.AppendSwitch("-NonInteractive");

            return builder.ToString();
        }
예제 #7
0
        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 ();
        }
예제 #8
0
        /// <summary>
        /// Construct the command line from the task properties by using the CommandLineBuilder
        /// </summary>
        /// <returns></returns>
        protected override string GenerateCommandLineCommands()
        {
            CommandLineBuilder builder = new CommandLineBuilder();

            foreach(ITaskItem iti in this._sources)
            {
                builder.AppendFileNameIfNotNull(iti);
            }

            if (this._configurationFile != null)
            {
                builder.AppendSwitchIfNotNull("/config:", new string[] {this._configurationFile}, ":");
            }

            if (this._filename != null)
            {
                builder.AppendSwitchIfNotNull("/fileName:", new string[] {this._filename}, ":");
            }

            // Log a High importance message stating the file that we are assembling
            Log.LogMessage(MessageImportance.High, "Assembling {0}", this._sources);

            // We have all of our switches added, return the commandline as a string
            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();
        }
예제 #10
0
 /// <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();
 }
예제 #11
0
 /// <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();
 }
예제 #12
0
 /// <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();
 }
예제 #13
0
        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();
        }
예제 #14
0
		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 ();
		}
예제 #15
0
 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 ();
     }
 }
예제 #16
0
        /// <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();
        }
예제 #17
0
        /// <summary>
        /// Generates the arguments.
        /// </summary>
        /// <param name="builder">The builder.</param>
        protected override void GenerateArguments(CommandLineBuilder builder)
        {
            builder.AppendSwitch("--count");

            base.GenerateArguments(builder);

            builder.AppendSwitch(Revision);
        }
예제 #18
0
        protected override string GenerateCommandLineCommands()
        {
            var args = new CommandLineBuilder ();

            args.AppendFileNameIfNotNull (Input);

            return args.ToString ();
        }
        protected override void GenerateCommandLineCommands(CommandLineBuilder commandLineBuilder)
        {
            commandLineBuilder.AppendSwitch("setApiKey");

            commandLineBuilder.AppendFileNameIfNotNull(ApiKey);

            commandLineBuilder.AppendSwitchIfNotNullOrWhiteSpace("-Source ", Source);
        }
예제 #20
0
        /// <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();
        }
예제 #21
0
        /// <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();
        }
예제 #22
0
		/// <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 args = new CommandLineBuilder();

			args.AppendSwitch("pack");
			args.AppendFileNameIfNotNull(this.NuSpec);
			args.AppendSwitchIfNotNull("-b ", this.BaseDirectory);
			args.AppendSwitchIfNotNull("-o ", this.OutputPackageDirectory);

			return args.ToString();
		}
예제 #23
0
        protected override void GenerateCommandLineCommands(CommandLineBuilder commandLineBuilder)
        {
            commandLineBuilder.AppendSwitch("config");

            commandLineBuilder.AppendFileNameIfNotNull(Key);

            commandLineBuilder.AppendSwitchIfAny("-Set ", Set);

            commandLineBuilder.AppendSwitchIfTrue("-AsPath", AsPath);
        }
예제 #24
0
		protected override string GenerateCommandLineCommands() {
			var args = new CommandLineBuilder();

			args.AppendSwitch("a");
			args.AppendSwitch("--");

			args.AppendFileNameIfNotNull(this.ZipFileName);

			return args.ToString();
		}
예제 #25
0
        protected override string GenerateCommandLineCommands()
        {
            var builder = new CommandLineBuilder();
            builder.AppendSwitch(File);

            if (Args != null)
                builder.AppendSwitch(Args);

            return builder.ToString();
        }
예제 #26
0
        protected override void GenerateCommandLineCommands(CommandLineBuilder commandLineBuilder)
        {
            commandLineBuilder.AppendSwitch("add");

            commandLineBuilder.AppendFileNameIfNotNull(Package);

            commandLineBuilder.AppendSwitchIfNotNullOrWhiteSpace("-Source ", Source);

            commandLineBuilder.AppendSwitchIfTrue("-Expand", Expand);
        }
예제 #27
0
        protected override string GenerateCommandLineCommands()
        {
            var builder = new CommandLineBuilder();

            builder.AppendSwitchIfNotNull("/source:", SourceDirectory);
            builder.AppendSwitchIfNotNull("/target:", TargetDirectory);
            builder.AppendSwitchIfNotNull("/output:", OutputUpdateFile);

            return builder.ToString();
        }
예제 #28
0
        /// <summary>
        /// Generates the arguments.
        /// </summary>
        /// <param name="builder">The builder.</param>
        protected override void GenerateArguments(CommandLineBuilder builder)
        {
            builder.AppendSwitch("--verify");

            if (Short)
                builder.AppendSwitch("--short");

            base.GenerateArguments(builder);

            builder.AppendSwitch(Revision);
        }
예제 #29
0
 private string AppendArgumentForProperty(CommandLineBuilder builder, string name, string value)
 {
     PropertyWrapper current;
     ToolProperties.TryGetValue(name, out current);
     if (current != null && value.Length > 0)
     {
         // call appropriate function for type
         m_typeFunctionMap[current.PropertyType](builder, current.Property, value);
     }
     return string.Empty;
 }
예제 #30
0
        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();
        }
예제 #31
0
 /// <summary>
 /// Utility function to help to generate Switch per item
 /// </summary>
 /// <param name="commandLine"></param>
 /// <param name="strSwitch"></param>
 /// <param name="args"></param>
 private static void GenerateSwitchPerItem(Utilities.CommandLineBuilder commandLine, string strSwitch, string args)
 {
     if (!string.IsNullOrEmpty(args))
     {
         foreach (string dl in args.Split(new char[] { ';' }))
         {
             if (!string.IsNullOrEmpty(dl))
             {
                 commandLine.AppendSwitchUnquotedIfNotNull(strSwitch, dl);
             }
         }
     }
 }
예제 #32
0
        /// <summary>
        /// Utility to build DeclareParameterOptions
        /// </summary>
        /// <param name="commandLineBuilder"></param>
        /// <param name="items"></param>
        static public void AddDeclareParametersOptions(Utilities.CommandLineBuilder commandLineBuilder, Framework.ITaskItem[] originalItems, string valueQuote, bool foptimisticParameterDefaultValue)
        {
            System.Collections.Generic.IList <Framework.ITaskItem> items = MsDeploy.Utility.SortParametersTaskItems(originalItems, foptimisticParameterDefaultValue, MsDeploy.DeclareParameterMetadata.DefaultValue.ToString());
            if (commandLineBuilder != null && items != null)
            {
                System.Collections.Generic.List <string> arguments = new System.Collections.Generic.List <string>(6);
                System.Collections.Generic.Dictionary <string, string> lookupDictionary = new System.Collections.Generic.Dictionary <string, string>(items.Count);

                foreach (Framework.ITaskItem item in items)
                {
                    AddDeclareParameterToCommandArgument(arguments, item, valueQuote, lookupDictionary);
                    commandLineBuilder.AppendSwitchUnquotedIfNotNull("-declareParam:", arguments.Count == 0 ? null : string.Join(",", arguments.ToArray()));
                }
            }
        }
예제 #33
0
        static public void AddSkipDirectiveToBaseOptions(Utilities.CommandLineBuilder commandLineBuilder, Framework.ITaskItem[] skipRuleItems, string valueQuoteChar)
        {
            if (commandLineBuilder != null &&
                skipRuleItems != null)   // Dev10 bug 496639 foreach will throw the exception if the replaceRuleItem is null
            {
                System.Collections.Generic.List <string> arguments = new System.Collections.Generic.List <string>(6);

                foreach (Framework.ITaskItem item in skipRuleItems)
                {
                    arguments.Clear();
                    MsDeploy.Utility.BuildArgumentsBaseOnEnumTypeName(item, arguments, typeof(MsDeploy.SkipRuleMetadata), valueQuoteChar);
                    commandLineBuilder.AppendSwitchUnquotedIfNotNull("-skip:", arguments.Count == 0? null : string.Join(",", arguments.ToArray()));
                }
            }
        }
예제 #34
0
 static internal void AddImportParametersFilesOptions(Utilities.CommandLineBuilder commandLineBuilder, string parameterFlag, Framework.ITaskItem[] items)
 {
     if (commandLineBuilder != null &&
         !string.IsNullOrEmpty(parameterFlag) &&
         items != null)   // Dev10 bug 496639 foreach will throw the exception if the replaceRuleItem is null
     {
         foreach (Framework.ITaskItem item in items)
         {
             string fileName = item.ItemSpec;
             if (!string.IsNullOrEmpty(fileName))
             {
                 commandLineBuilder.AppendSwitch(string.Concat(parameterFlag, "\"", fileName, "\""));
             }
         }
     }
 }
예제 #35
0
        /// <summary>
        /// Utility function to set SimpleeSyncParameter Name/Value
        /// </summary>
        /// <param name="commandLineBuilder"></param>
        /// <param name="items"></param>
        static public void AddSimpleSetParametersToObject(Utilities.CommandLineBuilder commandLineBuilder, Framework.ITaskItem[] originalItems, string valueQuoteChar, bool foptimisticParameterDefaultValue)
        {
            System.Collections.Generic.IList <Framework.ITaskItem> items = MsDeploy.Utility.SortParametersTaskItems(originalItems, foptimisticParameterDefaultValue, MsDeploy.SimpleSyncParameterMetadata.Value.ToString());
            if (commandLineBuilder != null && items != null)
            {
                System.Collections.Generic.List <string> arguments = new System.Collections.Generic.List <string>(6);
                foreach (Framework.ITaskItem item in items)
                {
                    arguments.Clear();

                    // special for name
                    string name = item.ItemSpec;
                    if (!string.IsNullOrEmpty(name))
                    {
                        string valueData = MsDeploy.Utility.PutValueInQuote(name, valueQuoteChar);
                        arguments.Add(string.Concat("name=", valueData));
                    }
                    // the rest, build on the enum name

                    MsDeploy.Utility.BuildArgumentsBaseOnEnumTypeName(item, arguments, typeof(MsDeploy.SimpleSyncParameterMetadata), valueQuoteChar);
                    commandLineBuilder.AppendSwitchUnquotedIfNotNull("-setParam:", arguments.Count == 0 ? null : string.Join(",", arguments.ToArray()));
                }
            }
        }
예제 #36
0
        /// <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);
        }
예제 #37
0
        static public void AddDestinationProviderSettingToObject(Utilities.CommandLineBuilder commandLineBuilder, string dest, Framework.ITaskItem[] items, string valueQuoteChar,
                                                                 Framework.ITaskItem[] additionalProviderItems, MSDeploy msdeploy)
        {
            //commandLineBuilder.AppendSwitchUnquotedIfNotNull("-source:", m_source);
            //commandLineBuilder.AppendSwitchUnquotedIfNotNull("-dest:", m_dest);
            System.Collections.Generic.List <string> arguments = new System.Collections.Generic.List <string>(6);

            if (items != null && items.GetLength(0) == 1)
            {
                Framework.ITaskItem taskItem = items[0];
                string provider  = taskItem.ItemSpec;
                string path      = taskItem.GetMetadata("Path");
                string valueData = MsDeploy.Utility.PutValueInQuote(path, valueQuoteChar);
                string setData   = (string.IsNullOrEmpty(path)) ? provider : string.Concat(provider, "=", valueData);
                arguments.Add(setData);

                //Commonly supported provider settings:
                //    computerName=<name>     Name of remote computer or proxy-URL
                //    wmsvc=<name>            Name of remote computer or proxy-URL for the Web
                //                            Management Service (wmsvc)
                //    userName=<name>         User name to authenticate
                //    password=<password>     Password of user name
                //    encryptPassword=<pwd>   Password to use for encryption related operations
                //    includeAcls=<bool>      If true, include ACLs in the operation for the
                //                            specified path

                foreach (string name in taskItem.MetadataNames)
                {
                    if (!MsDeploy.Utility.IsInternalMsdeployWellKnownItemMetadata(name))
                    {
                        string value = taskItem.GetMetadata(name);
                        if (!string.IsNullOrEmpty(value))
                        {
                            valueData = MsDeploy.Utility.PutValueInQuote(value, valueQuoteChar);
                            setData   = string.Concat(name, "=", valueData);
                            arguments.Add(setData);
                        }
                    }
                    else
                    {
                        MsDeploy.Utility.IISExpressMetadata expressMetadata;
                        if (System.Enum.TryParse <MsDeploy.Utility.IISExpressMetadata>(name, out expressMetadata))
                        {
                            string value = taskItem.GetMetadata(name);
                            if (!string.IsNullOrEmpty(value))
                            {
                                switch (expressMetadata)
                                {
                                case Utility.IISExpressMetadata.WebServerAppHostConfigDirectory:
                                    msdeploy.WebServerAppHostConfigDirectory = value;
                                    break;

                                case Utility.IISExpressMetadata.WebServerDirectory:
                                    msdeploy.WebServerDirectory = value;
                                    break;

                                case Utility.IISExpressMetadata.WebServerManifest:
                                    msdeploy.WebServerManifest = value;
                                    break;
                                }
                            }
                        }
                    }
                }
            }
            // If additional parameters are specified, we add these too. the itemSpec will be something like iisApp, contentPath, etc and
            // each item should have a name\value pair defined as metadata. Each provider will be written as itemSpec.Name=Value
            if (additionalProviderItems != null)
            {
                foreach (Framework.ITaskItem item in additionalProviderItems)
                {
                    if (!string.IsNullOrEmpty(item.ItemSpec))
                    {
                        string settingName  = item.GetMetadata("Name");
                        string settingValue = item.GetMetadata("Value");
                        if (!string.IsNullOrEmpty(settingName) && !string.IsNullOrEmpty(settingValue))
                        {
                            string providerString = string.Concat(item.ItemSpec, ".", settingName, "=", settingValue);
                            arguments.Add(providerString);
                        }
                    }
                }
            }

            commandLineBuilder.AppendSwitchUnquotedIfNotNull(dest, arguments.Count == 0 ? null : string.Join(",", arguments.ToArray()));
            return;
        }
예제 #38
0
        /// <summary>
        /// Utility function to setParameters in type, scope, match, value of SyncParameter
        /// </summary>
        /// <param name="commandLineBuilder"></param>
        /// <param name="items"></param>
        static public void AddSetParametersToObject(Utilities.CommandLineBuilder commandLineBuilder, Framework.ITaskItem[] originalItems, string valueQuote, bool foptimisticParameterDefaultValue)
        {
            System.Collections.Generic.IList <Framework.ITaskItem> items = MsDeploy.Utility.SortParametersTaskItems(originalItems, foptimisticParameterDefaultValue, MsDeploy.ExistingSyncParameterMetadata.Value.ToString());
            if (commandLineBuilder != null && items != null)
            {
                System.Collections.Generic.List <string> arguments = new System.Collections.Generic.List <string>(6);
                System.Collections.Generic.Dictionary <string, string> lookupDictionary    = new System.Collections.Generic.Dictionary <string, string>(items.Count);
                System.Collections.Generic.Dictionary <string, string> nameValueDictionary = new System.Collections.Generic.Dictionary <string, string>(items.Count, System.StringComparer.OrdinalIgnoreCase);

                foreach (Framework.ITaskItem item in items)
                {
                    arguments.Clear();

                    System.Collections.Generic.List <string> idenities = new System.Collections.Generic.List <string>(6);

                    string name = item.ItemSpec;
                    if (!string.IsNullOrEmpty(name))
                    {
                        string element = item.GetMetadata(MsDeploy.ExistingParameterValiationMetadata.Element.ToString());
                        if (string.IsNullOrEmpty(element))
                        {
                            element = "parameterEntry";
                        }

                        if (string.Compare(element, "parameterEntry", System.StringComparison.OrdinalIgnoreCase) == 0)
                        {
                            idenities.Add(name);
                            foreach (string dPIdentity in System.Enum.GetNames(typeof(MsDeploy.ExistingDeclareParameterMetadata)))
                            {
                                idenities.Add(item.GetMetadata(dPIdentity));
                            }

                            string identity = string.Join(",", idenities.ToArray());
                            if (!lookupDictionary.ContainsKey(identity))
                            {
                                string data          = null;
                                bool   fExistingName = nameValueDictionary.ContainsKey(name);

                                if (nameValueDictionary.ContainsKey(name))
                                {
                                    data = nameValueDictionary[name];
                                }
                                else
                                {
                                    data = item.GetMetadata(MsDeploy.ExistingSyncParameterMetadata.Value.ToString());
                                    nameValueDictionary.Add(name, data);
                                }

                                // the rest, build on the Enum Name
                                MsDeploy.Utility.BuildArgumentsBaseOnEnumTypeName(item, arguments, typeof(MsDeploy.ExistingDeclareParameterMetadata), valueQuote);
                                if (arguments.Count > 0 && !string.IsNullOrEmpty(data))
                                {
                                    arguments.Add(string.Concat(MsDeploy.ExistingSyncParameterMetadata.Value.ToString().ToLower(System.Globalization.CultureInfo.InvariantCulture),
                                                                "=", MsDeploy.Utility.PutValueInQuote(data, valueQuote)));
                                }
                                lookupDictionary.Add(identity, name);
                            }
                        }
                        else if (string.Compare(element, "parameterValidation", System.StringComparison.OrdinalIgnoreCase) == 0)
                        {
                            System.Diagnostics.Debug.Assert(false, "msdeploy.exe doesn't support parameterValidation entry in the command line for declareParameter yet.");
                        }
                    }
                    commandLineBuilder.AppendSwitchUnquotedIfNotNull("-setParam:", arguments.Count == 0 ? null : string.Join(",", arguments.ToArray()));
                }
            }
        }
예제 #39
0
 static public void AddImportSetParametersFilesOptions(Utilities.CommandLineBuilder commandLineBuilder, Framework.ITaskItem[] items)
 {
     AddImportParametersFilesOptions(commandLineBuilder, "-setParamFile:", items);
 }