AppendFileNameIfNotNull() public method

Appends a file name quoting it if necessary. This method appends a space to the command line (if it's not currently empty) before the file name.
public AppendFileNameIfNotNull ( string fileName ) : void
fileName string File name to append, if it's null this method has no effect
return void
Exemplo n.º 1
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 ();
		}
        /// <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();
        }
Exemplo n.º 3
0
        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 ();
        }
Exemplo n.º 4
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("push");
            builder.AppendFileNameIfNotNull(File);
            builder.AppendFileNameIfNotNull(APIKey);
            builder.AppendSwitchIfNotNull("-Source ", Source);
            if (CreateOnly)
                builder.AppendSwitch("-CreateOnly");

            return builder.ToString();
        }
Exemplo n.º 5
0
        protected override void GenerateCommandLineCommands(CommandLineBuilder commandLineBuilder)
        {
            commandLineBuilder.AppendSwitch("delete");

            commandLineBuilder.AppendFileNameIfNotNull(PackageId);

            commandLineBuilder.AppendFileNameIfNotNull(PackageVersion);

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

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

            commandLineBuilder.AppendSwitchIfTrue("-NoPrompt", NoPrompt);
        }
Exemplo n.º 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("delete");
            builder.AppendFileNameIfNotNull(Package);
            builder.AppendFileNameIfNotNull(Version);
            builder.AppendSwitchIfNotNull("-ApiKey ", ApiKey);
            builder.AppendSwitchIfNotNull("-Source ", Source);
            builder.AppendSwitchIfNotNull("-Verbosity ", Verbosity);
            builder.AppendSwitchIfNotNull("-ConfigFile ", ConfigFile);

            builder.AppendSwitch("-NonInteractive");

            return builder.ToString();
        }
Exemplo n.º 7
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();
        }
Exemplo n.º 8
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();
        }
Exemplo n.º 9
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();
        }
Exemplo n.º 10
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 ();
        }
        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();
        }
Exemplo n.º 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("/config:", ConfigFile);
     builder.AppendFileNameIfNotNull(ManifestFile);
     return builder.ToString();
 }
        protected override void GenerateCommandLineCommands(CommandLineBuilder commandLineBuilder)
        {
            commandLineBuilder.AppendSwitch("setApiKey");

            commandLineBuilder.AppendFileNameIfNotNull(ApiKey);

            commandLineBuilder.AppendSwitchIfNotNullOrWhiteSpace("-Source ", Source);
        }
Exemplo n.º 14
0
        protected override string GenerateCommandLineCommands()
        {
            var args = new CommandLineBuilder ();

            args.AppendFileNameIfNotNull (Input);

            return args.ToString ();
        }
Exemplo n.º 15
0
        protected override void GenerateCommandLineCommands(CommandLineBuilder commandLineBuilder)
        {
            commandLineBuilder.AppendSwitch("add");

            commandLineBuilder.AppendFileNameIfNotNull(Package);

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

            commandLineBuilder.AppendSwitchIfTrue("-Expand", Expand);
        }
Exemplo n.º 16
0
		protected override string GenerateCommandLineCommands() {
			var args = new CommandLineBuilder();

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

			args.AppendFileNameIfNotNull(this.ZipFileName);

			return args.ToString();
		}
Exemplo n.º 17
0
        protected override void GenerateCommandLineCommands(CommandLineBuilder commandLineBuilder)
        {
            commandLineBuilder.AppendSwitch("config");

            commandLineBuilder.AppendFileNameIfNotNull(Key);

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

            commandLineBuilder.AppendSwitchIfTrue("-AsPath", AsPath);
        }
Exemplo n.º 18
0
        protected override string GenerateCommandLineCommands()
        {
            var args = new CommandLineBuilder ();

            if (!string.IsNullOrEmpty (SymbolFile)) {
                args.AppendSwitch ("-i");
                args.AppendSwitch ("-s");
                args.AppendFileNameIfNotNull (SymbolFile);
            }

            if (IsFramework) {
                // Only remove debug symbols from frameworks.
                args.AppendSwitch ("-S");
            }

            args.AppendFileNameIfNotNull (Executable);

            return args.ToString ();
        }
Exemplo n.º 19
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();
        }
