Пример #1
0
        public void ExecuteGenerators()
        {
            _filesUtility.EmptyDirectory(_buildEnvironment.GeneratedAssetsFolder);
            _filesUtility.SafeCreateDirectory(_buildEnvironment.CacheFolder); // Cache is not deleted between builds.
            if (!string.IsNullOrEmpty(_buildEnvironment.GeneratedSourceFolder))
            {
                _filesUtility.SafeCreateDirectory(_buildEnvironment.GeneratedSourceFolder); // Obsolete source files will be cleaned later. Keeping the existing files to allowing source change detection in Visual Studio.
            }
            CheckDslModelErrors();

            var generators = _generatorsContainer.GetPlugins().ToArray();
            var job        = PrepareGeneratorsJob(generators);

            _logger.Trace(() => $"Starting parallel execution of {generators.Length} generators.");
            if (_buildOptions.MaxExecuteGeneratorsParallelism > 0)
            {
                _logger.Info(() => $"Using max {_buildOptions.MaxExecuteGeneratorsParallelism} degree of parallelism from configuration.");
            }

            var sw = Stopwatch.StartNew();

            job.RunAllTasks(_buildOptions.MaxExecuteGeneratorsParallelism);
            _performanceLogger.Write(sw, $"Executed {generators.Length} generators.");

            if (!string.IsNullOrEmpty(_buildEnvironment.GeneratedSourceFolder))
            {
                _sourceWriter.CleanUp();
            }
        }