示例#1
0
文件: Program.cs 项目: rfcclub/dot42
        /// <summary>
        /// Entry point
        /// </summary>
        /// <param name="args">Command line arguments</param>
        internal static int Main(string[] args)
        {
            try
            {
#if DEBUG
                if (args.Length == 0)
                {
                    args = new[] {
                        @"-frameworksfolder=S:\SVNWork\dot42\Build\Application\Frameworks", 
                        @"-out=S:\SVNWork\dot42\build\Docs\ApiDocsFiles"
                    };
                    args = new[] {
                        @"-fa=S:\SVNWork\dot42\Build\Application\Frameworks\v4.0.3\mscorlib.dll"
                    };

                }
#endif

                var options = new CommandLineOptions(args);
                if (options.ShowHelp)
                {
                    options.Usage();
                    return 2;
                }

                // Set target
                Locations.SetTarget(options.Target);

                if (!string.IsNullOrEmpty(options.TemplatePath))
                {
                    // Update template
                    if (!File.Exists(options.TemplatePath))
                    {
                        throw new ArgumentException(string.Format("Template ({0}) not found.", options.TemplatePath));
                    }

                    Templates.TemplateUpdater.UpdateTemplate(options.TemplatePath, options.Target);
                }

                if (!string.IsNullOrEmpty(options.SystemIdSourcePath))
                {
                    // Generate system id's
                    SystemIds.SystemIdSources.Generate(options.SystemIdSourcePath, options.FrameworksFolder);
                }
                else if (!string.IsNullOrEmpty(options.DebuggerExceptionsSourceFile))
                {
                    Exceptions.ExceptionsSnippetBuilder.Generate(options.DebuggerExceptionsSourceFile, options.FrameworksFolder);
                }
                else if (!string.IsNullOrEmpty(options.FrameworksFolder))
                {
                    // Document frameworks
                    if (!Directory.Exists(options.FrameworksFolder))
                    {
                        throw new ArgumentException(string.Format("Frameworks folder ({0}) not found.", options.FrameworksFolder));                        
                    }
                    var builder = new Documentation.DocumentationBuilder(options.FrameworksFolder, options.OutputFolder);
                    builder.Generate();
                }

                if (!string.IsNullOrEmpty(options.SamplesFolder))
                {
                    // Generate samples uninstall script
                    Samples.UninstallDeleteScript.Generate(options.ScriptPath, options.SamplesFolder);
                }

                if (!string.IsNullOrEmpty(options.InputAssembly) && options.EnumTypeNames.Any())
                {
                    EnumNames.EnumNamesBuilder.Generate(options.InputAssembly, options.OutputFolder, options.EnumTypeNames.ToArray());
                }

                if (!string.IsNullOrEmpty(options.FixAssemblyPath))
                {
                    Corlib.FixCorlib.Fix(options.FixAssemblyPath);
                }

                if (!string.IsNullOrEmpty(options.FindApiEnhancements))
                {
                    ApiEnhancements.FindApiEnhancements.Find(options.FindApiEnhancements);
                }

                if (!string.IsNullOrEmpty(options.UninstallAPK))
                {
                    UninstallAPK(options.UninstallAPK);
                }

                if (!string.IsNullOrEmpty(options.CheckForwardersAssembly))
                {
                    CheckForwarders.CheckForwardAssemblies.Check(options.CheckForwardersAssembly);
                }

                return 0;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
#if DEBUG
                Console.WriteLine(ex.StackTrace);
#endif
                return 1;
            }
        }
示例#2
0
        /// <summary>
        /// Entry point
        /// </summary>
        /// <param name="args">Command line arguments</param>
        internal static int Main(string[] args)
        {
            try
            {
#if DEBUG
                if (args.Length == 0)
                {
                    args = new[] {
                        @"-frameworksfolder=S:\SVNWork\dot42\Build\Application\Frameworks",
                        @"-out=S:\SVNWork\dot42\build\Docs\ApiDocsFiles"
                    };
                    args = new[] {
                        @"-fa=S:\SVNWork\dot42\Build\Application\Frameworks\v4.0.3\mscorlib.dll"
                    };
                }
#endif

                var options = new CommandLineOptions(args);
                if (options.ShowHelp)
                {
                    options.Usage();
                    return(2);
                }

                // Set target
                Locations.SetTarget(options.Target);

                if (!string.IsNullOrEmpty(options.TemplatePath))
                {
                    // Update template
                    if (!File.Exists(options.TemplatePath))
                    {
                        throw new ArgumentException(string.Format("Template ({0}) not found.", options.TemplatePath));
                    }

                    Templates.TemplateUpdater.UpdateTemplate(options.TemplatePath, options.Target);
                }

                if (!string.IsNullOrEmpty(options.SystemIdSourcePath))
                {
                    // Generate system id's
                    SystemIds.SystemIdSources.Generate(options.SystemIdSourcePath, options.FrameworksFolder);
                }
                else if (!string.IsNullOrEmpty(options.DebuggerExceptionsSourceFile))
                {
                    Exceptions.ExceptionsSnippetBuilder.Generate(options.DebuggerExceptionsSourceFile, options.FrameworksFolder);
                }
                else if (!string.IsNullOrEmpty(options.FrameworksFolder))
                {
                    // Document frameworks
                    if (!Directory.Exists(options.FrameworksFolder))
                    {
                        throw new ArgumentException(string.Format("Frameworks folder ({0}) not found.", options.FrameworksFolder));
                    }
                    var builder = new Documentation.DocumentationBuilder(options.FrameworksFolder, options.OutputFolder);
                    builder.Generate();
                }

                if (!string.IsNullOrEmpty(options.SamplesFolder))
                {
                    // Generate samples uninstall script
                    Samples.UninstallDeleteScript.Generate(options.ScriptPath, options.SamplesFolder);
                }

                if (!string.IsNullOrEmpty(options.InputAssembly) && options.EnumTypeNames.Any())
                {
                    EnumNames.EnumNamesBuilder.Generate(options.InputAssembly, options.OutputFolder, options.EnumTypeNames.ToArray());
                }

                if (!string.IsNullOrEmpty(options.FixAssemblyPath))
                {
                    Corlib.FixCorlib.Fix(options.FixAssemblyPath);
                }

                if (!string.IsNullOrEmpty(options.FindApiEnhancements))
                {
                    ApiEnhancements.FindApiEnhancements.Find(options.FindApiEnhancements);
                }

                if (!string.IsNullOrEmpty(options.UninstallAPK))
                {
                    UninstallAPK(options.UninstallAPK);
                }

                if (!string.IsNullOrEmpty(options.CheckForwardersAssembly))
                {
                    CheckForwarders.CheckForwardAssemblies.Check(options.CheckForwardersAssembly);
                }

                return(0);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
#if DEBUG
                Console.WriteLine(ex.StackTrace);
#endif
                return(1);
            }
        }