コード例 #1
0
 public BridgeScriptHost(ICakeEngine engine, ICakeContext context, IExecutionStrategy strategy, ICakeReportPrinter reporter, ICakeArguments arguments)
     : base(engine, context)
 {
     Strategy  = strategy;
     Reporter  = reporter;
     Arguments = arguments;
 }
コード例 #2
0
 public FrostingRunner(BuildScriptHost <IFrostingContext> host,
                       ICakeEngine engine, IFrostingContext context, ICakeLog log,
                       IEnumerable <IFrostingTask> tasks,
                       IFrostingSetup setup         = null, IFrostingTeardown teardown = null,
                       IFrostingTaskSetup taskSetup = null, IFrostingTaskTeardown taskTeardown = null)
     : base(host, engine, context, log, tasks, setup, teardown, taskSetup, taskTeardown)
 {
 }
コード例 #3
0
ファイル: ScriptHost.cs プロジェクト: sjmcallister/cake
 /// <summary>
 /// Initializes a new instance of the <see cref="ScriptHost"/> class.
 /// </summary>
 /// <param name="engine">The engine.</param>
 protected ScriptHost(ICakeEngine engine)
 {
     if (engine == null)
     {
         throw new ArgumentNullException("engine");
     }
     _engine = engine;
 }
コード例 #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BuildScriptHost"/> class.
 /// </summary>
 /// <param name="engine">The engine.</param>
 /// <param name="executionStrategy">The execution strategy.</param>
 /// <param name="context">The context.</param>
 /// <param name="reportPrinter">The report printer.</param>
 /// <param name="log">The log.</param>
 public BuildScriptHost(
     ICakeEngine engine,
     IExecutionStrategy executionStrategy,
     ICakeContext context,
     ICakeReportPrinter reportPrinter,
     ICakeLog log) : base(engine, executionStrategy, context, reportPrinter, log)
 {
 }
コード例 #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TaskTreeScriptHost"/> class.
 /// </summary>
 /// <param name="engine">The engine.</param>
 /// <param name="context">The context.</param>
 /// <param name="console">The console.</param>
 public TaskTreeScriptHost(ICakeEngine engine, ICakeContext context, IConsole console)
     : base(engine, context)
 {
     if (console == null)
     {
         throw new ArgumentNullException(nameof(console));
     }
     _console = console;
 }
コード例 #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BuildScriptHost"/> class.
 /// </summary>
 /// <param name="engine">The engine.</param>
 /// <param name="context">The context.</param>
 /// <param name="reportPrinter">The report printer.</param>
 /// <param name="log">The log.</param>
 public BuildScriptHost(
     ICakeEngine engine,
     ICakeContext context,
     ICakeReportPrinter reportPrinter,
     ICakeLog log) : base(engine, context)
 {
     _reportPrinter = reportPrinter;
     _log           = log;
 }
コード例 #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DryRunScriptHost"/> class.
 /// </summary>
 /// <param name="engine">The engine.</param>
 /// <param name="context">The context.</param>
 /// <param name="log">The log.</param>
 public DryRunScriptHost(ICakeEngine engine, ICakeContext context, ICakeLog log)
     : base(engine, context)
 {
     if (log == null)
     {
         throw new ArgumentNullException(nameof(log));
     }
     _log = log;
 }
コード例 #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DescriptionScriptHost"/> class.
 /// </summary>
 /// <param name="engine">The engine.</param>
 /// <param name="context">The context.</param>
 /// <param name="console">The console.</param>
 public DescriptionScriptHost(ICakeEngine engine, ICakeContext context, IConsole console)
     : base(engine, context)
 {
     if (console == null)
     {
         throw new ArgumentNullException("console");
     }
     _console      = console;
     _descriptions = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase);
 }
コード例 #9
0
ファイル: RunCommand.cs プロジェクト: adamhathcock/frosting
        public override bool Execute(ICakeEngine engine, CakeHostOptions options)
        {
            var report = engine.RunTarget(_context, _strategy, options.Target);

            if (report != null && !report.IsEmpty)
            {
                _printer.Write(report);
            }

            return(true);
        }
