Exemple #1
0
        public override Boolean Execute()
        {
            Boolean retVal;
            var     inputs = this.InputAssemblies;

            if (inputs == null || inputs.Length <= 0)
            {
                this.Log.LogError("At least one input assembly is required.");
                retVal = false;
            }
            else
            {
                if (!String.IsNullOrEmpty(this.OutDir))
                {
                    this.OutPath = System.IO.Path.GetFullPath(System.IO.Path.Combine(this.OutDir, System.IO.Path.GetFileName(inputs[0])));
                }
                else if (String.IsNullOrEmpty(this.OutPath))
                {
                    this.OutPath = inputs[0];
                }

                if (this.DoLogging && this.LogFile == null)
                {
                    ((CILMergeOptions)this).CILLogCallback = this;
                }

                if (this.LibPaths == null || this.LibPaths.Length == 0)
                {
                    this.LibPaths = new[] { this.OutDir ?? System.IO.Path.GetDirectoryName(inputs[0]) };
                }
                else
                {
                    ExpandPaths(this.LibPaths);
                }

                ExpandPaths(inputs);

                this.Log.LogMessage(MessageImportance.High, "Performing merge for assemblies {0}; with library paths {1}; and outputting to {2} (union: {3}, closed: {4}).", String.Join(", ", this.InputAssemblies), String.Join(", ", this.LibPaths), this.OutPath, this.Union, this.Closed);

                try
                {
                    using (var merger = new CILMerger(this))
                    {
                        merger.PerformMerge();
                    }
                    retVal = true;
                }
                catch (Exception exc)
                {
                    this.Log.LogErrorFromException(exc, true, true, null);
                    retVal = false;
                }
            }
            return(retVal);
        }
Exemple #2
0
        internal static Int32 Main(String[] args)
        {
            ExitCode retVal;
            SimpleApplicationParameters paramInstance = null;

            try
            {
                var paramModel = new SimpleApplicationParametersModel(
                    "Files",
                    new StringOptionModel("help", "?"),
                    new StringOptionModel(OUT),
                    new OptionModel[]
                {
                    new StringOptionModel(KEY_FILE),
                    new EnumOptionModel <AssemblyHashAlgorithm>(SIGN_ALGORITHM, true),
                    new StringOptionModel(LOG),
                    new ListOptionModel(VER, new OptionModel(typeof(UInt16), null), ".", 4, 4),
                    new SwitchOptionModel(UNION),
                    new SwitchOptionModel(NODEBUG),
                    new SwitchOptionModel(COPY_ATTRS),
                    new StringOptionModel(ATTR),
                    new SwitchOptionModel(ALLOW_MULTIPLE),
                    new EnumOptionModel <ModuleKind>(TARGET, true),
                    new StringOptionModel(TARGET_PLATFORM),
                    new SwitchOptionModel(XML_DOCS),
                    new StringOptionModel(LIB),
                    new StringOptionModel(INTERNALIZE),
                    new SwitchOptionModel(DELAY_SIGN),
                    new SwitchOptionModel(USE_FULL_PUBLIC_KEY_FOR_REFERENCES),
                    new OptionModel(typeof(Int32), ALIGN),
                    new SwitchOptionModel(CLOSED),
                    new StringOptionModel(ALLOW_DUP),
                    new SwitchOptionModel(ALLOW_DUP_RES),
                    new SwitchOptionModel(ZERO_PE_KIND),
                    new SwitchOptionModel(PARALLEL),
                    new SwitchOptionModel(PAUSE),
                    new SwitchOptionModel(VERBOSE),
                    new SwitchOptionModel(WILDCARDS),
                    new StringOptionModel(SUBSYSTEMVERSION, new System.Text.RegularExpressions.Regex(@"\d{1,5}\.\d{1,5}")),
                    new SwitchOptionModel(HIGH_ENTROPY_VA)
                },
                    1,
                    LIB,
                    ALLOW_DUP
                    );
                paramInstance = new SimpleApplicationParameters(paramModel, args);
                if (paramInstance.Errors.Count > 0)
                {
                    Console.Error.WriteLine("Errors in command-line arguments:\n" + String.Join("\n", paramInstance.Errors));
                    retVal = ExitCode.ExceptionDuringStartup;
                }
                else if (paramInstance.HelpOptionPresent)
                {
                    Console.WriteLine("TODO Help.");
                    retVal = ExitCode.Success;
                }
                else
                {
                    var options = FromApplicationOptions(paramInstance);
#if DEBUG
                    options.DoLogging      = true;
                    options.CILLogCallback = new CILMergeLogCallbackImpl();
#endif
                    var merger = new CILMerger(options);
                    merger.PerformMerge();
                    retVal = ExitCode.Success;
                }
            }
            catch (CILMergeException cExc)
            {
                retVal = cExc._exitCode;
                Console.Error.WriteLine("Error: " + cExc.Message);
            }
            catch (Exception exc)
            {
                Console.Error.WriteLine("An exception occurred:\n" + exc);
                retVal = ExitCode.ExceptionDuringMerge;
            }
            if (paramInstance != null && paramInstance.GetSingleOptionOrNull(PAUSE).GetOrDefault(false))
            {
                Console.ReadKey();
            }
            return((Int32)retVal);
        }