Exemplo n.º 1
0
        private void ExecCore()
        {
            string originalGlobalNamespaceId = VisitorHelper.GlobalNamespaceId;

            EnvironmentContext.SetBaseDirectory(BaseDirectory);

            // If Root Output folder is specified from command line, use it instead of the base directory
            EnvironmentContext.SetOutputDirectory(OutputFolder ?? BaseDirectory);
            using (new MSBuildEnvironmentScope())
            {
                foreach (var item in Config)
                {
                    VisitorHelper.GlobalNamespaceId = item.GlobalNamespaceId;

                    var inputModel = ConvertToInputModel(item);

                    EnvironmentContext.SetGitFeaturesDisabled(item.DisableGitFeatures);

                    // TODO: Use plugin to generate metadata for files with different extension?
                    using (var worker = new ExtractMetadataWorker(inputModel))
                    {
                        // Use task.run to get rid of current context (causing deadlock in xunit)
                        var task = Task.Run(worker.ExtractMetadataAsync);
                        task.Wait();
                    }
                }

                VisitorHelper.GlobalNamespaceId = originalGlobalNamespaceId;
            }
        }
Exemplo n.º 2
0
        public void BuildDocument()
        {
            var sponsor = new ClientSponsor();

            EnvironmentContext.SetBaseDirectory(_baseDirectory);
            EnvironmentContext.SetGitFeaturesDisabled(_disableGitFeatures);
            EnvironmentContext.SetVersion(_version);
            if (_listener != null)
            {
                Logger.LogLevelThreshold = _logLevel;
                Logger.RegisterListener(_listener);
                sponsor.Register(_listener);
            }
            try
            {
                try
                {
                    BuildDocument(_config, _manager, _baseDirectory, _outputDirectory, _pluginDirectory, _templateDirectory);
                }
                catch (AggregateException agg) when(agg.InnerException is DocfxException)
                {
                    throw new DocfxException(agg.InnerException.Message);
                }
                catch (AggregateException agg) when(agg.InnerException is DocumentException)
                {
                    throw new DocumentException(agg.InnerException.Message);
                }
                catch (DocfxException e)
                {
                    throw new DocfxException(e.Message);
                }
                catch (DocumentException)
                {
                    throw;
                }
                catch (Exception e)
                {
                    throw new DocfxException(e.ToString());
                }
            }
            finally
            {
                sponsor.Close();
            }
        }
Exemplo n.º 3
0
        public void Exec(SubCommandRunningContext context)
        {
            EnvironmentContext.SetGitFeaturesDisabled(Config.DisableGitFeatures);
            EnvironmentContext.SetBaseDirectory(Path.GetFullPath(string.IsNullOrEmpty(Config.BaseDirectory) ? Directory.GetCurrentDirectory() : Config.BaseDirectory));
            // TODO: remove BaseDirectory from Config, it may cause potential issue when abused
            var baseDirectory = EnvironmentContext.BaseDirectory;

            Config.IntermediateFolder = Config.IntermediateFolder ?? Path.Combine(baseDirectory, "obj", ".cache", "build");

            var outputFolder = Path.GetFullPath(Path.Combine(string.IsNullOrEmpty(Config.OutputFolder) ? baseDirectory : Config.OutputFolder, Config.Destination ?? string.Empty));

            BuildDocument(baseDirectory, outputFolder);

            _templateManager.ProcessTheme(outputFolder, true);
            // TODO: SEARCH DATA

            if (Config?.Serve ?? false)
            {
                ServeCommand.Serve(outputFolder, Config.Host, Config.Port);
            }
            EnvironmentContext.Clean();
        }