예제 #1
0
파일: Respack.cs 프로젝트: carrie901/mono
		void AddCommandLineCommands (CommandLineBuilderExtension commandLine)
		{
			if (Resources.Length == 0)
				return;

			commandLine.AppendFileNameIfNotNull (OutputFile);

			commandLine.AppendFileNamesIfNotNull (Resources, " ");
		}
 protected internal override void AddResponseFileCommands(CommandLineBuilderExtension commandLine)
 {
     if (((this.OutputAssembly == null) && (this.Sources != null)) && ((this.Sources.Length > 0) && (this.ResponseFiles == null)))
     {
         try
         {
             this.OutputAssembly = new TaskItem(Path.GetFileNameWithoutExtension(this.Sources[0].ItemSpec));
         }
         catch (ArgumentException exception)
         {
             throw new ArgumentException(exception.Message, "Sources");
         }
         if (string.Compare(this.TargetType, "library", StringComparison.OrdinalIgnoreCase) == 0)
         {
             ITaskItem outputAssembly = this.OutputAssembly;
             outputAssembly.ItemSpec = outputAssembly.ItemSpec + ".dll";
         }
         else if (string.Compare(this.TargetType, "module", StringComparison.OrdinalIgnoreCase) == 0)
         {
             ITaskItem item2 = this.OutputAssembly;
             item2.ItemSpec = item2.ItemSpec + ".netmodule";
         }
         else
         {
             ITaskItem item3 = this.OutputAssembly;
             item3.ItemSpec = item3.ItemSpec + ".exe";
         }
     }
     commandLine.AppendSwitchIfNotNull("/addmodule:", this.AddModules, ",");
     commandLine.AppendSwitchWithInteger("/codepage:", base.Bag, "CodePage");
     this.ConfigureDebugProperties();
     commandLine.AppendPlusOrMinusSwitch("/debug", base.Bag, "EmitDebugInformation");
     commandLine.AppendSwitchIfNotNull("/debug:", this.DebugType);
     commandLine.AppendPlusOrMinusSwitch("/delaysign", base.Bag, "DelaySign");
     commandLine.AppendSwitchWithInteger("/filealign:", base.Bag, "FileAlignment");
     commandLine.AppendSwitchIfNotNull("/keycontainer:", this.KeyContainer);
     commandLine.AppendSwitchIfNotNull("/keyfile:", this.KeyFile);
     commandLine.AppendSwitchIfNotNull("/linkresource:", this.LinkResources, new string[] { "LogicalName", "Access" });
     commandLine.AppendWhenTrue("/nologo", base.Bag, "NoLogo");
     commandLine.AppendWhenTrue("/nowin32manifest", base.Bag, "NoWin32Manifest");
     commandLine.AppendPlusOrMinusSwitch("/optimize", base.Bag, "Optimize");
     commandLine.AppendSwitchIfNotNull("/out:", this.OutputAssembly);
     commandLine.AppendSwitchIfNotNull("/resource:", this.Resources, new string[] { "LogicalName", "Access" });
     commandLine.AppendSwitchIfNotNull("/target:", this.TargetType);
     commandLine.AppendPlusOrMinusSwitch("/warnaserror", base.Bag, "TreatWarningsAsErrors");
     commandLine.AppendWhenTrue("/utf8output", base.Bag, "Utf8Output");
     commandLine.AppendSwitchIfNotNull("/win32icon:", this.Win32Icon);
     commandLine.AppendSwitchIfNotNull("/win32manifest:", this.Win32Manifest);
     commandLine.AppendFileNamesIfNotNull(this.Sources, " ");
 }
 protected internal override void AddResponseFileCommands(CommandLineBuilderExtension commandLine)
 {
     if (((this.OutputAssembly == null) && (this.Sources != null)) && ((this.Sources.Length > 0) && (this.ResponseFiles == null)))
     {
         try
         {
             this.OutputAssembly = new TaskItem(Path.GetFileNameWithoutExtension(this.Sources[0].ItemSpec));
         }
         catch (ArgumentException exception)
         {
             throw new ArgumentException(exception.Message, "Sources");
         }
         if (string.Compare(this.TargetType, "library", StringComparison.OrdinalIgnoreCase) == 0)
         {
             ITaskItem outputAssembly = this.OutputAssembly;
             outputAssembly.ItemSpec = outputAssembly.ItemSpec + ".dll";
         }
         else if (string.Compare(this.TargetType, "module", StringComparison.OrdinalIgnoreCase) == 0)
         {
             ITaskItem item2 = this.OutputAssembly;
             item2.ItemSpec = item2.ItemSpec + ".netmodule";
         }
         else
         {
             ITaskItem item3 = this.OutputAssembly;
             item3.ItemSpec = item3.ItemSpec + ".exe";
         }
     }
     commandLine.AppendSwitchIfNotNull("/addmodule:", this.AddModules, ",");
     commandLine.AppendSwitchWithInteger("/codepage:", base.Bag, "CodePage");
     this.ConfigureDebugProperties();
     commandLine.AppendPlusOrMinusSwitch("/debug", base.Bag, "EmitDebugInformation");
     commandLine.AppendSwitchIfNotNull("/debug:", this.DebugType);
     commandLine.AppendPlusOrMinusSwitch("/delaysign", base.Bag, "DelaySign");
     commandLine.AppendSwitchWithInteger("/filealign:", base.Bag, "FileAlignment");
     commandLine.AppendSwitchIfNotNull("/keycontainer:", this.KeyContainer);
     commandLine.AppendSwitchIfNotNull("/keyfile:", this.KeyFile);
     commandLine.AppendSwitchIfNotNull("/linkresource:", this.LinkResources, new string[] { "LogicalName", "Access" });
     commandLine.AppendWhenTrue("/nologo", base.Bag, "NoLogo");
     commandLine.AppendWhenTrue("/nowin32manifest", base.Bag, "NoWin32Manifest");
     commandLine.AppendPlusOrMinusSwitch("/optimize", base.Bag, "Optimize");
     commandLine.AppendSwitchIfNotNull("/out:", this.OutputAssembly);
     commandLine.AppendSwitchIfNotNull("/resource:", this.Resources, new string[] { "LogicalName", "Access" });
     commandLine.AppendSwitchIfNotNull("/target:", this.TargetType);
     commandLine.AppendPlusOrMinusSwitch("/warnaserror", base.Bag, "TreatWarningsAsErrors");
     commandLine.AppendWhenTrue("/utf8output", base.Bag, "Utf8Output");
     commandLine.AppendSwitchIfNotNull("/win32icon:", this.Win32Icon);
     commandLine.AppendSwitchIfNotNull("/win32manifest:", this.Win32Manifest);
     commandLine.AppendFileNamesIfNotNull(this.Sources, " ");
 }