コード例 #10
0
ファイル: RunCommand.cs プロジェクト: lexusean/frosting
        public override bool Execute(ICakeEngine engine, CakeHostOptions options)
        {
            _executionSettings.SetTarget(options.Target);
            var report = engine.RunTargetAsync(_context, _strategy, _executionSettings).GetAwaiter().GetResult();

            if (report != null && !report.IsEmpty)
            {
                _printer.Write(report);
            }

            return(true);
        }
コード例 #11
0
        public override async Task <bool> ExecuteAsync(ICakeEngine engine, CakeHostOptions options)
        {
            _executionSettings.SetTarget(options.Target);
            var report = await engine.RunTargetAsync(_context, _strategy, _executionSettings).ConfigureAwait(false);

            if (report != null && !report.IsEmpty)
            {
                _printer.Write(report);
            }

            return(true);
        }
コード例 #12
0
        public void Initialize(ICakeEngine engine, IFrostingContext context, IEnumerable <IFrostingTask> tasks,
                               IFrostingLifetime lifetime, IFrostingTaskLifetime taskLifetime)
        {
            if (tasks != null)
            {
                foreach (var task in tasks)
                {
                    var taskName = TaskNameHelper.GetTaskName(task);
                    _log.Debug("Registering task {0} with engine...", taskName);

                    // Get the task's context type.
                    if (!task.HasCompatibleContext(context))
                    {
                        const string format = "Task cannot be used since the context isn't convertable to {0}.";
                        _log.Warning(format, task.GetContextType().FullName);
                    }
                    else
                    {
                        // Register task with the Cake engine.
                        var cakeTask = engine.RegisterTask(taskName);
                        cakeTask.Does(task.Run);
                        cakeTask.WithCriteria(task.ShouldRun);

                        // Add dependencies
                        var attributes = task.GetType().GetTypeInfo().GetCustomAttributes <DependencyAttribute>();
                        foreach (var dependency in attributes)
                        {
                            var dependencyName = TaskNameHelper.GetTaskName(dependency);
                            if (!typeof(IFrostingTask).IsAssignableFrom(dependency.Task))
                            {
                                throw new FrostingException($"The dependency {dependencyName} does not implement IFrostingTask.");
                            }
                            cakeTask.IsDependentOn(dependencyName);
                        }
                    }
                }
            }

            if (lifetime != null)
            {
                _log.Debug("Registering lifetime {0} with engine...", lifetime.GetType().FullName);
                engine.RegisterSetupAction(info => lifetime.Setup(context));
                engine.RegisterTeardownAction(info => lifetime.Teardown(context, info));
            }

            if (taskLifetime != null)
            {
                _log.Debug("Registering task lifetime {0} with engine...", taskLifetime.GetType().Name);
                engine.RegisterTaskSetupAction(info => taskLifetime.Setup(context, info));
                engine.RegisterTaskTeardownAction(info => taskLifetime.Teardown(context, info));
            }
        }
コード例 #13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ScriptHost"/> class.
 /// </summary>
 /// <param name="engine">The engine.</param>
 /// <param name="context">The context.</param>
 protected ScriptHost(ICakeEngine engine, ICakeContext context)
 {
     if (engine == null)
     {
         throw new ArgumentNullException("engine");
     }
     if (context == null)
     {
         throw new ArgumentNullException("context");
     }
     _engine  = engine;
     _context = context;
 }
コード例 #14
0
ファイル: ScriptHost.cs プロジェクト: zokiz/cake
 /// <summary>
 /// Initializes a new instance of the <see cref="ScriptHost"/> class.
 /// </summary>
 /// <param name="engine">The engine.</param>
 /// <param name="context">The context.</param>
 protected ScriptHost(ICakeEngine engine, ICakeContext context)
 {
     if (engine == null)
     {
         throw new ArgumentNullException(nameof(engine));
     }
     if (context == null)
     {
         throw new ArgumentNullException(nameof(context));
     }
     Engine  = engine;
     Context = context;
 }
