/// <summary> /// Executes supplied cake script in own process and supplied settings. /// </summary> /// <param name="scriptPath">Path to script to execute.</param> /// <param name="settings">optional cake settings.</param> public void ExecuteScript(FilePath scriptPath, CakeSettings settings = null) { if (scriptPath == null) { throw new ArgumentNullException(nameof(scriptPath)); } scriptPath = scriptPath.MakeAbsolute(_environment); if (!_fileSystem.GetFile(scriptPath).Exists) { throw new FileNotFoundException("Cake script file not found.", scriptPath.FullPath); } settings = settings ?? new CakeSettings(); var toolPath = GetToolPath(settings); if (toolPath?.GetFilename().FullPath == "Cake.dll") { _coreExecutor.Execute( toolPath, GetArguments(scriptPath, settings), new DotNetCoreExecuteSettings { ArgumentCustomization = settings.ArgumentCustomization, EnvironmentVariables = settings.EnvironmentVariables, ToolTimeout = settings.ToolTimeout, WorkingDirectory = settings.WorkingDirectory }); } else { Run(settings, GetArguments(scriptPath, settings)); } }
public static void DotNetCoreExecute(this ICakeContext context, FilePath assemblyPath, ProcessArgumentBuilder arguments, DotNetCoreSettings settings) { if (context == null) { throw new ArgumentNullException("context"); } if (assemblyPath == null) { throw new ArgumentNullException("assemblyPath"); } if (settings == null) { settings = new DotNetCoreExecuteSettings(); } var executor = new DotNetCoreExecutor(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools); executor.Execute(assemblyPath, arguments, settings); }
protected override void RunTool() { var tool = new DotNetCoreExecutor(FileSystem, Environment, ProcessRunner, Tools); tool.Execute(AssemblyPath, Arguments, Settings); }