예제 #4
0
        protected internal override void AddCommandLineCommands(CommandLineBuilderExtension commandLine)
        {
#if RUNTIME_TYPE_NETCORE
            commandLine.AppendFileNameIfNotNull(_executablePath.Value);
            commandLine.AppendTextUnquoted(" ");
#endif
            commandLine.AppendSwitchIfTrue("/noconfig", NoConfig);

            if (References != null)
            {
                foreach (ITaskItem reference in References)
                {
                    commandLine.AppendSwitchIfNotNull(ReferenceSwitch, reference.ItemSpec);
                }
            }

            commandLine.AppendPlusOrMinusSwitch("/deterministic", Deterministic);
            commandLine.AppendSwitchIfTrue("/nologo", NoLogo);
            commandLine.AppendPlusOrMinusSwitch("/optimize", Optimize);
            commandLine.AppendSwitchIfNotNull("/target:", TargetType);
            commandLine.AppendSwitchIfNotNull("/out:", OutputAssembly);
            commandLine.AppendFileNamesIfNotNull(Sources, " ");
        }
예제 #5
0
            /// <summary>
            /// Generate the command line to be passed to resgen.exe, sans the path to the tool.
            /// </summary>
            private void GenerateResGenCommands(CommandLineBuilderExtension resGenArguments, bool useForResponseFile)
            {
                resGenArguments = resGenArguments ?? new CommandLineBuilderExtension();

                if (ResGen.IsNullOrEmpty(OutputFiles))
                {
                    GenerateOutputFileNames();
                }

                // Append boolean flags if requested
                string useSourcePathSwitch = "/useSourcePath" + (useForResponseFile ? "\n" : String.Empty);
                string publicClassSwitch   = "/publicClass" + (useForResponseFile ? "\n" : String.Empty);

                resGenArguments.AppendWhenTrue(useSourcePathSwitch, Bag, "UseSourcePath");
                resGenArguments.AppendWhenTrue(publicClassSwitch, Bag, "PublicClass");

                // append the references, if any
                if (References != null)
                {
                    foreach (ITaskItem reference in References)
                    {
                        // ResGen.exe response files frown on quotes in filenames, even if there are
                        // spaces in the names of the files.
                        if (useForResponseFile && reference != null)
                        {
                            resGenArguments.AppendTextUnquoted("/r:");
                            resGenArguments.AppendTextUnquoted(reference.ItemSpec);
                            resGenArguments.AppendTextUnquoted("\n");
                        }
                        else
                        {
                            resGenArguments.AppendSwitchIfNotNull("/r:", reference);
                        }
                    }
                }

                if (String.IsNullOrEmpty(StronglyTypedLanguage))
                {
                    // append the compile switch
                    resGenArguments.AppendSwitch("/compile" + (useForResponseFile ? "\n" : String.Empty));

                    // append the resources to compile
                    if (InputFiles != null && InputFiles.Length > 0)
                    {
                        ITaskItem[] inputFiles  = InputFiles;
                        ITaskItem[] outputFiles = OutputFiles;

                        for (int i = 0; i < inputFiles.Length; ++i)
                        {
                            if (useForResponseFile)
                            {
                                // ResGen.exe response files frown on quotes in filenames, even if there are
                                // spaces in the names of the files.
                                if (inputFiles[i] != null && outputFiles[i] != null)
                                {
                                    resGenArguments.AppendTextUnquoted(inputFiles[i].ItemSpec);
                                    resGenArguments.AppendTextUnquoted(",");
                                    resGenArguments.AppendTextUnquoted(outputFiles[i].ItemSpec);
                                    resGenArguments.AppendTextUnquoted("\n");
                                }
                            }
                            else
                            {
                                resGenArguments.AppendFileNamesIfNotNull
                                (
                                    new ITaskItem[] { inputFiles[i], outputFiles[i] },
                                    ","
                                );
                            }
                        }
                    }
                }
                else
                {
                    // append the resource to compile
                    resGenArguments.AppendFileNamesIfNotNull(InputFiles, " ");
                    resGenArguments.AppendFileNamesIfNotNull(OutputFiles, " ");

                    // append the strongly-typed resource details
                    resGenArguments.AppendSwitchIfNotNull
                    (
                        "/str:",
                        new string[] { StronglyTypedLanguage, StronglyTypedNamespace, StronglyTypedClassName, StronglyTypedFileName },
                        ","
                    );
                }
            }
