public BridgeScriptHost(ICakeEngine engine, ICakeContext context, IExecutionStrategy strategy, ICakeReportPrinter reporter, ICakeArguments arguments) : base(engine, context) { Strategy = strategy; Reporter = reporter; Arguments = arguments; }
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) { }
/// <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; }
/// <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) { }
/// <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; }
/// <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; }
/// <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; }
/// <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); }
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); }
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); }
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); }
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)); } }
/// <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; }
/// <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; }
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); }
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); }
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>()); }
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; }
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); }
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; }
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; }
public override async Task <bool> ExecuteAsync(ICakeEngine engine, CakeHostOptions options) { await _command.ExecuteAsync(engine, options).ConfigureAwait(false); return(false); }
/// <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) { }
public DescriptionScriptHost(ICakeEngine engine, IConsole console) : base(engine) { _console = console; _descriptions = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase); }
public static bool IsTaskRegistered(this ICakeEngine engine, string name) { return(engine.Tasks.Any(e => e.Name.Equals(name, StringComparison.OrdinalIgnoreCase))); }
public override bool Execute(ICakeEngine engine, CakeHostOptions options) { _command.Execute(engine, options); return(false); }
public MyCakeEngine(ICakeDataService dataService, ICakeLog log) { _cakeEngine = new CakeEngine(dataService, log); RegisterTasks(); }
/// <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(); }
protected CakeEngineBase(ICakeEngine implementation) { _engine = implementation; }
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)); } } }
/// <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) { }