コード例 #15
0
        public override bool Execute(ICakeEngine engine, CakeHostOptions options)
        {
            _log.Information("Performing dry run...");
            _log.Information("Target is: {0}", options.Target);
            _log.Information(string.Empty);

            var strategy = new DryRunExecutionStrategy(_log);

            engine.RunTarget(_context, strategy, options.Target);

            _log.Information(string.Empty);
            _log.Information("This was a dry run.");
            _log.Information("No tasks were actually executed.");

            return(true);
        }
コード例 #16
0
        public override async Task <bool> ExecuteAsync(ICakeEngine engine, CakeHostOptions options)
        {
            _executionSettings.SetTarget(options.Target);

            _log.Information("Performing dry run...");
            _log.Information("Target is: {0}", options.Target);
            _log.Information(string.Empty);

            var strategy = new DryRunExecutionStrategy(_log);
            await engine.RunTargetAsync(_context, strategy, _executionSettings).ConfigureAwait(false);

            _log.Information(string.Empty);
            _log.Information("This was a dry run.");
            _log.Information("No tasks were actually executed.");

            return(true);
        }
コード例 #17
0
ファイル: FrostingEngine.cs プロジェクト: weiplanet/cake
 protected FrostingEngine(
     THost host,
     ICakeEngine engine, IFrostingContext context, ICakeLog log,
     IEnumerable <IFrostingTask> tasks,
     IFrostingSetup setup               = null,
     IFrostingTeardown teardown         = null,
     IFrostingTaskSetup taskSetup       = null,
     IFrostingTaskTeardown taskTeardown = null)
 {
     _host         = host;
     _engine       = engine;
     _context      = context;
     _log          = log;
     _setup        = setup;
     _teardown     = teardown;
     _taskSetup    = taskSetup;
     _taskTeardown = taskTeardown;
     _tasks        = new List <IFrostingTask>(tasks ?? Array.Empty <IFrostingTask>());
 }
コード例 #18
0
        public CakeHost(CakeHostOptions options, CakeHostServices services, ILifetimeScope scope,
                        IFrostingContext context,
                        IEnumerable <IFrostingTask> tasks = null, IFrostingLifetime lifetime = null, IFrostingTaskLifetime taskLifetime = null)
        {
            Guard.ArgumentNotNull(scope, nameof(scope));
            Guard.ArgumentNotNull(services, nameof(services));
            Guard.ArgumentNotNull(context, nameof(context));
            Guard.ArgumentNotNull(options, nameof(options));

            _options      = options;
            _scope        = scope; // Keep the scope alive.
            _context      = context;
            _tasks        = tasks;
            _lifetime     = lifetime;
            _taskLifetime = taskLifetime;

            _environment       = services.Environment;
            _engine            = services.Engine;
            _log               = services.Log;
            _commandFactory    = services.CommandFactory;
            _engineInitializer = services.EngineInitializer;
        }
コード例 #19
0
ファイル: HelpCommand.cs プロジェクト: lexusean/frosting
        public override bool Execute(ICakeEngine engine, CakeHostOptions options)
        {
            _console.Write("Cake.Frosting (");
            _console.ForegroundColor = ConsoleColor.Yellow;
            _console.Write(typeof(HelpCommand).GetTypeInfo().Assembly.GetName().Version.ToString(3));
            _console.ResetColor();
            _console.WriteLine(")");

            _console.WriteLine("Usage:");
            _console.WriteLine("  dotnet {0}.dll [options]", typeof(HelpCommand).GetTypeInfo().Assembly.GetName().Name);
            _console.WriteLine();
            _console.WriteLine("Options:");
            _console.WriteLine("  --target|-t <TARGET>          Sets the build target");
            _console.WriteLine("  --working|-w <DIR>            Sets the working directory");
            _console.WriteLine("  --verbosity|-v <VERBOSITY>    Sets the verbosity");
            _console.WriteLine("  --dryrun|-r                   Performs a dry run");
            _console.WriteLine("  --version                     Displays Cake.Frosting version number");
            _console.WriteLine("  --help|-h                     Show help");
            _console.WriteLine();

            return(true);
        }