예제 #6
0
        /// <summary>
        /// Fills the provided CommandLineBuilderExtension with those switches and other information that can go into a response file.
        /// </summary>
        protected internal override void AddResponseFileCommands(CommandLineBuilderExtension commandLine)
        {
            // If outputAssembly is not specified, then an "/out: <name>" option won't be added to
            // overwrite the one resulting from the OutputAssembly member of the CompilerParameters class.
            // In that case, we should set the outputAssembly member based on the first source file.
            if (
                    (OutputAssembly == null) &&
                    (Sources != null) &&
                    (Sources.Length > 0) &&
                    (this.ResponseFiles == null)    // The response file may already have a /out: switch in it, so don't try to be smart here.
                )
            {
                try
                {
                    OutputAssembly = new TaskItem(Path.GetFileNameWithoutExtension(Sources[0].ItemSpec));
                }
                catch (ArgumentException e)
                {
                    throw new ArgumentException(e.Message, "Sources");
                }
                if (String.Compare(TargetType, "library", StringComparison.OrdinalIgnoreCase) == 0)
                {
                    OutputAssembly.ItemSpec += ".dll";
                }
                else if (String.Compare(TargetType, "module", StringComparison.OrdinalIgnoreCase) == 0)
                {
                    OutputAssembly.ItemSpec += ".netmodule";
                }
                else
                {
                    OutputAssembly.ItemSpec += ".exe";
                }
            }

            commandLine.AppendSwitchIfNotNull("/addmodule:", this.AddModules, ",");
            commandLine.AppendSwitchWithInteger("/codepage:", this.Bag, "CodePage");

            ConfigureDebugProperties();

            // The "DebugType" parameter should be processed after the "EmitDebugInformation" parameter
            // because it's more specific.  Order matters on the command-line, and the last one wins.
            // /debug+ is just a shorthand for /debug:full.  And /debug- is just a shorthand for /debug:none.

            commandLine.AppendPlusOrMinusSwitch("/debug", this.Bag, "EmitDebugInformation");
            commandLine.AppendSwitchIfNotNull("/debug:", this.DebugType);

            commandLine.AppendPlusOrMinusSwitch("/delaysign", this.Bag, "DelaySign");

            commandLine.AppendSwitchWithInteger("/filealign:", this.Bag, "FileAlignment");
            commandLine.AppendSwitchIfNotNull("/keycontainer:", this.KeyContainer);
            commandLine.AppendSwitchIfNotNull("/keyfile:", this.KeyFile);
            // If the strings "LogicalName" or "Access" ever change, make sure to search/replace everywhere in vsproject.
            commandLine.AppendSwitchIfNotNull("/linkresource:", this.LinkResources, new string[] { "LogicalName", "Access" });
            commandLine.AppendWhenTrue("/nologo", this.Bag, "NoLogo");
            commandLine.AppendWhenTrue("/nowin32manifest", this.Bag, "NoWin32Manifest");
            commandLine.AppendPlusOrMinusSwitch("/optimize", this.Bag, "Optimize");
            commandLine.AppendSwitchIfNotNull("/out:", this.OutputAssembly);
            commandLine.AppendSwitchIfNotNull("/ruleset:", this.CodeAnalysisRuleSet);
            commandLine.AppendSwitchIfNotNull("/subsystemversion:", this.SubsystemVersion);
            // If the strings "LogicalName" or "Access" ever change, make sure to search/replace everywhere in vsproject.
            commandLine.AppendSwitchIfNotNull("/resource:", this.Resources, new string[] { "LogicalName", "Access" });
            commandLine.AppendSwitchIfNotNull("/target:", this.TargetType);
            commandLine.AppendPlusOrMinusSwitch("/warnaserror", this.Bag, "TreatWarningsAsErrors");
            commandLine.AppendWhenTrue("/utf8output", this.Bag, "Utf8Output");
            commandLine.AppendSwitchIfNotNull("/win32icon:", this.Win32Icon);
            commandLine.AppendSwitchIfNotNull("/win32manifest:", this.Win32Manifest);

            // Append the analyzers.
            this.AddAnalyzersToCommandLine(commandLine);

            // Append additional files.
            this.AddAdditionalFilesToCommandLine(commandLine);

            // Append the sources.
            commandLine.AppendFileNamesIfNotNull(Sources, " ");
        }
