static ProjectReference() { var platform = new CakePlatform(); var runtime = new CakeRuntime(); var cakeConsole = new CakeConsole(); var cakeLog = new CakeBuildLog(cakeConsole, Verbosity.Diagnostic); _environment = new CakeEnvironment(platform, runtime, cakeLog); _fileSystem = new Cake.Core.IO.FileSystem(); }
static ProjectHelper() { var platform = new CakePlatform(); var runtime = new CakeRuntime(); var cakeConsole = new CakeConsole(); var cakeLog = new CakeBuildLog(cakeConsole, Verbosity.Quiet); _environment = new CakeEnvironment(platform, runtime, cakeLog); _fileSystem = new FileSystem(); }
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 void Should_Create_Instance_Registration_As_Singleton_By_Default() { // Given var registry = new ContainerRegistry(); var instance = new CakeConsole(); // When registry.RegisterInstance(instance); // Then Assert.Equal(1, registry.Registrations.Count); Assert.Equal(typeof(CakeConsole), registry.Registrations[0].ImplementationType); Assert.Equal(instance, registry.Registrations[0].Instance); Assert.True(registry.Registrations[0].IsSingleton); }
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 static void PrintHeader(this ICakeContext context, CakeConsole cakeConsole, ConsoleColor foregroundColor) { cakeConsole.WriteLine("Sitecore Demo Build Tasks"); cakeConsole.ResetColor(); }