Beispiel #1
0
 /// <summary>
 /// Instantiate a new WixCop class.
 /// </summary>
 private WixCop()
 {
     this.errorsAsWarnings = null;
     this.exemptFiles = new Hashtable();
     this.fixErrors = false;
     this.inspector = null;
     this.searchPatterns = new ArrayList();
     this.settingsFile1 = null;
     this.settingsFile2 = null;
     this.showHelp = false;
     this.showLogo = true;
     this.subDirectories = false;
     this.indentationAmount = 2;
 }
Beispiel #2
0
        /// <summary>
        /// Run the application with the given arguments.
        /// </summary>
        /// <param name="args">The commandline arguments.</param>
        /// <returns>The number of errors that were found.</returns>
        private int Run(string[] args)
        {
            try
            {
                this.ParseCommandLine(args);

                if (this.showLogo)
                {
                    Assembly wixcopAssembly = this.GetType().Assembly;
                    FileVersionInfo fv = FileVersionInfo.GetVersionInfo(wixcopAssembly.Location);

                    Console.WriteLine("Windows Installer Xml Cop version {0}", fv.FileVersion);
                    Console.WriteLine("Copyright (C) .NET Foundation and contributors. All rights reserved.");
                    Console.WriteLine();
                }

                if (this.showHelp)
                {
                    Console.WriteLine(" usage:  wixcop.exe sourceFile [sourceFile ...]");
                    Console.WriteLine();
                    Console.WriteLine("   -f       fix errors automatically for writable files");
                    Console.WriteLine("   -nologo  suppress displaying the logo information");
                    Console.WriteLine("   -s       search for matching files in current dir and subdirs");
                    Console.WriteLine("   -set1<file> primary settings file");
                    Console.WriteLine("   -set2<file> secondary settings file (overrides primary)");
                    Console.WriteLine("   -indent:<n> indentation multiple (overrides default of 4)");
                    Console.WriteLine("   -?       this help information");
                    Console.WriteLine();
                    Console.WriteLine("   sourceFile may use wildcards like *.wxs");

                    return 0;
                }

                // parse the settings if any were specified
                if (null != this.settingsFile1 || null != this.settingsFile2)
                {
                    this.ParseSettingsFiles(this.settingsFile1, this.settingsFile2);
                }
                else
                {
                    if (File.Exists(settingsFileDefault))
                    {
                        this.ParseSettingsFiles(this.settingsFileDefault, null);
                    }
                }

                this.inspector = new Inspector(this.errorsAsWarnings, this.ignoreErrorsHash, this.indentationAmount);

                int errors = this.InspectSubDirectories(Path.GetFullPath("."));

                foreach (string searchPattern in this.searchPatterns)
                {
                    if (!this.searchPatternResults.ContainsKey(searchPattern))
                    {
                        Console.WriteLine("Could not find file \"{0}\"", searchPattern);
                        errors++;
                    }
                }

                return errors != 0 ? 2 : 0;
            }
            catch (Exception e)
            {
                Console.WriteLine("wixcop.exe : fatal error WXCP0001 : {0}\r\n\n\nStack Trace:\r\n{1}", e.Message, e.StackTrace);

                return 1;
            }
        }