예제 #7
0
        /// <summary>
        /// Logs a Resgen.exe command line that indicates what parameters were
        /// passed to this task. Since this task is replacing Resgen, and we used
        /// to log the Resgen.exe command line, we need to continue logging an
        /// equivalent command line.
        /// </summary>
        /// <param name="inputFiles"></param>
        /// <param name="outputFiles"></param>
        private void LogResgenCommandLine(List<ITaskItem> inputFiles, List<ITaskItem> outputFiles)
        {
            CommandLineBuilderExtension commandLineBuilder = new CommandLineBuilderExtension();

            // start the command line with the path to Resgen.exe
            commandLineBuilder.AppendFileNameIfNotNull(Path.Combine(_resgenPath, "resgen.exe"));

            GenerateResGenCommandLineWithoutResources(commandLineBuilder);

            if (StronglyTypedLanguage == null)
            {
                // append the resources to compile
                for (int i = 0; i < inputFiles.Count; ++i)
                {
                    if (!ExtractResWFiles)
                    {
                        commandLineBuilder.AppendFileNamesIfNotNull
                        (
                            new string[] { inputFiles[i].ItemSpec, outputFiles[i].ItemSpec },
                            ","
                        );
                    }
                    else
                    {
                        commandLineBuilder.AppendFileNameIfNotNull(inputFiles[i].ItemSpec);
                    }
                }
            }
            else
            {
                // append the resource to compile
                commandLineBuilder.AppendFileNamesIfNotNull(inputFiles.ToArray(), " ");
                commandLineBuilder.AppendFileNamesIfNotNull(outputFiles.ToArray(), " ");

                // append the strongly-typed resource details
                commandLineBuilder.AppendSwitchIfNotNull
                (
                    "/str:",
                    new string[] { StronglyTypedLanguage, StronglyTypedNamespace, StronglyTypedClassName, StronglyTypedFileName },
                    ","
                );
            }

            Log.LogCommandLine(MessageImportance.Low, commandLineBuilder.ToString());
        }
예제 #8
0
        /// <summary>
        /// Given the list of inputs and outputs, returns the number of resources (starting at the provided initial index)
        /// that can fit onto the commandline without exceeding MaximumCommandLength.
        /// </summary>
        private int CalculateResourceBatchSize(List<ITaskItem> inputsToProcess, List<ITaskItem> outputsToProcess, string resourcelessCommand, int initialResourceIndex)
        {
            CommandLineBuilderExtension currentCommand = new CommandLineBuilderExtension();

            if (!String.IsNullOrEmpty(resourcelessCommand))
            {
                currentCommand.AppendTextUnquoted(resourcelessCommand);
            }

            int i = initialResourceIndex;
            while (currentCommand.Length < s_maximumCommandLength && i < inputsToProcess.Count)
            {
                currentCommand.AppendFileNamesIfNotNull
                    (
                        new ITaskItem[] { inputsToProcess[i], outputsToProcess[i] },
                        ","
                    );
                i++;
            }

            int numberOfResourcesToAdd = 0;
            if (currentCommand.Length <= s_maximumCommandLength)
            {
                // We've successfully added all the rest. 
                numberOfResourcesToAdd = i - initialResourceIndex;
            }
            else
            {
                // The last one added tossed us over the edge.
                numberOfResourcesToAdd = i - initialResourceIndex - 1;
            }

            return numberOfResourcesToAdd;
        }