Exemplo n.º 20
0
        /// <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;
            }
        }
Exemplo n.º 21
0
		/// <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();
		}
Exemplo n.º 22
0
		/// <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();
		}
Exemplo n.º 23
0
		/// <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();
		}
Exemplo n.º 24
0
        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();
        }
Exemplo n.º 25
0
        protected override string GenerateCommandLineCommands()
        {
            var builder = new CommandLineBuilder();
            builder.AppendSwitch("pack");
            builder.AppendFileNameIfNotNull(Package);
            builder.AppendSwitchIfNotNull("-Version ", Version);
            builder.AppendSwitchIfNotNull("-BasePath ", BasePath);
            builder.AppendSwitchIfNotNull("-OutputDirectory ", OutputDirectory);

            if (Symbols)
              builder.AppendSwitch("-symbols");

            return builder.ToString();
        }
Exemplo n.º 26
0
        protected override void GenerateCommandLineCommands(CommandLineBuilder commandLineBuilder)
        {
            commandLineBuilder.AppendSwitch("push");

            commandLineBuilder.AppendFileNameIfNotNull(Package);

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

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

            commandLineBuilder.AppendSwitchIfNotNullOrWhiteSpace("-Timeout ", PushTimeout);

            commandLineBuilder.AppendSwitchIfTrue("-DisableBuffering", DisableBuffering);
        }
Exemplo n.º 27
0
        protected override void GenerateCommandLineCommands(CommandLineBuilder commandLineBuilder)
        {
            commandLineBuilder.AppendSwitch("list");

            commandLineBuilder.AppendFileNameIfNotNull(SearchTerms);

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

            commandLineBuilder.AppendSwitchIfTrue("-AllVersions", AllVersions);

            commandLineBuilder.AppendSwitchIfTrue("-Prerelease", Prerelease);

            commandLineBuilder.AppendSwitchIfTrue("-IncludeDelisted", IncludeDelisted);
        }
		protected override string GenerateCommandLineCommands()
		{
			var builder = new CommandLineBuilder();
			builder.AppendSwitch(NuGetVerb);

			builder.AppendFileNameIfNotNull(PackagePath);
			builder.AppendSwitch("-NonInteractive");
			builder.AppendSwitchIfNotNull("-Source ", Source);
			builder.AppendSwitchIfNotNull("-ApiKey ", ApiKey);
			builder.AppendSwitchIfNotNull("-Verbosity ", Verbosity);
			builder.AppendSwitchIfNotNull("-ConfigFile ", ConfigFile);
			builder.AppendSwitchIfNotNullOrEmpty(PushArguments);

			return builder.ToString();
		}
Exemplo n.º 29
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("restore");
            builder.AppendFileNameIfNotNull(Solution);
            builder.AppendSwitchIfNotNull("-PackagesDirectory ", PackagesDirectory);
            builder.AppendSwitchIfNotNull("-SolutionDirectory ", SolutionDirectory);
            builder.AppendSwitchIfNotNull("-Source ", Source);
            builder.AppendSwitchIfNotNull("-Verbosity ", Verbosity);
            builder.AppendSwitchIfNotNull("-ConfigFile ", ConfigFile);

            if (DisableParallelProcessing)
                builder.AppendSwitch("-DisableParallelProcessing");
            if (NoCache)
                builder.AppendSwitch("-NoCache");

            builder.AppendSwitch("-NonInteractive");

            return builder.ToString();
        }
Exemplo n.º 30
0
        protected override string GenerateCommandLineCommands()
        {
            var builder = new CommandLineBuilder();
            builder.AppendSwitch("pack");
            builder.AppendFileNameIfNotNull(NuSpecPath);
            builder.AppendSwitchIfNotNull("-OutputDirectory ", OutputDirectory);

            if (Symbols)
                builder.AppendSwitch("-Symbols");

            if (NoPackageAnalysis)
                builder.AppendSwitch("-NoPackageAnalysis");

            if (NoDefaultExcludes)
                builder.AppendSwitch("-NoDefaultExcludes");

            if (ExcludeEmptyDirectories)
                builder.AppendSwitch("-ExcludeEmptyDirectories");

            return builder.ToString();
        }