コード例 #20
0
        public CakeHost(IFrostingContext context, Container container, CakeHostOptions options,
                        IFileSystem fileSystem, ICakeEnvironment environment, ICakeEngine engine, ICakeLog log,
                        IToolInstaller installer, IEnumerable <PackageReference> tools,
                        EngineInitializer engineInitializer, CommandFactory commandFactory,
                        WorkingDirectory workingDirectory = null, IEnumerable <IFrostingTask> tasks  = null,
                        IFrostingLifetime lifetime        = null, IFrostingTaskLifetime taskLifetime = null)
        {
            Guard.ArgumentNotNull(context, nameof(context));
            Guard.ArgumentNotNull(container, nameof(container));
            Guard.ArgumentNotNull(options, nameof(options));
            Guard.ArgumentNotNull(fileSystem, nameof(fileSystem));
            Guard.ArgumentNotNull(environment, nameof(environment));
            Guard.ArgumentNotNull(engine, nameof(engine));
            Guard.ArgumentNotNull(log, nameof(log));
            Guard.ArgumentNotNull(engineInitializer, nameof(engineInitializer));
            Guard.ArgumentNotNull(commandFactory, nameof(commandFactory));

            // Mandatory arguments.
            _context           = context;
            _container         = container;
            _options           = options;
            _fileSystem        = fileSystem;
            _environment       = environment;
            _engine            = engine;
            _log               = log;
            _installer         = installer;
            _tools             = new List <PackageReference>(tools ?? Enumerable.Empty <PackageReference>());
            _engineInitializer = engineInitializer;
            _commandFactory    = commandFactory;

            // Optional arguments.
            _workingDirectory = workingDirectory;
            _tasks            = tasks;
            _lifetime         = lifetime;
            _taskLifetime     = taskLifetime;
        }
コード例 #21
0
        public CakeHostServices(ICakeEnvironment environment, ICakeEngine engine, ICakeLog log,
                                EngineInitializer engineInitializer, CommandFactory commandFactory)
        {
            Guard.ArgumentNotNull(environment, nameof(environment));
            Guard.ArgumentNotNull(engine, nameof(engine));
            Guard.ArgumentNotNull(log, nameof(log));
            Guard.ArgumentNotNull(engineInitializer, nameof(engineInitializer));
            Guard.ArgumentNotNull(commandFactory, nameof(commandFactory));

            if (environment == null)
            {
                throw new ArgumentNullException(nameof(environment));
            }
            if (engine == null)
            {
                throw new ArgumentNullException(nameof(engine));
            }
            if (log == null)
            {
                throw new ArgumentNullException(nameof(log));
            }
            if (engineInitializer == null)
            {
                throw new ArgumentNullException(nameof(engineInitializer));
            }
            if (commandFactory == null)
            {
                throw new ArgumentNullException(nameof(commandFactory));
            }

            Environment       = environment;
            Engine            = engine;
            Log               = log;
            CommandFactory    = commandFactory;
            EngineInitializer = engineInitializer;
        }
コード例 #22
0
        public override async Task <bool> ExecuteAsync(ICakeEngine engine, CakeHostOptions options)
        {
            await _command.ExecuteAsync(engine, options).ConfigureAwait(false);

            return(false);
        }
コード例 #23
0
ファイル: BuildScriptHost.cs プロジェクト: geffzhang/CodeCake
 /// <summary>
 /// Initializes a new instance of the <see cref="BuildScriptHost"/> class.
 /// </summary>
 /// <param name="engine">The engine.</param>
 /// <param name="context">The context.</param>
 public BuildScriptHost(
     ICakeEngine engine,
     ICakeContext context)
     : base(engine, context)
 {
 }
コード例 #24
0
 public DescriptionScriptHost(ICakeEngine engine, IConsole console)
     : base(engine)
 {
     _console      = console;
     _descriptions = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase);
 }
コード例 #25
0
 public static bool IsTaskRegistered(this ICakeEngine engine, string name)
 {
     return(engine.Tasks.Any(e => e.Name.Equals(name, StringComparison.OrdinalIgnoreCase)));
 }
コード例 #26
0
 public override bool Execute(ICakeEngine engine, CakeHostOptions options)
 {
     _command.Execute(engine, options);
     return(false);
 }