예제 #9
0
        protected void AddResponseFileCommandsImpl(CommandLineBuilderExtension commandLine)
        {
            if (OutputAssembly == null && Sources != null && Sources.Length > 0 && ResponseFiles == null)
            {
                try
                {
                    OutputAssembly = new TaskItem(Path.GetFileNameWithoutExtension(Sources[0].ItemSpec));
                }
                catch (ArgumentException exception)
                {
                    throw new ArgumentException(exception.Message, "Sources", exception);
                }

                var outputAssembly = OutputAssembly;
                switch (TargetType.ToLowerInvariant())
                {
                    case "library":
                        outputAssembly.ItemSpec = outputAssembly.ItemSpec + ".dll";
                        break;

                    case "module":
                        outputAssembly.ItemSpec = outputAssembly.ItemSpec + ".netmodule";
                        break;

                    default:
                        outputAssembly.ItemSpec = outputAssembly.ItemSpec + ".exe";
                        break;
                }
            }

            // Don't call base.AddResponseFileCommands()!
            //base.AddResponseFileCommands(commandLine);

            //System.Diagnostics.Debug.Assert(false);
            if (RunDebugger)
                commandLine.AppendSwitch("\n/debugger");
            if (Optimize)
                commandLine.AppendSwitch("\n/optimize");
            commandLine.AppendPlusOrMinusSwitch("\n/checked", base.Bag, "CheckIntegerOverflow");

            commandLine.AppendSwitch("\n/no-color");
            commandLine.AppendSwitchIfNotNull("\n/lib:", base.AdditionalLibPaths, ",");
            commandLine.AppendSwitchIfNotNull("\n/nowarn:", this.DisabledWarnings, ",");
            commandLine.AppendSwitchIfNotNull("\n/dowarn:", this.EnabledWarnings, ",");
            if (NoStdLib)
                commandLine.AppendSwitch("\n/no-stdlib");
            if (NoStdMacros)
                commandLine.AppendSwitch("\n/no-stdmacros");
            if (!GreedyReferences)
                commandLine.AppendSwitch("\n/greedy-references:-");
            if (WarningLevel != 4)
                commandLine.AppendSwitchIfNotNull("\n/warn:", this.WarningLevel.ToString());
            if (IndentationSyntax)
                commandLine.AppendSwitch("\n/indentation-syntax");
            commandLine.AppendSwitchIfNotNull("\n/doc:", this.DocumentationFile);
            if (!string.IsNullOrEmpty(base.DefineConstants))
            {
                var defines = base.DefineConstants
                    .Split(new char[] { ';', ' ', '\r', '\n', '\t' }, StringSplitOptions.RemoveEmptyEntries);
                commandLine.AppendSwitchUnquotedIfNotNull("\n/define:", String.Join(";", defines));
            }
            commandLine.AppendSwitchIfNotNull("\n/win32res:", base.Win32Resource);
            commandLine.AppendSwitchIfNotNull("\n/platform:", this.Platform);

            // Switchs from base.AddResponseFileCommands()
            commandLine.AppendSwitchIfNotNull("\n/addmodule:", this.AddModules, ",");
            commandLine.AppendPlusOrMinusSwitch("\n/delaysign", base.Bag, "DelaySign");
            commandLine.AppendSwitchIfNotNull("\n/keycontainer:", this.KeyContainer);
            commandLine.AppendSwitchIfNotNull("\n/keyfile:", this.KeyFile);
            commandLine.AppendSwitchIfNotNull("\n/linkresource:", this.LinkResources, new[] { "LogicalName", "Access" });
            if (NoLogo)
                commandLine.AppendSwitch("\n/nologo");
            commandLine.AppendSwitchIfNotNull("\n/resource:", this.Resources, new[] { "LogicalName", "Access" });
            commandLine.AppendSwitchIfNotNull("\n/target:", this.TargetType);
            commandLine.AppendPlusOrMinusSwitch("\n/warnaserror", base.Bag, "TreatWarningsAsErrors");
            commandLine.AppendSwitchIfNotNull("\n/win32icon:", this.Win32Icon);
            commandLine.AppendPlusOrMinusSwitch("\n/debug", base.Bag, "EmitDebugInformation");
            commandLine.AppendSwitchIfNotNull("\n/project-path:", this.ProjectPath);
            commandLine.AppendSwitchIfNotNull("\n/root-namespace:", this.RootNamespace);
            commandLine.AppendSwitchIfNotNull("\n/main:", this.MainEntryPoint);
            if (CompilerStackSize > 0)
                commandLine.AppendSwitchIfNotNull("\n/stack-size:", this.CompilerStackSize.ToString());

            // Not supported options:
            //commandLine.AppendSwitchWithInteger("\n/codepage:", base.Bag, "CodePage");
            //commandLine.AppendSwitchIfNotNull("/debug:", this.DebugType);
            //commandLine.AppendSwitchWithInteger("\n/filealign:", base.Bag, "FileAlignment");
            //commandLine.AppendWhenTrue("\n/utf8output", base.Bag, "Utf8Output");

            // Add sources
            if (this.Sources != null)
            {
                commandLine.Append("\n\n");
                commandLine.AppendFileNamesIfNotNull(this.Sources, "\n");
                commandLine.Append("\n");
            }

            if (null != base.ResponseFiles)
            {
                foreach (var it in base.ResponseFiles)
                    commandLine.AppendSwitchIfNotNull("\n/fromfile:", it.ItemSpec);
            }

            if (null != base.References)
            {
                foreach (var it in base.References)
                    commandLine.AppendSwitchIfNotNull("\n/ref:", it.ItemSpec);
            }

            if (null != this.MacroReferences)
            {
                foreach (var it in this.MacroReferences)
                    commandLine.AppendSwitchIfNotNull("\n/macros:", it.ItemSpec);
            }

            if (!string.IsNullOrEmpty(CustomArguments))
                commandLine.AppendSwitch(CustomArguments);

            commandLine.AppendSwitchIfNotNull("\n\n/out:", OutputAssembly);
        }
예제 #10
0
            /// <summary>
            /// Generate the command line to be passed to resgen.exe, sans the path to the tool. 
            /// </summary>
            private void GenerateResGenCommands(CommandLineBuilderExtension resGenArguments, bool useForResponseFile)
            {
                resGenArguments = resGenArguments ?? new CommandLineBuilderExtension();

                if (ResGen.IsNullOrEmpty(OutputFiles))
                {
                    GenerateOutputFileNames();
                }

                // Append boolean flags if requested
                string useSourcePathSwitch = "/useSourcePath" + (useForResponseFile ? "\n" : String.Empty);
                string publicClassSwitch = "/publicClass" + (useForResponseFile ? "\n" : String.Empty);
                resGenArguments.AppendWhenTrue(useSourcePathSwitch, Bag, "UseSourcePath");
                resGenArguments.AppendWhenTrue(publicClassSwitch, Bag, "PublicClass");

                // append the references, if any
                if (References != null)
                {
                    foreach (ITaskItem reference in References)
                    {
                        // ResGen.exe response files frown on quotes in filenames, even if there are 
                        // spaces in the names of the files.  
                        if (useForResponseFile && reference != null)
                        {
                            resGenArguments.AppendTextUnquoted("/r:");
                            resGenArguments.AppendTextUnquoted(reference.ItemSpec);
                            resGenArguments.AppendTextUnquoted("\n");
                        }
                        else
                        {
                            resGenArguments.AppendSwitchIfNotNull("/r:", reference);
                        }
                    }
                }

                if (String.IsNullOrEmpty(StronglyTypedLanguage))
                {
                    // append the compile switch
                    resGenArguments.AppendSwitch("/compile" + (useForResponseFile ? "\n" : String.Empty));

                    // append the resources to compile
                    if (InputFiles != null && InputFiles.Length > 0)
                    {
                        ITaskItem[] inputFiles = InputFiles;
                        ITaskItem[] outputFiles = OutputFiles;

                        for (int i = 0; i < inputFiles.Length; ++i)
                        {
                            if (useForResponseFile)
                            {
                                // ResGen.exe response files frown on quotes in filenames, even if there are 
                                // spaces in the names of the files.  
                                if (inputFiles[i] != null && outputFiles[i] != null)
                                {
                                    resGenArguments.AppendTextUnquoted(inputFiles[i].ItemSpec);
                                    resGenArguments.AppendTextUnquoted(",");
                                    resGenArguments.AppendTextUnquoted(outputFiles[i].ItemSpec);
                                    resGenArguments.AppendTextUnquoted("\n");
                                }
                            }
                            else
                            {
                                resGenArguments.AppendFileNamesIfNotNull
                                (
                                    new ITaskItem[] { inputFiles[i], outputFiles[i] },
                                    ","
                                );
                            }
                        }
                    }
                }
                else
                {
                    // append the resource to compile
                    resGenArguments.AppendFileNamesIfNotNull(InputFiles, " ");
                    resGenArguments.AppendFileNamesIfNotNull(OutputFiles, " ");

                    // append the strongly-typed resource details
                    resGenArguments.AppendSwitchIfNotNull
                    (
                        "/str:",
                        new string[] { StronglyTypedLanguage, StronglyTypedNamespace, StronglyTypedClassName, StronglyTypedFileName },
                        ","
                    );
                }
            }
