示例#1
0
        public EngineManager(Preprocessor preprocessor, ConfigOptions configOptions)
        {
            _configOptions = configOptions;
            Engine = new Engine();
            Configurator = new Configurator(Engine, preprocessor);
            
            // Set no cache if requested
            if (_configOptions.NoCache)
            {
                Engine.Settings.UseCache = false;
            }

            // Set folders
            Engine.FileSystem.RootPath = _configOptions.RootPath;
            if (_configOptions.InputPaths != null && _configOptions.InputPaths.Count > 0)
            {
                // Clear existing default paths if new ones are set
                // and reverse the inputs so the last one is first to match the semantics of multiple occurrence single options
                Engine.FileSystem.InputPaths.Clear();
                Engine.FileSystem.InputPaths.AddRange(_configOptions.InputPaths.Reverse());
            }
            if (_configOptions.OutputPath != null)
            {
                Engine.FileSystem.OutputPath = _configOptions.OutputPath;
            }
            if (_configOptions.NoClean)
            {
                Engine.Settings.CleanOutputPath = false;
            }
            if (_configOptions.GlobalMetadata != null)
            {
                foreach (KeyValuePair<string, object> item in _configOptions.GlobalMetadata)
                {
                    Engine.GlobalMetadata.Add(item);
                }
            }

            // Set NuGet settings
            Configurator.PackageInstaller.UpdatePackages = _configOptions.UpdatePackages;
            Configurator.PackageInstaller.UseLocalPackagesFolder = _configOptions.UseLocalPackages;
            Configurator.PackageInstaller.UseGlobalPackageSources = _configOptions.UseGlobalSources;
            if (_configOptions.PackagesPath != null)
            {
                Configurator.PackageInstaller.PackagesPath = _configOptions.PackagesPath;
            }

            // Metadata
            Configurator.GlobalMetadata = configOptions.GlobalMetadata;
            Configurator.InitialMetadata = configOptions.InitialMetadata;

            // Script output
            Configurator.OutputScript = _configOptions.OutputScript;

            // Application input
            Engine.ApplicationInput = _configOptions.Stdin;
        }
示例#2
0
 public static EngineManager Get(Preprocessor preprocessor, ConfigOptions configOptions)
 {
     try
     {
         return new EngineManager(preprocessor, configOptions);
     }
     catch (Exception ex)
     {
         Trace.Critical("Error while instantiating engine: {0}", ex.Message);
         return null;
     }
 }
示例#3
0
 // Used by both build and new
 protected static void ParseRootPathParameter(ArgumentSyntax syntax, ConfigOptions configOptions)
 {
     if (syntax.DefineParameter("root", ref configOptions.RootPath, DirectoryPathFromArg, "The folder (or config file) to use.").IsSpecified)
     {
         // If a root folder was defined, but it actually points to a file, set the root folder to the directory
         // and use the specified file as the config file (if a config file was already specified, it's an error)
         FilePath rootDirectoryPathAsConfigFile = new DirectoryPath(Environment.CurrentDirectory).CombineFile(configOptions.RootPath.FullPath);
         if (System.IO.File.Exists(rootDirectoryPathAsConfigFile.FullPath))
         {
             // The specified root actually points to a file...
             if (configOptions.ConfigFilePath != null)
             {
                 syntax.ReportError("A config file was both explicitly specified and specified in the root folder.");
             }
             else
             {
                 configOptions.ConfigFilePath = rootDirectoryPathAsConfigFile.FileName;
                 configOptions.RootPath       = rootDirectoryPathAsConfigFile.Directory;
             }
         }
     }
 }