示例#1
0
        static int Main(string[] args)
        {
            try
            {
                _logger.Information("Build process started");

                var startTime      = DateTime.UtcNow;
                var parsingResults = ArgumentsParser.Parse(args);
                var clientAssembly = AssemblyLoadContext.Default.LoadFromAssemblyPath(parsingResults.AssemblyPath);
                InitialSetup();

                var boundedContextConfig = _boundedContextLoader.Load(parsingResults.BoundedContextConfigRelativePath);

                var assemblyContext = AssemblyContext.From(clientAssembly);

                _artifactsDiscoverer      = new ArtifactsDiscoverer(assemblyContext, _artifactTypes, _logger);
                _eventProcessorDiscoverer = new EventProcessorDiscoverer(assemblyContext, _logger);

                var artifacts = _artifactsDiscoverer.Artifacts;

                var topology = _topologyConfigurationHandler.Build(artifacts, parsingResults);

                var artifactsConfiguration = _artifactsConfigurationHandler.Build(artifacts, topology, parsingResults);

                ValidateEventProcessors(_eventProcessorDiscoverer.GetAllEventProcessors());

                var events = artifacts.Where(_ => _artifactTypes.ArtifactTypes.Where(artifactType => artifactType.TypeName == "event").First().Type.IsAssignableFrom(_));
                ValidateEvents(events);

                _topologyConfigurationHandler.Save(topology);
                _artifactsConfigurationHandler.Save(artifactsConfiguration);

                if (parsingResults.GenerateProxies)
                {
                    _proxiesHandler = _bootLoaderResult.Container.Get <ProxiesHandler>();
                    _proxiesHandler.CreateProxies(artifacts, parsingResults, artifactsConfiguration);
                }

                var endTime   = DateTime.UtcNow;
                var deltaTime = endTime.Subtract(startTime);
                _logger.Information($"Finished build process. (Took {deltaTime.TotalSeconds} seconds)");
            }
            catch (Exception ex)
            {
                _logger.Error(ex, "Error consolidating artifacts;");
                return(1);
            }

            return(0);
        }
示例#2
0
        static int Main(string[] args)
        {
            try
            {
                var startTime = DateTime.UtcNow;

                var assemblyFile       = args[0];
                var pluginAssemblies   = args[1].Split(";");
                var configurationFile  = args[2];
                var outputAssemblyFile = args[3];

                if (string.IsNullOrEmpty(args[1]) ||
                    pluginAssemblies.Length == 0 ||
                    string.IsNullOrEmpty(configurationFile))
                {
                    return(0);
                }

                var assembly        = AssemblyLoadContext.Default.LoadFromAssemblyPath(assemblyFile);
                var assemblyContext = AssemblyContext.From(assemblyFile);
                BuildTarget = new BuildTarget(assemblyFile, outputAssemblyFile, assembly, assemblyContext);

                Console.WriteLine("Performing Dolittle post-build steps");

                Console.WriteLine($"  Performing for: {assemblyFile}");
                Console.WriteLine($"  Will output to: {outputAssemblyFile}");
                Console.WriteLine("  Using plugins from: ");

                foreach (var pluginAssembly in pluginAssemblies)
                {
                    Console.WriteLine($"    {pluginAssembly}");
                }

                var bootLoaderResult = Bootloader.Configure(_ => _
                                                            .WithAssemblyProvider(new AssemblyProvider(new Dolittle.Logging.NullLogger(), pluginAssemblies))
                                                            .NoLogging()
                                                            .SkipBootprocedures()
                                                            ).Start();

                var buildMessages = bootLoaderResult.Container.Get <IBuildMessages>();

                var configuration = bootLoaderResult.Container.Get <IPerformerConfigurationManager>();
                configuration.Initialize(configurationFile);
                var buildTaskPerformers = bootLoaderResult.Container.Get <IBuildTaskPerformers>();
                buildTaskPerformers.Perform();

                var assemblyModifiers = bootLoaderResult.Container.Get <ITargetAssemblyModifiers>();
                assemblyModifiers.ModifyAndSave();

                var postTasksPerformers = bootLoaderResult.Container.Get <IPostBuildTaskPerformers>();
                postTasksPerformers.Perform();

                var endTime   = DateTime.UtcNow;
                var deltaTime = endTime.Subtract(startTime);
                buildMessages.Information($"Time Elapsed {deltaTime.ToString("G")} (Dolittle)");
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine("Error executing Dolittle post build tool".Red());
                Console.Error.WriteLine($"Exception: {ex.Message}".Red());
                Console.Error.WriteLine($"StackTrace: {ex.StackTrace}".Red());
                return(1);
            }

            return(0);
        }