예제 #11
0
파일: Jar.cs 프로젝트: Kav2018/JavaForVS
        protected override void AddResponseFileCommands(CommandLineBuilderExtension commandLine)
        {
            JarCommand command;
            string flags = "";

            switch (Command.ToLowerInvariant())
            {
            case "create":
                command = JarCommand.Create;
                flags += "c";
                break;

            case "update":
                command = JarCommand.Update;
                flags += "u";
                break;

            case "extract":
                command = JarCommand.Extract;
                flags += "x";
                break;

            case "index":
                command = JarCommand.Index;
                flags += "i";
                break;

            case "list":
                command = JarCommand.List;
                flags += "t";
                break;

            default:
                throw new InvalidOperationException();
            }

            if (command != JarCommand.Index && JarFile != null && JarFile.ItemSpec != null)
                flags += 'f';

            if (Verbose && command != JarCommand.Index)
                flags += 'v';

            if (command == JarCommand.Create || command == JarCommand.Update)
            {
                if (!Compress)
                    flags += '0';

                if (!CreateManifest)
                    flags += 'M';

                if (Manifest != null && Manifest.Length == 0 && Manifest[0].ItemSpec != null)
                    flags += 'm';
            }

            commandLine.AppendSwitch(flags);

            if (JarFile != null && JarFile.ItemSpec != null)
                commandLine.AppendFileNameIfNotNull(JarFile);

            if (command == JarCommand.Create || command == JarCommand.Update)
            {
                if (Manifest != null && Manifest.Length == 0 && Manifest[0].ItemSpec != null)
                    commandLine.AppendFileNameIfNotNull(Manifest[0]);
            }

            ILookup<string, ITaskItem> inputs = Inputs.ToLookup(i => i.GetMetadata("BaseOutputDirectory") ?? string.Empty);

            commandLine.AppendFileNamesIfNotNull(inputs[string.Empty].ToArray(), " ");
            foreach (var pair in inputs)
            {
                if (pair.Key == string.Empty)
                    continue;

                foreach (var file in pair)
                {
                    commandLine.AppendSwitchIfNotNull("-C ", pair.Key);
                    commandLine.AppendFileNameIfNotNull(file.ItemSpec.StartsWith(pair.Key) ? file.ItemSpec.Substring(pair.Key.Length) : file.ItemSpec);
                }

                //commandLine.AppendSwitchIfNotNull("-C ", pair.Key);
                //commandLine.AppendFileNamesIfNotNull(pair.Select(i => i.ItemSpec.StartsWith(pair.Key) ? i.ItemSpec.Substring(pair.Key.Length) : i.ItemSpec).ToArray(), " ");
            }

            if (!string.IsNullOrEmpty(EntryPoint))
                commandLine.AppendSwitchIfNotNull("-e ", EntryPoint);
        }
