/// <summary> /// Initializes a new instance of the <see cref="NuGetPackageInstaller"/> class. /// </summary> /// <param name="fileSystem">The file system.</param> /// <param name="environment">The environment.</param> /// <param name="contentResolver">The content resolver.</param> /// <param name="log">The log.</param> /// <param name="config">the configuration.</param> public NuGetPackageInstaller( IFileSystem fileSystem, ICakeEnvironment environment, INuGetContentResolver contentResolver, ICakeLog log, ICakeConfiguration config) { _fileSystem = fileSystem ?? throw new ArgumentNullException(nameof(fileSystem)); _environment = environment ?? throw new ArgumentNullException(nameof(environment)); _contentResolver = contentResolver ?? throw new ArgumentNullException(nameof(contentResolver)); _log = log ?? throw new ArgumentNullException(nameof(log)); _config = config ?? throw new ArgumentNullException(nameof(config)); _currentFramework = NuGetFramework.Parse(_environment.Runtime.BuiltFramework.FullName, DefaultFrameworkNameProvider.Instance); _nugetLogger = new NuGetLogger(_log); var nugetConfig = GetNuGetConfigPath(_environment, _config, _fileSystem); var nugetConfigDirectoryPath = nugetConfig.Item1; var nugetConfigFilePath = nugetConfig.Item2; _log.Debug(nugetConfigFilePath != null ? $"Found NuGet Config at: {nugetConfigDirectoryPath}/{nugetConfigFilePath}" : "NuGet Config not specified. Will use NuGet default mechanism for resolving it."); _nugetSettings = Settings.LoadDefaultSettings( nugetConfigDirectoryPath.FullPath, nugetConfigFilePath?.GetFilename().ToString(), new XPlatMachineWideSetting()); _sourceCacheContext = new SourceCacheContext(); }
public ModuleLoader(ModuleSearcher searcher, ICakeLog log, ICakeConfiguration configuration, ICakeEnvironment environment) { _searcher = searcher; _log = log; _configuration = configuration; _environment = environment; }
/// <summary> /// Initializes a new instance of the <see cref="NuGetPackageInstaller"/> class. /// </summary> /// <param name="fileSystem">The file system.</param> /// <param name="environment">The environment.</param> /// <param name="contentResolver">The content resolver.</param> /// <param name="log">The log.</param> /// <param name="config">the configuration</param> public NuGetPackageInstaller( IFileSystem fileSystem, ICakeEnvironment environment, INuGetContentResolver contentResolver, ICakeLog log, ICakeConfiguration config) { _fileSystem = fileSystem ?? throw new ArgumentNullException(nameof(fileSystem)); _environment = environment ?? throw new ArgumentNullException(nameof(environment)); _contentResolver = contentResolver ?? throw new ArgumentNullException(nameof(contentResolver)); _log = log ?? throw new ArgumentNullException(nameof(log)); _config = config ?? throw new ArgumentNullException(nameof(config)); _currentFramework = NuGetFramework.Parse(_environment.Runtime.BuiltFramework.FullName, DefaultFrameworkNameProvider.Instance); _nugetLogger = new NuGetLogger(_log); var nugetConfig = GetNuGetConfigPath(_environment, _config); var nugetConfigDirectoryPath = nugetConfig.Item1; var nugetConfigFilePath = nugetConfig.Item2; if (nugetConfigFilePath != null) { _log.Debug($"Found NuGet.config at: {nugetConfigFilePath}"); } else { _log.Debug("NuGet.config not found."); } _nugetSettings = Settings.LoadDefaultSettings( nugetConfigDirectoryPath.FullPath, nugetConfigFilePath?.GetFilename().ToString(), new XPlatMachineWideSetting()); _gatherCache = new GatherCache(); }
public DNFPackageInstaller(ICakeEnvironment environment, IProcessRunner processRunner, ICakeLog log, IDNFContentResolver contentResolver, ICakeConfiguration config) { if (environment == null) { throw new ArgumentNullException(nameof(environment)); } if (processRunner == null) { throw new ArgumentNullException(nameof(processRunner)); } if (log == null) { throw new ArgumentNullException(nameof(log)); } if (contentResolver == null) { throw new ArgumentNullException(nameof(contentResolver)); } _environment = environment; _processRunner = processRunner; _log = log; _contentResolver = contentResolver; _config = config; }
public void Configure( ICakeContainerRegistrar registrar, ICakeConfiguration configuration, IRemainingArguments arguments) { // Arguments registrar.RegisterInstance(new CakeArguments(arguments.Parsed)).AsSelf().As <ICakeArguments>(); // Scripting registrar.RegisterType <RoslynScriptEngine>().As <IScriptEngine>().Singleton(); registrar.RegisterType <BuildScriptHost>().Singleton(); registrar.RegisterType <DryRunScriptHost>().Singleton(); registrar.RegisterType <TreeScriptHost>().Singleton(); registrar.RegisterType <DescriptionScriptHost>().Singleton(); // Diagnostics registrar.RegisterType <CakeBuildLog>().As <ICakeLog>().Singleton(); registrar.RegisterType <CakeDebugger>().As <ICakeDebugger>().Singleton(); // External modules new CoreModule().Register(registrar); new CommonModule().Register(registrar); new NuGetModule().Register(registrar); // Misc registrations. registrar.RegisterType <CakeReportPrinter>().As <ICakeReportPrinter>().Singleton(); registrar.RegisterType <CakeConsole>().As <IConsole>().Singleton(); registrar.RegisterInstance(configuration).As <ICakeConfiguration>().Singleton(); }
public void Setup() { _settings = new GraphiteSettings() { Host = "192.0.2.0", HttpApiPort = 10, BatchSize = 500, ThrowExceptions = true }; _log = new FakeLog(); _configuration = new FakeConfiguration(); _environment = new FakeEnvironment(PlatformFamily.Windows) { WorkingDirectory = new DirectoryPath(Environment.CurrentDirectory) }; _fileSystem = new FakeFileSystem(_environment); _globber = new Globber(_fileSystem, _environment); var mockArguments = new Mock <ICakeArguments>(); mockArguments.Setup(x => x.GetArgument(It.IsAny <string>())).Returns(string.Empty); mockArguments.Setup(x => x.HasArgument(It.IsAny <string>())).Returns(false); _arguments = mockArguments.Object; _toolLocator = new ToolLocator(_environment, new ToolRepository(_environment), new ToolResolutionStrategy(_fileSystem, _environment, _globber, _configuration)); _processRunner = new ProcessRunner(_fileSystem, _environment, _log, _toolLocator, _configuration); var mockDataService = new Mock <ICakeDataService>(); mockDataService.Setup(x => x.Add(It.IsAny <string>())); _dataService = mockDataService.Object; _context = new CakeContext(_fileSystem, _environment, _globber, _log, _arguments, _processRunner, new WindowsRegistry(), _toolLocator, _dataService, _configuration); }
public CakeScriptGenerator( IBufferedFileSystem fileSystem, ICakeEnvironment environment, IGlobber globber, ICakeConfiguration configuration, IScriptProcessor processor, IScriptAliasFinder aliasFinder, ICakeLog log, IEnumerable <ILoadDirectiveProvider> loadDirectiveProviders = null) { _fileSystem = fileSystem ?? throw new ArgumentNullException(nameof(fileSystem)); _environment = environment ?? throw new ArgumentNullException(nameof(environment)); _globber = globber ?? throw new ArgumentNullException(nameof(globber)); _log = log ?? throw new ArgumentNullException(nameof(log)); _configuration = configuration ?? throw new ArgumentNullException(nameof(configuration)); _processor = processor ?? throw new ArgumentNullException(nameof(processor)); _aliasFinder = aliasFinder ?? throw new ArgumentNullException(nameof(fileSystem)); _analyzer = new ScriptAnalyzer(_fileSystem, _environment, _log, loadDirectiveProviders); var typeEmitter = new TypeEmitter(); var parameterEmitter = new ParameterEmitter(typeEmitter); _methodGenerator = new CakeMethodAliasGenerator(typeEmitter, parameterEmitter); _propertyGenerator = new CakePropertyAliasGenerator(typeEmitter); }
public NuGetSourceRepositoryProvider(ISettings settings, ICakeConfiguration config, PackageReference package) { // Create the package source provider (needed primarily to get default sources) PackageSourceProvider = new PackageSourceProvider(settings); // Create the default v3 resource provider _resourceProviders = new List <Lazy <INuGetResourceProvider> >(); _resourceProviders.AddRange(Repository.Provider.GetCoreV3()); // Add repositories _repositories = new List <SourceRepository>(); foreach (var source in PackageSourceProvider.LoadPackageSources()) { if (source.IsEnabled) { CreateRepository(source); } } var nugetSource = config.GetValue(Constants.NuGet.Source); if (!string.IsNullOrWhiteSpace(nugetSource)) { CreateRepository(nugetSource); } if (package.Address != null) { CreateRepository(package.Address.AbsoluteUri); } }
/// <summary> /// Initializes a new instance of the <see cref="ScriptProcessor"/> class. /// </summary> /// <param name="fileSystem">The file system.</param> /// <param name="environment">The environment.</param> /// <param name="log">The log.</param> /// <param name="tools">The tool locator.</param> /// <param name="installers">The available package installers.</param> /// <param name="configuration">The configuration.</param> public ScriptProcessor( IFileSystem fileSystem, ICakeEnvironment environment, ICakeLog log, IToolLocator tools, IEnumerable <IPackageInstaller> installers, ICakeConfiguration configuration) { if (fileSystem == null) { throw new ArgumentNullException(nameof(fileSystem)); } if (environment == null) { throw new ArgumentNullException(nameof(environment)); } if (log == null) { throw new ArgumentNullException(nameof(log)); } if (installers == null) { throw new ArgumentNullException(nameof(installers)); } _environment = environment; _log = log; _tools = tools; _installers = new List <IPackageInstaller>(installers); var skip = configuration.GetValue(Constants.Settings.SkipPackageVersionCheck); _skipPackageVersionCheck = skip != null && skip.Equals("true", StringComparison.OrdinalIgnoreCase); }
protected RoslynNightlyScriptSessionFactory( IFileSystem fileSystem, ICakeEnvironment environment, ICakeConfiguration configuration, IGlobber globber, ICakeLog log) { _fileSystem = fileSystem; _environment = environment; _configuration = configuration; _globber = globber; _log = log; _paths = new FilePath[] { @"net45/Microsoft.CodeAnalysis.dll", @"net45/Microsoft.CodeAnalysis.Scripting.CSharp.dll", @"net45/Microsoft.CodeAnalysis.Scripting.dll", @"net45/Microsoft.CodeAnalysis.Desktop.dll", @"net45/Microsoft.CodeAnalysis.CSharp.dll", @"net45/Microsoft.CodeAnalysis.CSharp.Desktop.dll", @"portable-net45+win8+wp8+wpa81/System.Collections.Immutable.dll", @"portable-net45+win8/System.Reflection.Metadata.dll", }; }
public FrostingConfiguration(IEnumerable <FrostingConfigurationValue> values, IFileSystem fileSystem, ICakeEnvironment environment, IRemainingArguments remainingArguments) { if (values is null) { throw new ArgumentNullException(nameof(values)); } if (fileSystem is null) { throw new ArgumentNullException(nameof(fileSystem)); } if (environment is null) { throw new ArgumentNullException(nameof(environment)); } var baseConfiguration = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase); foreach (var value in values) { baseConfiguration[value.Key] = value.Value; } var provider = new CakeConfigurationProvider(fileSystem, environment); var args = remainingArguments.Parsed.ToDictionary(x => x.Key, x => x.FirstOrDefault() ?? string.Empty); _cakeConfiguration = provider.CreateConfiguration(environment.WorkingDirectory, baseConfiguration, args); }
public DefaultRoslynScriptSessionFactory( IFileSystem fileSystem, ICakeEnvironment environment, ICakeConfiguration configuration, ICakeLog log) : base(fileSystem, environment, configuration, log) { }
public AssemblyVerifier(ICakeConfiguration configuration, ICakeLog log) { _log = log; var skip = configuration.GetValue(Constants.Settings.SkipVerification); _skipVerification = skip != null && skip.Equals("true", StringComparison.OrdinalIgnoreCase); }
/// <summary> /// Initializes a new instance of the <see cref="DotNetToolPackageInstaller"/> class. /// </summary> /// <param name="environment">The environment.</param> /// <param name="processRunner">The process runner.</param> /// <param name="log">The log.</param> /// <param name="contentResolver">The DotNetTool Package Content Resolver.</param> /// <param name="config">the configuration.</param> /// <param name="fileSystem">The file system.</param> public DotNetToolPackageInstaller(ICakeEnvironment environment, IProcessRunner processRunner, ICakeLog log, IDotNetToolContentResolver contentResolver, ICakeConfiguration config, IFileSystem fileSystem) { if (environment == null) { throw new ArgumentNullException(nameof(environment)); } if (processRunner == null) { throw new ArgumentNullException(nameof(processRunner)); } if (log == null) { throw new ArgumentNullException(nameof(log)); } if (contentResolver == null) { throw new ArgumentNullException(nameof(contentResolver)); } _environment = environment; _processRunner = processRunner; _log = log; _contentResolver = contentResolver; _config = config; _fileSystem = fileSystem; }
/// <summary> /// Initializes a new instance of the <see cref="ToolResolutionStrategy"/> class. /// </summary> /// <param name="fileSystem">The file system.</param> /// <param name="environment">The environment.</param> /// <param name="globber">The globber.</param> /// <param name="configuration">The configuration.</param> /// <param name="log">The log.</param> public ToolResolutionStrategy( IFileSystem fileSystem, ICakeEnvironment environment, IGlobber globber, ICakeConfiguration configuration, ICakeLog log) { if (fileSystem == null) { throw new ArgumentNullException(nameof(fileSystem)); } if (environment == null) { throw new ArgumentNullException(nameof(environment)); } if (globber == null) { throw new ArgumentNullException(nameof(globber)); } _fileSystem = fileSystem; _environment = environment; _globber = globber; _configuration = configuration; _log = log; _lock = new object(); }
public static ICakeContext CreateContext() { ICakeEnvironment enviroment = CakeHelper.CreateEnvironment(); ICakeConfiguration config = CakeHelper.CreateConfiguration(); IToolLocator toolLocator = CakeHelper.CreateToolLocator(enviroment, config); return(new CakeContext(new FileSystem(), enviroment, new Globber(new FileSystem(), enviroment), new DebugLog(), CreateArguments(), new ProcessRunner(new FileSystem(), enviroment, new DebugLog(), toolLocator, config), new WindowsRegistry(), toolLocator, new CakeDataService(), config)); }
public CakeScriptService(IOmniSharpEnvironment environment, ICakeConfiguration cakeConfiguration, ILoggerFactory loggerFactory) { _environment = environment ?? throw new ArgumentNullException(nameof(environment)); _cakeConfiguration = cakeConfiguration ?? throw new ArgumentNullException(nameof(cakeConfiguration)); _loggerFactory = loggerFactory ?? throw new ArgumentNullException(nameof(loggerFactory)); _cachedReferences = new Dictionary <string, ISet <string> >(); _cachedUsings = new Dictionary <string, ISet <string> >(); }
public DebugRoslynNightlyScriptSessionFactory( IFileSystem fileSystem, ICakeEnvironment environment, ICakeConfiguration configuration, IGlobber globber, ICakeLog log) : base(fileSystem, environment, configuration, globber, log) { }
private static string GetToolPath(ICakeEnvironment environment, ICakeConfiguration config) { var toolPath = config.GetValue(Constants.Paths.Tools); return(!string.IsNullOrWhiteSpace(toolPath) ? new DirectoryPath(toolPath).MakeAbsolute(environment).FullPath : environment.WorkingDirectory.Combine("tools").MakeAbsolute(environment).FullPath); }
/// <summary> /// Initializes a new instance of the <see cref="NpmPackageInstaller"/> class. /// </summary> /// <param name="processRunner">The process runner.</param> /// <param name="log">The log.</param> /// <param name="contentResolver">The content resolver.</param> /// <param name="config">The configuration.</param> /// <param name="toolLocator">The ToolLocator.</param> public NpmPackageInstaller(IProcessRunner processRunner, ICakeLog log, INpmContentResolver contentResolver, ICakeConfiguration config, IToolLocator toolLocator) { _processRunner = processRunner ?? throw new ArgumentNullException(nameof(processRunner)); _log = log ?? throw new ArgumentNullException(nameof(log)); _contentResolver = contentResolver ?? throw new ArgumentNullException(nameof(contentResolver)); _config = config ?? throw new ArgumentNullException(nameof(config)); _toolLocator = toolLocator ?? throw new ArgumentNullException(nameof(toolLocator)); }
/// <summary> /// Initializes a new instance of the <see cref="ScriptRunner"/> class. /// </summary> /// <param name="environment">The environment.</param> /// <param name="log">The log.</param> /// <param name="configuration">The configuration.</param> /// <param name="engine">The session factory.</param> /// <param name="aliasFinder">The alias finder.</param> /// <param name="analyzer">The script analyzer.</param> /// <param name="processor">The script processor.</param> /// <param name="conventions">The script conventions.</param> /// <param name="assemblyLoader">The assembly loader.</param> public ScriptRunner( ICakeEnvironment environment, ICakeLog log, ICakeConfiguration configuration, IScriptEngine engine, IScriptAliasFinder aliasFinder, IScriptAnalyzer analyzer, IScriptProcessor processor, IScriptConventions conventions, IAssemblyLoader assemblyLoader) { if (environment == null) { throw new ArgumentNullException(nameof(environment)); } if (log == null) { throw new ArgumentNullException(nameof(log)); } if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } if (engine == null) { throw new ArgumentNullException(nameof(engine)); } if (aliasFinder == null) { throw new ArgumentNullException(nameof(aliasFinder)); } if (analyzer == null) { throw new ArgumentNullException(nameof(analyzer)); } if (processor == null) { throw new ArgumentNullException(nameof(processor)); } if (conventions == null) { throw new ArgumentNullException(nameof(conventions)); } if (assemblyLoader == null) { throw new ArgumentNullException(nameof(assemblyLoader)); } _environment = environment; _log = log; _configuration = configuration; _engine = engine; _aliasFinder = aliasFinder; _analyzer = analyzer; _processor = processor; _conventions = conventions; _assemblyLoader = assemblyLoader; }
/// <summary> /// Gets the tool directory path. /// </summary> /// <param name="configuration">The Cake configuration.</param> /// <param name="defaultRoot">The default root path.</param> /// <param name="environment">The environment.</param> /// <returns>The tool directory path.</returns> public static DirectoryPath GetToolPath(this ICakeConfiguration configuration, DirectoryPath defaultRoot, ICakeEnvironment environment) { var toolPath = configuration.GetValue(Constants.Paths.Tools); if (!string.IsNullOrWhiteSpace(toolPath)) { return(new DirectoryPath(toolPath).MakeAbsolute(environment)); } return(defaultRoot.Combine("tools")); }
/// <summary> /// Get a config-value as a flag from the <see cref="ICakeConfiguration"/>. /// </summary> /// <param name="config">The <see cref="ICakeConfiguration"/>.</param> /// <param name="key">The config key to get.</param> /// <returns><c>true</c>, if the config key exists and equals the text <c>"True"</c>. Otherwise, <c>false</c>.</returns> public static bool GetConfigFlag(this ICakeConfiguration config, string key) { string configValue = config.GetValue(key); return(string.IsNullOrWhiteSpace(configValue) ? false : bool.TryParse(configValue, out bool fail) ? fail : false); }
public BootstrapCommand( IScriptAnalyzer analyzer, ICakeConfiguration configuration, IScriptProcessor processor, ICakeEnvironment environment) { _analyzer = analyzer; _configuration = configuration; _processor = processor; _environment = environment; }
public NuGetLoadDirectiveProvider( ICakeEnvironment environment, INuGetPackageInstaller installer, ICakeConfiguration configuration, ICakeLog log) { _environment = environment ?? throw new ArgumentNullException(nameof(environment)); _installer = installer ?? throw new ArgumentNullException(nameof(installer)); _configuration = configuration ?? throw new ArgumentNullException(nameof(configuration)); _log = log ?? throw new ArgumentNullException(nameof(log)); }
public NuGetLoadDirectiveProvider( ICakeEnvironment environment, INuGetPackageInstaller installer, ICakeConfiguration configuration, ICakeLog log) { _environment = environment; _installer = installer; _configuration = configuration; _log = log; }
/// <summary> /// Initializes a new instance of the <see cref="NpmContentResolver"/> class. /// </summary> /// <param name="fileSystem">The file system.</param> /// <param name="environment">The environment.</param> /// <param name="log">The log.</param> /// <param name="configuration">The Configuration.</param> public NpmContentResolver( IFileSystem fileSystem, ICakeEnvironment environment, ICakeLog log, ICakeConfiguration configuration) { _fileSystem = fileSystem; _environment = environment; _log = log; _configuration = configuration; }
/// <summary> /// Gets the module directory path. /// </summary> /// <param name="configuration">The Cake configuration.</param> /// <param name="defaultRoot">The default root path.</param> /// <param name="environment">The environment.</param> /// <returns>The module directory path.</returns> public static DirectoryPath GetModulePath(this ICakeConfiguration configuration, DirectoryPath defaultRoot, ICakeEnvironment environment) { var modulePath = configuration.GetValue(Constants.Paths.Modules); if (!string.IsNullOrWhiteSpace(modulePath)) { return(new DirectoryPath(modulePath).MakeAbsolute(environment)); } var toolPath = configuration.GetToolPath(defaultRoot, environment); return(toolPath.Combine("Modules").Collapse()); }
/// <summary> /// Initializes a new instance of the <see cref="DotNetToolPackageInstallerFixture"/> class. /// </summary> internal DotNetToolPackageInstallerFixture() { Environment = FakeEnvironment.CreateUnixEnvironment(); FileSystem = new FakeFileSystem(Environment); ProcessRunner = Substitute.For <IProcessRunner>(); ContentResolver = Substitute.For <IDotNetToolContentResolver>(); Log = new FakeLog(); Config = Substitute.For <ICakeConfiguration>(); Package = new PackageReference("dotnet:?package=windirstat"); PackageType = PackageType.Addin; InstallPath = new DirectoryPath("./dotnet"); }
/// <summary> /// Initializes a new instance of the <see cref="DNFPackageInstallerFixture"/> class. /// </summary> internal DNFPackageInstallerFixture() { Environment = FakeEnvironment.CreateUnixEnvironment(); FileSystem = new FakeFileSystem(Environment); ProcessRunner = Substitute.For <IProcessRunner>(); ContentResolver = Substitute.For <IDNFContentResolver>(); Log = new FakeLog(); Config = Substitute.For <ICakeConfiguration>(); Package = new PackageReference("dnf:?package=glx-utils"); PackageType = PackageType.Addin; InstallPath = new DirectoryPath("./fake-path"); }