Beispiel #3
0
        /// <summary>
        /// Run the application with the given arguments.
        /// </summary>
        /// <param name="args">The commandline arguments.</param>
        /// <returns>The number of errors that were found.</returns>
        private int Run(string[] args)
        {
            try
            {
                this.ParseCommandLine(args);

                if (this.showLogo)
                {
                    Assembly        wixcopAssembly = this.GetType().Assembly;
                    FileVersionInfo fv             = FileVersionInfo.GetVersionInfo(wixcopAssembly.Location);

                    Console.WriteLine("Windows Installer Xml Cop version {0}", fv.FileVersion);
                    Console.WriteLine("Copyright (C) Outercurve Foundation. All rights reserved.");
                    Console.WriteLine();
                }

                if (this.showHelp)
                {
                    Console.WriteLine(" usage:  wixcop.exe sourceFile [sourceFile ...]");
                    Console.WriteLine();
                    Console.WriteLine("   -f       fix errors automatically for writable files");
                    Console.WriteLine("   -nologo  suppress displaying the logo information");
                    Console.WriteLine("   -s       search for matching files in current dir and subdirs");
                    Console.WriteLine("   -set1<file> primary settings file");
                    Console.WriteLine("   -set2<file> secondary settings file (overrides primary)");
                    Console.WriteLine("   -indent:<n> indentation multiple (overrides default of 4)");
                    Console.WriteLine("   -?       this help information");
                    Console.WriteLine();
                    Console.WriteLine("   sourceFile may use wildcards like *.wxs");

                    return(0);
                }

                // parse the settings if any were specified
                if (null != this.settingsFile1 || null != this.settingsFile2)
                {
                    this.ParseSettingsFiles(this.settingsFile1, this.settingsFile2);
                }
                else
                {
                    if (File.Exists(settingsFileDefault))
                    {
                        this.ParseSettingsFiles(this.settingsFileDefault, null);
                    }
                }

                this.inspector = new Inspector(this.errorsAsWarnings, this.ignoreErrorsHash, this.indentationAmount);

                int errors = this.InspectSubDirectories(Path.GetFullPath("."));

                foreach (string searchPattern in this.searchPatterns)
                {
                    if (!this.searchPatternResults.ContainsKey(searchPattern))
                    {
                        Console.WriteLine("Could not find file \"{0}\"", searchPattern);
                        errors++;
                    }
                }

                return(errors != 0 ? 2 : 0);
            }
            catch (Exception e)
            {
                Console.WriteLine("wixcop.exe : fatal error WXCP0001 : {0}\r\n\n\nStack Trace:\r\n{1}", e.Message, e.StackTrace);

                return(1);
            }
        }
Beispiel #4
0
        /// <summary>
        /// Run the application with the given arguments.
        /// </summary>
        /// <param name="args">The commandline arguments.</param>
        /// <returns>The number of errors that were found.</returns>
        private int Run(string[] args)
        {
            try
            {
                this.ParseCommandLine(args);

                if (this.showLogo)
                {
                    Assembly wixcopAssembly = Assembly.GetExecutingAssembly();

                    Console.WriteLine("Microsoft (R) Windows Installer Xml Cop version {0}", wixcopAssembly.GetName().Version.ToString());
                    Console.WriteLine("Copyright (C) Microsoft Corporation 2004. All rights reserved.");
                    Console.WriteLine();
                }

                if (this.showHelp)
                {
                    Console.WriteLine(" usage:  wixcop.exe sourceFile [sourceFile ...]");
                    Console.WriteLine();
                    Console.WriteLine("   -f       fix errors automatically for writable files");
                    Console.WriteLine("   -nologo  suppress displaying the logo information");
                    Console.WriteLine("   -s       search for matching files in current dir and subdirs");
                    Console.WriteLine("   -set1<file> primary settings file");
                    Console.WriteLine("   -set2<file> secondary settings file (overrides primary)");
                    Console.WriteLine("   -indent:<n> indentation multiple (overrides default of 2)");
                    Console.WriteLine("   -?       this help information");
                    Console.WriteLine();
                    Console.WriteLine("   sourceFile may use wildcards like *.wxs");

                    return 0;
                }

                // parse the settings if any were specified
                if (null != this.settingsFile1 || null != this.settingsFile2)
                {
                    this.ParseSettingsFiles(this.settingsFile1, this.settingsFile2);
                }

                this.inspector = new Inspector(this.errorsAsWarnings, this.indentationAmount);

                int errors = this.InspectSubDirectories(Path.GetFullPath("."));

                return errors != 0 ? 2 : 0;
            }
            catch (Exception e)
            {
                Console.WriteLine("wixcop.exe : fatal error WXCP0001 : {0}\r\n\n\nStack Trace:\r\n{1}", e.Message, e.StackTrace);

                return 1;
            }
        }