예제 #12
0
        /// <summary>
        /// Fills the provided CommandLineBuilderExtension with those switches and other information that can go into a response file.
        /// </summary>
        protected internal override void AddResponseFileCommands(CommandLineBuilderExtension commandLine)
        {
            // If outputAssembly is not specified, then an "/out: <name>" option won't be added to
            // overwrite the one resulting from the OutputAssembly member of the CompilerParameters class.
            // In that case, we should set the outputAssembly member based on the first source file.
            if (
                (OutputAssembly == null) &&
                (Sources != null) &&
                (Sources.Length > 0) &&
                (this.ResponseFiles == null)        // The response file may already have a /out: switch in it, so don't try to be smart here.
                )
            {
                try
                {
                    OutputAssembly = new TaskItem(Path.GetFileNameWithoutExtension(Sources[0].ItemSpec));
                }
                catch (ArgumentException e)
                {
                    throw new ArgumentException(e.Message, "Sources");
                }
                if (String.Compare(TargetType, "library", StringComparison.OrdinalIgnoreCase) == 0)
                {
                    OutputAssembly.ItemSpec += ".dll";
                }
                else if (String.Compare(TargetType, "module", StringComparison.OrdinalIgnoreCase) == 0)
                {
                    OutputAssembly.ItemSpec += ".netmodule";
                }
                else
                {
                    OutputAssembly.ItemSpec += ".exe";
                }
            }

            commandLine.AppendSwitchIfNotNull("/addmodule:", this.AddModules, ",");
            commandLine.AppendSwitchWithInteger("/codepage:", this.Bag, "CodePage");

            ConfigureDebugProperties();

            // The "DebugType" parameter should be processed after the "EmitDebugInformation" parameter
            // because it's more specific.  Order matters on the command-line, and the last one wins.
            // /debug+ is just a shorthand for /debug:full.  And /debug- is just a shorthand for /debug:none.

            commandLine.AppendPlusOrMinusSwitch("/debug", this.Bag, "EmitDebugInformation");
            commandLine.AppendSwitchIfNotNull("/debug:", this.DebugType);

            commandLine.AppendPlusOrMinusSwitch("/delaysign", this.Bag, "DelaySign");

            commandLine.AppendSwitchWithInteger("/filealign:", this.Bag, "FileAlignment");
            commandLine.AppendSwitchIfNotNull("/keycontainer:", this.KeyContainer);
            commandLine.AppendSwitchIfNotNull("/keyfile:", this.KeyFile);
            // If the strings "LogicalName" or "Access" ever change, make sure to search/replace everywhere in vsproject.
            commandLine.AppendSwitchIfNotNull("/linkresource:", this.LinkResources, new string[] { "LogicalName", "Access" });
            commandLine.AppendWhenTrue("/nologo", this.Bag, "NoLogo");
            commandLine.AppendWhenTrue("/nowin32manifest", this.Bag, "NoWin32Manifest");
            commandLine.AppendPlusOrMinusSwitch("/optimize", this.Bag, "Optimize");
            commandLine.AppendSwitchIfNotNull("/out:", this.OutputAssembly);
            commandLine.AppendSwitchIfNotNull("/ruleset:", this.CodeAnalysisRuleSet);
            commandLine.AppendSwitchIfNotNull("/subsystemversion:", this.SubsystemVersion);
            // If the strings "LogicalName" or "Access" ever change, make sure to search/replace everywhere in vsproject.
            commandLine.AppendSwitchIfNotNull("/resource:", this.Resources, new string[] { "LogicalName", "Access" });
            commandLine.AppendSwitchIfNotNull("/target:", this.TargetType);
            commandLine.AppendPlusOrMinusSwitch("/warnaserror", this.Bag, "TreatWarningsAsErrors");
            commandLine.AppendWhenTrue("/utf8output", this.Bag, "Utf8Output");
            commandLine.AppendSwitchIfNotNull("/win32icon:", this.Win32Icon);
            commandLine.AppendSwitchIfNotNull("/win32manifest:", this.Win32Manifest);

            // Append the analyzers.
            this.AddAnalyzersToCommandLine(commandLine);

            // Append additional files.
            this.AddAdditionalFilesToCommandLine(commandLine);

            // Append the sources.
            commandLine.AppendFileNamesIfNotNull(Sources, " ");
        }
