static CakeAPI() { var env = new CakeEnvironment(new CakePlatform(), new CakeRuntime()); var fileSystem = new FileSystem(); var verbosity = Verbosity.Normal; if (Startup.HasArgument("cake-verbosity")) { verbosity = Enum.Parse <Verbosity>(Startup.Argument("cake-verbosity")); } var cakeLog = new CakeBuildLog(new CakeConsole(env), verbosity); var cakeConfiguration = new CakeConfiguration(new Dictionary <string, string>()); var toolRepos = new ToolRepository(env); Globber = new Globber(fileSystem, env); var cakeDataService = new CakeDataService(); var registry = new WindowsRegistry(); var toolLocator = new ToolLocator(env, toolRepos, new ToolResolutionStrategy(fileSystem, env, Globber, cakeConfiguration, cakeLog)); var cakeArgs = new CakeArguments(new List <string>().ToLookup(x => x)); var procRunner = new ProcessRunner(fileSystem, env, cakeLog, toolLocator, cakeConfiguration); Context = new CakeContext(fileSystem, env, Globber, cakeLog, cakeArgs, procRunner, registry, toolLocator, cakeDataService, cakeConfiguration); }
public FakeCakeContext() { testsDir = new DirectoryPath( System.IO.Path.GetFullPath(AppContext.BaseDirectory)); var fileSystem = new FileSystem(); log = new FakeLog(); var runtime = new CakeRuntime(); var platform = new FakePlatform(PlatformFamily.Windows); var environment = new CakeEnvironment(platform, runtime); var globber = new Globber(fileSystem, environment); var args = new FakeCakeArguments(); var registry = new WindowsRegistry(); var dataService = new FakeDataService(); var toolRepository = new ToolRepository(environment); var config = new FakeConfiguration(); var toolResolutionStrategy = new ToolResolutionStrategy(fileSystem, environment, globber, config, log); IToolLocator tools = new ToolLocator(environment, toolRepository, toolResolutionStrategy); var processRunner = new ProcessRunner(fileSystem, environment, log, tools, config); context = new CakeContext(fileSystem, environment, globber, log, args, processRunner, registry, tools, dataService, config); context.Environment.WorkingDirectory = testsDir; }
public FakeCakeContext() { var fileSystem = new FileSystem(); Log = new FakeLog(); var runtime = new CakeRuntime(); var platform = new FakePlatform(PlatformFamily.Windows); var environment = new CakeEnvironment(platform, runtime, Log); var globber = new Globber(fileSystem, environment); var args = Substitute.For <ICakeArguments>(); var registry = new WindowsRegistry(); var dataService = Substitute.For <ICakeDataService>(); var toolRepository = new ToolRepository(environment); var toolResolutionStrategy = new ToolResolutionStrategy(fileSystem, environment, globber, new FakeConfiguration()); var tools = new ToolLocator(environment, toolRepository, toolResolutionStrategy); var processRunner = new ProcessRunner(fileSystem, environment, Log, tools, new FakeConfiguration()); Context = new CakeContext(fileSystem, environment, globber, Log, args, processRunner, registry, tools, dataService); WorkingDirectory = new DirectoryPath( System.IO.Path.GetFullPath(AppContext.BaseDirectory)); Context.Environment.WorkingDirectory = WorkingDirectory; }
private static IEnumerable<IFile> Install(NuGetConfiguration configuration, DirectoryPath appDataPath) { var fileSystem = new FileSystem(); var environment = new CakeEnvironment(); var globber = new Globber(fileSystem, environment); var installer = new NuGetInstaller(fileSystem, globber); return installer.Install(configuration, appDataPath, true); }
internal static IEnumerable <string> GetCSharpFilesFromProject(string csProjFolderPath) { var csProjFilePath = Directory.EnumerateFiles(csProjFolderPath, "*.csproj", SearchOption.TopDirectoryOnly).SingleOrDefault(); if (csProjFilePath is null) { throw new FileNotFoundException(); } var fileSystem = new Cake.Core.IO.FileSystem(); var platform = new CakePlatform(); var runtime = new CakeRuntime(); var cakeConsole = new CakeConsole(); var cakeLog = new CakeBuildLog(cakeConsole, Verbosity.Diagnostic); var environment = new CakeEnvironment(platform, runtime, cakeLog); var projectPath = new Cake.Core.IO.FilePath(csProjFilePath); if (projectPath.IsRelative) { projectPath = projectPath.MakeAbsolute(environment); } var projectFile = fileSystem.GetFile(projectPath); var parseResult = projectFile.ParseProjectFile("Debug"); // TODO: do not assume all .cs files are included by default? // TODO: do not return .cs files that are removed from Compile in the .csproj foreach (var sourceFile in GetCSharpFilesFromFolder(csProjFolderPath)) { yield return(sourceFile); } // TODO: if a project or package is encountered multiple times through recursion, ensure it only gets evaluated once (use HashSet?) // TODO: handle the case where a library is referenced as both a projectReference and a packageReference (NuGet gives error when this happens) foreach (var projectReference in parseResult.ProjectReferences) { // TODO: test that this works correctly foreach (var sourceFile in GetCSharpFilesFromProject(projectReference.FilePath.FullPath)) { yield return(sourceFile); } } // Assume package reference is either a .Sources package, or it's not and has no .cs files packed. foreach (var packageReference in parseResult.PackageReferences) { // TODO: try to get source files from package's dependencies (recursively) foreach (var sourceFile in DiscoverPackageReferenceSourceFiles(packageReference.Name, packageReference.Version)) { yield return(sourceFile); } } }
public FakeCakeContext () { testsDir = new DirectoryPath ( System.IO.Path.GetFullPath (AppDomain.CurrentDomain.BaseDirectory)); var fileSystem = new FileSystem (); var environment = new CakeEnvironment (); var globber = new Globber (fileSystem, environment); log = new FakeLog (); var args = new FakeCakeArguments (); var processRunner = new ProcessRunner (environment, log); var registry = new WindowsRegistry (); context = new CakeContext (fileSystem, environment, globber, log, args, processRunner, registry); context.Environment.WorkingDirectory = testsDir; }
public FakeSession() { testsDir = new DirectoryPath( System.IO.Path.GetFullPath(AppDomain.CurrentDomain.BaseDirectory)); var fileSystem = new FileSystem(); var environment = new CakeEnvironment(); var globber = new Globber(fileSystem, environment); log = new FakeLog(); var args = new FakeCakeArguments(); var processRunner = new ProcessRunner(environment, log); var registry = new WindowsRegistry(); context = new CakeContext(fileSystem, environment, globber, log, args, processRunner, registry); context.Environment.WorkingDirectory = testsDir; }
public static IScriptHost GetScriptHost() { var console = new CakeConsole(); ICakeLog log = new CakeBuildLog(console); IFileSystem fileSystem = new FileSystem(); ICakeDataService data = new BridgeDataService(); ICakeEnvironment environment = new CakeEnvironment( new CakePlatform(), new CakeRuntime(), log ); IGlobber globber = new Globber(fileSystem, environment); ICakeArguments arguments = new BridgeArguments(); ICakeConfiguration configuration = new BridgeConfiguration(); IToolLocator tools = new ToolLocator( environment, new ToolRepository(environment), new ToolResolutionStrategy( fileSystem, environment, globber, configuration ) ); ICakeContext context = new CakeContext( fileSystem, environment, globber, log, arguments, new ProcessRunner(fileSystem, environment, log, tools, configuration), new WindowsRegistry(), tools, data, configuration ); return(new BridgeScriptHost( new CakeEngine(data, log), context, new DefaultExecutionStrategy(log), new CakeReportPrinter(console, context), arguments )); }
public FakeCakeContext() { testsDir = new DirectoryPath(System.IO.Path.Combine(System.IO.Path.GetFullPath(AppDomain.CurrentDomain.BaseDirectory), "..", "..", "..")); log = new FakeCakeLog(); var fileSystem = new FileSystem(); var environment = new CakeEnvironment(new CakePlatform(), new CakeRuntime(), log); var globber = new Globber(fileSystem, environment); var args = new FakeCakeArguments(); var processRunner = new ProcessRunner(environment, log); var registry = new WindowsRegistry(); var toolRepo = new ToolRepository(environment); var config = new Core.Configuration.CakeConfigurationProvider(fileSystem, environment).CreateConfiguration(testsDir, new Dictionary <string, string>()); var toolResolutionStrategy = new ToolResolutionStrategy(fileSystem, environment, globber, config); var toolLocator = new ToolLocator(environment, toolRepo, toolResolutionStrategy); context = new CakeContext(fileSystem, environment, globber, log, args, processRunner, registry, toolLocator); context.Environment.WorkingDirectory = testsDir; }
public FakeCakeContext () { testsDir = new DirectoryPath ( System.IO.Path.GetFullPath (AppDomain.CurrentDomain.BaseDirectory)); var fileSystem = new FileSystem (); var environment = new CakeEnvironment (new CakePlatform (), new CakeRuntime ()); var globber = new Globber (fileSystem, environment); log = new FakeLog (); var args = new FakeCakeArguments (); var processRunner = new ProcessRunner (environment, log); var registry = new WindowsRegistry (); var toolRepo = new ToolRepository (environment); var config = new Core.Configuration.CakeConfigurationProvider (fileSystem, environment).CreateConfiguration (testsDir, new Dictionary<string, string> ()); var toolResolutionStrategy = new ToolResolutionStrategy (fileSystem, environment, globber, config); var toolLocator = new ToolLocator (environment, toolRepo, toolResolutionStrategy); context = new CakeContext (fileSystem, environment, globber, log, args, processRunner, registry, toolLocator); context.Environment.WorkingDirectory = testsDir; }
public FakeCakeContext () { testsDir = new DirectoryPath ( System.IO.Path.GetDirectoryName (System.Reflection.Assembly.GetExecutingAssembly ().Location)); var fileSystem = new FileSystem (); var environment = new CakeEnvironment (); var globber = new Globber (fileSystem, environment); log = new FakeLog (); var args = new FakeCakeArguments (); var processRunner = new ProcessRunner (environment, log); var registry = new WindowsRegistry (); var toolRepo = new ToolRepository (environment); var config = new Core.Configuration.CakeConfigurationProvider (fileSystem, environment).CreateConfiguration (new Dictionary<string, string> ()); var toolResStrat = new ToolResolutionStrategy (fileSystem, environment, globber, config); var toolLocator = new ToolLocator (environment, toolRepo, toolResStrat); context = new CakeContext (fileSystem, environment, globber, log, args, processRunner, registry, toolLocator); context.Environment.WorkingDirectory = testsDir; }
public FakeCakeContext() { _testsDir = new DirectoryPath( System.IO.Path.GetFullPath(AppDomain.CurrentDomain.BaseDirectory)); var fileSystem = new FileSystem(); _log = new FakeLog(); var environment = new CakeEnvironment(new CakePlatform(), new CakeRuntime(), _log); var globber = new Globber(fileSystem, environment); var args = new FakeCakeArguments(); var processRunner = new ProcessRunner(environment, _log); var registry = new WindowsRegistry(); var toolLocator = new ToolLocator(environment, new ToolRepository(environment), new ToolResolutionStrategy(fileSystem, environment, globber, new FakeConfiguration())); _context = new CakeContext(fileSystem, environment, globber, _log, args, processRunner, registry, toolLocator); _context.Environment.WorkingDirectory = _testsDir; }
public FakeCakeContext() { testsDir = new DirectoryPath( System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location)); var fileSystem = new FileSystem(); var environment = new CakeEnvironment(); var globber = new Globber(fileSystem, environment); log = new FakeLog(); var args = new FakeCakeArguments(); var processRunner = new ProcessRunner(environment, log); var registry = new WindowsRegistry(); var toolRepo = new ToolRepository(environment); var config = new Core.Configuration.CakeConfigurationProvider(fileSystem, environment).CreateConfiguration(new Dictionary <string, string> ()); var toolResStrat = new ToolResolutionStrategy(fileSystem, environment, globber, config); var toolLocator = new ToolLocator(environment, toolRepo, toolResStrat); context = new CakeContext(fileSystem, environment, globber, log, args, processRunner, registry, toolLocator); context.Environment.WorkingDirectory = testsDir; }
public static DocumentModel Download( DirectoryPath appDataPath, NuGetConfiguration configuration, out string version) { var fileSystem = new FileSystem(); var environment = new CakeEnvironment(); var globber = new Globber(fileSystem, environment); var installer = new NuGetInstaller(fileSystem, globber); var files = new Dictionary <string, IDocumentationMetadata>(); foreach (var package in configuration.Packages) { var packageFiles = installer.Install(package, appDataPath); foreach (var packageFile in packageFiles) { files.Add(packageFile.Path.FullPath, package.Metadata); } } // Find Cake.exe. version = "0.5.2"; // Default to this version if we could not find. var exe = files.Keys.FirstOrDefault(x => x.EndsWith("Cake.Core.dll")); if (exe != null) { var name = AssemblyName.GetAssemblyName(exe); if (name != null) { version = string.Format("{0}.{1}.{2}", name.Version.Major, name.Version.Minor, name.Version.Build); } } // Build the model. return(new DocumentModelBuilder() .BuildModel(files)); }
public static DocumentModel Download( DirectoryPath appDataPath, NuGetConfiguration configuration, out string version) { var fileSystem = new FileSystem(); var environment = new CakeEnvironment(); var globber = new Globber(fileSystem, environment); var installer = new NuGetInstaller(fileSystem, globber); var files = new Dictionary<string, IDocumentationMetadata>(); foreach (var package in configuration.Packages) { var packageFiles = installer.Install(package, appDataPath); foreach (var packageFile in packageFiles) { files.Add(packageFile.Path.FullPath, package.Metadata); } } // Find Cake.exe. version = "0.5.2"; // Default to this version if we could not find. var exe = files.Keys.FirstOrDefault(x => x.EndsWith("Cake.Core.dll")); if (exe != null) { var name = AssemblyName.GetAssemblyName(exe); if (name != null) { version = string.Format("{0}.{1}.{2}", name.Version.Major, name.Version.Minor, name.Version.Build); } } // Build the model. return new DocumentModelBuilder() .BuildModel(files); }