Ejemplo n.º 1
0
        public BuildManager(IServiceProvider hostServices, BuildOptions buildOptions)
        {
            _hostServices = hostServices;
            _buildOptions = buildOptions;

            _applicationEnvironment = (IApplicationEnvironment)hostServices.GetService(typeof(IApplicationEnvironment));

            ScriptExecutor = new ScriptExecutor(buildOptions.Reports.Information);
        }
Ejemplo n.º 2
0
        public BuildManager(IServiceProvider hostServices, BuildOptions buildOptions)
        {
            _hostServices = hostServices;
            _buildOptions = buildOptions;

            _applicationEnvironment = (IApplicationEnvironment)hostServices.GetService(typeof(IApplicationEnvironment));
            var loadContextAccessor = (IAssemblyLoadContextAccessor)hostServices.GetService(typeof(IAssemblyLoadContextAccessor));

            _compilationEngine = new CompilationEngine(new CompilationEngineContext(_applicationEnvironment, loadContextAccessor.Default, new CompilationCache()));

            ScriptExecutor = new ScriptExecutor(buildOptions.Reports.Information);
        }
Ejemplo n.º 3
0
        public BuildManager(BuildOptions buildOptions)
        {
            _buildOptions = buildOptions;

            _applicationEnvironment = PlatformServices.Default.Application;
            var runtimeEnvironment = PlatformServices.Default.Runtime;
            var loadContextAccessor = PlatformServices.Default.AssemblyLoadContextAccessor;

            _compilationEngine = new CompilationEngine(new CompilationEngineContext(
                _applicationEnvironment,
                runtimeEnvironment,
                loadContextAccessor.Default,
                new CompilationCache()));

            ScriptExecutor = new ScriptExecutor(buildOptions.Reports.Information);
        }
Ejemplo n.º 4
0
        public static void Register(CommandLineApplication cmdApp, ReportsFactory reportsFactory)
        {
            cmdApp.Command("build", c =>
            {
                c.Description = "Produce assemblies for the project in given directory";

                var optionFramework = c.Option("--framework <TARGET_FRAMEWORK>", "A list of target frameworks to build.", CommandOptionType.MultipleValue);
                var optionConfiguration = c.Option("--configuration <CONFIGURATION>", "A list of configurations to build.", CommandOptionType.MultipleValue);
                var optionOut = c.Option("--out <OUTPUT_DIR>", "Output directory", CommandOptionType.SingleValue);
                var optionQuiet = c.Option("--quiet", "Do not show output such as dependencies in use",
                    CommandOptionType.NoValue);
                var argProjectDir = c.Argument(
                    "[projects]",
                    "One or more projects build. If not specified, the project in the current directory will be used.",
                    multipleValues: true);
                c.HelpOption("-?|-h|--help");

                c.OnExecute(() =>
                {
                    c.ShowRootCommandFullNameAndVersion();

                    var buildOptions = new BuildOptions();
                    buildOptions.OutputDir = optionOut.Value();
                    buildOptions.ProjectPatterns = argProjectDir.Values;
                    if (buildOptions.ProjectPatterns.Count == 0)
                    {
                        buildOptions.ProjectPatterns.Add(Path.Combine(Directory.GetCurrentDirectory(), "project.json"));
                    }
                    buildOptions.Configurations = optionConfiguration.Values;
                    buildOptions.AddFrameworkMonikers(optionFramework.Values);
                    buildOptions.GeneratePackages = false;
                    buildOptions.Reports = reportsFactory.CreateReports(optionQuiet.HasValue());

                    var projectManager = new BuildManager(buildOptions);

                    if (!projectManager.Build())
                    {
                        return 1;
                    }

                    return 0;
                });
            });
        }
Ejemplo n.º 5
0
        public static void Register(CommandLineApplication cmdApp, ReportsFactory reportsFactory, IServiceProvider serviceProvider)
        {
            cmdApp.Command("pack", c =>
            {
                c.Description = "Build NuGet packages for the project in given directory";

                var optionFramework = c.Option("--framework <TARGET_FRAMEWORK>", "A list of target frameworks to build.", CommandOptionType.MultipleValue);
                var optionConfiguration = c.Option("--configuration <CONFIGURATION>", "A list of configurations to build.", CommandOptionType.MultipleValue);
                var optionOut = c.Option("--out <OUTPUT_DIR>", "Output directory", CommandOptionType.SingleValue);
                var optionQuiet = c.Option("--quiet", "Do not show output such as source/destination of nupkgs",
                    CommandOptionType.NoValue);
                var argProjectDir = c.Argument(
                    "[projects]",
                    "One or more projects to pack, default is current directory",
                    multipleValues: true);
                c.HelpOption("-?|-h|--help");

                c.OnExecute(() =>
                {
                    c.ShowRootCommandFullNameAndVersion();

                    var buildOptions = new BuildOptions();
                    buildOptions.OutputDir = optionOut.Value();
                    buildOptions.ProjectPatterns = argProjectDir.Values;
                    if (buildOptions.ProjectPatterns.Count == 0)
                    {
                        buildOptions.ProjectPatterns.Add(Path.Combine(Directory.GetCurrentDirectory(), "project.json"));
                    }
                    buildOptions.Configurations = optionConfiguration.Values;
                    buildOptions.TargetFrameworks = optionFramework.Values;
                    buildOptions.GeneratePackages = true;
                    buildOptions.Reports = reportsFactory.CreateReports(optionQuiet.HasValue());

                    var projectManager = new BuildManager(serviceProvider, buildOptions);

                    if (!projectManager.Build())
                    {
                        return -1;
                    }

                    return 0;
                });
            });
        }
Ejemplo n.º 6
0
 private static void CompileProjectJson(string v)
 {
     var buildOptions = new BuildOptions();
     buildOptions.Reports = CreateReports(true, false);
     buildOptions.GeneratePackages = false;
     var mgr = new BuildManager(_hostServices, buildOptions);
     buildOptions.ProjectPatterns.Add(Path.Combine(Directory.GetCurrentDirectory(), "project.json"));
     if (!mgr.Build())
     {
         throw new Exception("Build did not succeed.");
     }
 }