예제 #13
0
파일: Javac.cs 프로젝트: Kav2018/JavaForVS
        protected override void AddResponseFileCommands(CommandLineBuilderExtension commandLine)
        {
            // the -verbose flag must be included or there's no way to figure out what the output files are
            commandLine.AppendSwitch("-verbose");

            if (!string.IsNullOrEmpty(Encoding))
                commandLine.AppendSwitchIfNotNull("-encoding ", Encoding);

            switch (DebugSymbols)
            {
            case "All":
                commandLine.AppendSwitch("-g");break;

            case "None":
                commandLine.AppendSwitch("-g:none");break;

            case "Specific":
                if (!string.IsNullOrEmpty(SpecificDebugSymbols))
                    commandLine.AppendSwitchIfNotNull("-g:", SpecificDebugSymbols);
                else
                    commandLine.AppendSwitch("-g:none");

                break;

            case "Default":
            default:
                break;
            }

            if (!string.IsNullOrEmpty(SourceRelease) && !string.Equals(SourceRelease, "Default", StringComparison.OrdinalIgnoreCase))
                commandLine.AppendSwitchIfNotNull("-source ", SourceRelease);
            if (!string.IsNullOrEmpty(TargetRelease) && !string.Equals(TargetRelease, "Default", StringComparison.OrdinalIgnoreCase))
                commandLine.AppendSwitchIfNotNull("-target ", TargetRelease);

            if (!string.IsNullOrEmpty(OutputPath))
                commandLine.AppendSwitchIfNotNull("-d ", OutputPath);

            if (!ShowWarnings)
            {
                commandLine.AppendSwitch("-nowarn");
            }
            else if (ShowAllWarnings)
            {
                commandLine.AppendSwitch("-Xlint");
                commandLine.AppendSwitch("-deprecation");
            }

            if (!string.IsNullOrEmpty(BuildArgs))
                commandLine.AppendTextUnquoted(" " + BuildArgs);

            // reference paths
            List<string> referencePaths = new List<string>();
            foreach (var reference in (References ?? Enumerable.Empty<ITaskItem>()))
            {
                string path = GetReferencePath(reference);
                if (!string.IsNullOrEmpty(path))
                    referencePaths.Add(path);
            }

            if (referencePaths.Count > 0)
            {
                commandLine.AppendSwitchIfNotNull("-cp ", referencePaths.ToArray(), ";");
            }

            commandLine.AppendSwitchIfNotNull("-classpath ", ClassPath, ";");

            commandLine.AppendFileNamesIfNotNull(Sources, " ");
        }
 private void LogResgenCommandLine(List<ITaskItem> inputFiles, List<ITaskItem> outputFiles)
 {
     CommandLineBuilderExtension resGenCommand = new CommandLineBuilderExtension();
     resGenCommand.AppendFileNameIfNotNull(Path.Combine(this.resgenPath, "resgen.exe"));
     this.GenerateResGenCommandLineWithoutResources(resGenCommand);
     if (this.StronglyTypedLanguage == null)
     {
         resGenCommand.AppendSwitch("/compile");
         for (int i = 0; i < inputFiles.Count; i++)
         {
             resGenCommand.AppendFileNamesIfNotNull(new string[] { inputFiles[i].ItemSpec, outputFiles[i].ItemSpec }, ",");
         }
     }
     else
     {
         resGenCommand.AppendFileNamesIfNotNull(inputFiles.ToArray(), " ");
         resGenCommand.AppendFileNamesIfNotNull(outputFiles.ToArray(), " ");
         resGenCommand.AppendSwitchIfNotNull("/str:", new string[] { this.StronglyTypedLanguage, this.StronglyTypedNamespace, this.StronglyTypedClassName, this.StronglyTypedFileName }, ",");
     }
     base.Log.LogCommandLine(MessageImportance.Low, resGenCommand.ToString());
 }
 private void GenerateResGenCommands(CommandLineBuilderExtension resGenArguments, bool useForResponseFile)
 {
     resGenArguments = resGenArguments ?? new CommandLineBuilderExtension();
     if (IsNullOrEmpty(this.OutputFiles))
     {
         this.GenerateOutputFileNames();
     }
     string switchName = "/useSourcePath" + (useForResponseFile ? "\n" : string.Empty);
     string str2 = "/publicClass" + (useForResponseFile ? "\n" : string.Empty);
     resGenArguments.AppendWhenTrue(switchName, base.Bag, "UseSourcePath");
     resGenArguments.AppendWhenTrue(str2, base.Bag, "PublicClass");
     if (this.References != null)
     {
         foreach (ITaskItem item in this.References)
         {
             if (useForResponseFile && (item != null))
             {
                 resGenArguments.AppendTextUnquoted("/r:");
                 resGenArguments.AppendTextUnquoted(item.ItemSpec);
                 resGenArguments.AppendTextUnquoted("\n");
             }
             else
             {
                 resGenArguments.AppendSwitchIfNotNull("/r:", item);
             }
         }
     }
     if (string.IsNullOrEmpty(this.StronglyTypedLanguage))
     {
         resGenArguments.AppendSwitch("/compile" + (useForResponseFile ? "\n" : string.Empty));
         if ((this.InputFiles != null) && (this.InputFiles.Length > 0))
         {
             ITaskItem[] inputFiles = this.InputFiles;
             ITaskItem[] outputFiles = this.OutputFiles;
             for (int i = 0; i < inputFiles.Length; i++)
             {
                 if (useForResponseFile)
                 {
                     if ((inputFiles[i] != null) && (outputFiles[i] != null))
                     {
                         resGenArguments.AppendTextUnquoted(inputFiles[i].ItemSpec);
                         resGenArguments.AppendTextUnquoted(",");
                         resGenArguments.AppendTextUnquoted(outputFiles[i].ItemSpec);
                         resGenArguments.AppendTextUnquoted("\n");
                     }
                 }
                 else
                 {
                     resGenArguments.AppendFileNamesIfNotNull(new ITaskItem[] { inputFiles[i], outputFiles[i] }, ",");
                 }
             }
         }
     }
     else
     {
         resGenArguments.AppendFileNamesIfNotNull(this.InputFiles, " ");
         resGenArguments.AppendFileNamesIfNotNull(this.OutputFiles, " ");
         resGenArguments.AppendSwitchIfNotNull("/str:", new string[] { this.StronglyTypedLanguage, this.StronglyTypedNamespace, this.StronglyTypedClassName, this.StronglyTypedFileName }, ",");
     }
 }
 private int CalculateResourceBatchSize(List<ITaskItem> inputsToProcess, List<ITaskItem> outputsToProcess, string resourcelessCommand, int initialResourceIndex)
 {
     CommandLineBuilderExtension extension = new CommandLineBuilderExtension();
     if (!string.IsNullOrEmpty(resourcelessCommand))
     {
         extension.AppendTextUnquoted(resourcelessCommand);
     }
     int num = initialResourceIndex;
     while ((extension.Length < MaximumCommandLength) && (num < inputsToProcess.Count))
     {
         extension.AppendFileNamesIfNotNull(new ITaskItem[] { inputsToProcess[num], outputsToProcess[num] }, ",");
         num++;
     }
     if (num == inputsToProcess.Count)
     {
         return (num - initialResourceIndex);
     }
     return ((num - initialResourceIndex) - 1);
 }