コード例 #27
0
 public MyCakeEngine(ICakeDataService dataService, ICakeLog log)
 {
     _cakeEngine = new CakeEngine(dataService, log);
     RegisterTasks();
 }
コード例 #28
0
ファイル: ScriptHost.cs プロジェクト: weiplanet/cake
 /// <summary>
 /// Initializes a new instance of the <see cref="ScriptHost"/> class.
 /// </summary>
 /// <param name="engine">The engine.</param>
 /// <param name="context">The context.</param>
 protected ScriptHost(ICakeEngine engine, ICakeContext context)
 {
     Engine   = engine ?? throw new ArgumentNullException(nameof(engine));
     Context  = context ?? throw new ArgumentNullException(nameof(context));
     Settings = new ExecutionSettings();
 }
コード例 #29
0
 protected CakeEngineBase(ICakeEngine implementation)
 {
     _engine = implementation;
 }
コード例 #30
0
        public void Initialize(ICakeEngine engine, IFrostingContext context, IEnumerable <IFrostingTask> tasks,
                               IFrostingLifetime lifetime, IFrostingTaskLifetime taskLifetime)
        {
            if (tasks != null)
            {
                foreach (var task in tasks)
                {
                    var taskName = TaskNameHelper.GetTaskName(task);
                    _log.Debug("Registering task: {0}", taskName);

                    // Get the task's context type.
                    if (!task.HasCompatibleContext(context))
                    {
                        const string format = "Task cannot be used since the context isn't convertible to {0}.";
                        _log.Warning(format, task.GetContextType().FullName);
                    }
                    else
                    {
                        // Register task with the Cake engine.
                        var cakeTask = engine.RegisterTask(taskName);

                        // Is the run method overridden?
                        if (task.IsRunOverridden(context))
                        {
                            cakeTask.Does(c => task.Run(c));
                        }

                        // Is the criteria method overridden?
                        if (task.IsShouldRunOverridden(context))
                        {
                            cakeTask.WithCriteria(task.ShouldRun);
                        }

                        // Continue on error?
                        if (task.IsContinueOnError())
                        {
                            cakeTask.ContinueOnError();
                        }

                        // Is the on error method overridden?
                        if (task.IsOnErrorOverridden(context))
                        {
                            cakeTask.OnError(exception => task.OnError(exception, context));
                        }

                        // Is the finally method overridden?
                        if (task.IsFinallyOverridden(context))
                        {
                            cakeTask.Finally(() => task.Finally(context));
                        }

                        // Add dependencies
                        var attributes = task.GetType().GetTypeInfo().GetCustomAttributes <DependencyAttribute>();
                        foreach (var dependency in attributes)
                        {
                            var dependencyName = TaskNameHelper.GetTaskName(dependency);
                            if (!typeof(IFrostingTask).IsAssignableFrom(dependency.Task))
                            {
                                throw new FrostingException($"The dependency '{dependencyName}' is not a valid task.");
                            }
                            cakeTask.IsDependentOn(dependencyName);
                        }
                    }
                }
            }

            if (lifetime != null)
            {
                _log.Debug("Registering lifetime: {0}", lifetime.GetType().Name);

                if (lifetime.IsSetupOverridden(context))
                {
                    engine.RegisterSetupAction(info => lifetime.Setup(context));
                }
                if (lifetime.IsTeardownOverridden(context))
                {
                    engine.RegisterTeardownAction(info => lifetime.Teardown(context, info));
                }
            }

            if (taskLifetime != null)
            {
                _log.Debug("Registering task lifetime: {0}", taskLifetime.GetType().Name);

                if (taskLifetime.IsSetupOverridden(context))
                {
                    engine.RegisterTaskSetupAction(info => taskLifetime.Setup(context, info));
                }

                if (taskLifetime.IsTeardownOverridden(context))
                {
                    engine.RegisterTaskTeardownAction(info => taskLifetime.Teardown(context, info));
                }
            }
        }
コード例 #31
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BuildScriptHost"/> class.
 /// </summary>
 /// <param name="engine">The engine.</param>
 /// <param name="context">The context.</param>
 public BuildScriptHost(
     ICakeEngine engine,
     ICakeContext context )
     : base(engine, context)
 {
 }