private bool IsExtensionBinaryFile(Path path, string extensionName, ExtensionDeploymentOptions deploymentOptions) { bool isValidExtension = IsAssemblyFile(path); if (!isValidExtension) { return(false); } bool isAssemblyInWebAppBin = _knownBinAssemblies.Contains(path.FileNameWithoutExtension, StringComparer.OrdinalIgnoreCase); if (isAssemblyInWebAppBin) { return(false); } bool isExtensionAssembly = IsOrchardExtensionFile(path); bool copyExtensionAssembly = (deploymentOptions & ExtensionDeploymentOptions.CompiledAssembly) == ExtensionDeploymentOptions.CompiledAssembly; if (isExtensionAssembly && !copyExtensionAssembly) { return(false); } return(true); }
public static Path ShallowCopy(this Path sourcePath, string pattern, Path targetPath) { sourcePath .GetFiles(pattern, false /*recursive*/) .ForEach(file => FileCopy(sourcePath, targetPath, file)); return(sourcePath); }
public static Path ShallowCopy(this Path sourcePath, Predicate <Path> predicatePath, Path targetPath) { sourcePath .GetFiles(predicatePath, false /*recursive*/) .ForEach(file => FileCopy(sourcePath, targetPath, file)); return(sourcePath); }
public static Path DeepCopy(this Path sourcePath, Path targetPath) { sourcePath .GetFiles("*", true /*recursive*/) .ForEach(file => FileCopy(sourcePath, targetPath, file)); return(sourcePath); }
public void CopyFile(string source, string destination) { StackTrace st = new StackTrace(true); Path origin = null; foreach (var sf in st.GetFrames()) { var sourceFile = sf.GetFileName(); if (String.IsNullOrEmpty(sourceFile)) { continue; } var testOrigin = Path.Get(sourceFile).Parent.Combine(source); if (testOrigin.Exists) { origin = testOrigin; break; } } if (origin == null) { throw new FileNotFoundException("File not found: " + source); } var target = _tempSite.Combine(destination); Directory.CreateDirectory(target.DirectoryName); File.Copy(origin, target); }
private static void FileCopy(Path sourcePath, Path targetPath, Path sourceFile) { var targetFile = targetPath.Combine(sourceFile.GetRelativePath(sourcePath)); targetFile.Parent.CreateDirectory(); // Trace.WriteLine(string.Format("Copying file '{0}' to '{1}'", sourceFile, targetFile)); File.Copy(sourceFile, targetFile, true /*overwrite*/); }
public static Path GetRelativePath(this Path path, Path basePath) { if (path.Equals(basePath)) return Path.Get("."); if (path.Parent.Equals(basePath)) return path.FileName; return path.Parent.GetRelativePath(basePath).Combine(path.FileName); }
private bool IsSpecFlowTestAssembly(Path path) { if (!IsAssemblyFile(path)) return false; if (IsOrchardExtensionFile(path)) return false; return true; }
public static Path GetRelativePath(this Path path, Path basePath) { if (path.Equals(basePath)) { return(Path.Get(".")); } if (path.Parent.Equals(basePath)) { return(path.FileName); } return(path.Parent.GetRelativePath(basePath).Combine(path.FileName)); }
private bool IsSpecFlowTestAssembly(Path path) { if (!IsAssemblyFile(path)) { return(false); } if (IsOrchardExtensionFile(path)) { return(false); } return(true); }
public void Init() { var builder = new ContainerBuilder(); builder.RegisterType<RubyScriptingRuntime>().As<IScriptingRuntime>(); builder.RegisterType<ScriptingManager>().As<IScriptingManager>(); _container = builder.Build(); _scriptingRuntime = _container.Resolve<IScriptingRuntime>(); _scriptingManager = _container.Resolve<IScriptingManager>(); _tempFolderName = _tempFixtureFolderName.Combine(System.IO.Path.GetRandomFileName()); try { _tempFolderName.Delete(); } catch { } _tempFolderName.CreateDirectory(); }
public void Init() { var builder = new ContainerBuilder(); builder.RegisterType <RubyScriptingRuntime>().As <IScriptingRuntime>(); builder.RegisterType <ScriptingManager>().As <IScriptingManager>(); _container = builder.Build(); _scriptingRuntime = _container.Resolve <IScriptingRuntime>(); _scriptingManager = _container.Resolve <IScriptingManager>(); _tempFolderName = _tempFixtureFolderName.Combine(System.IO.Path.GetRandomFileName()); try { _tempFolderName.Delete(); } catch { } _tempFolderName.CreateDirectory(); }
private void StartAspNetHost(string virtualDirectory) { Log("Starting up ASP.NET host"); HostName = "localhost"; PhysicalDirectory = _tempSite; VirtualDirectory = virtualDirectory; _webHostAgent = (WebHostAgent)ApplicationHost.CreateApplicationHost(typeof(WebHostAgent), VirtualDirectory, PhysicalDirectory); var shuttle = new Shuttle(); Execute(() => { shuttle.CodeGenDir = HttpRuntime.CodegenDir; }); // ASP.NET folder seems to be always nested into an empty directory _codeGenDir = shuttle.CodeGenDir; _codeGenDir = _codeGenDir.Parent; Log("ASP.NET CodeGenDir: \"{0}\"", _codeGenDir); }
public static Path DeepCopy(this Path sourcePath, Path targetPath) { sourcePath .GetFiles("*", true /*recursive*/) .ForEach(file => FileCopy(sourcePath, targetPath, file)); return sourcePath; }
public WebHost(Path orchardTemp) { _orchardTemp = orchardTemp; }
public void CreateDb() { var types = new[] { typeof(BlogRecord), typeof(BodyRecord), typeof(BlogArchiveRecord), typeof(ContentItemVersionRecord), typeof(ContentItemRecord), typeof(ContentTypeRecord) }; _tempFolderName = _tempFixtureFolderName.Combine(System.IO.Path.GetRandomFileName()); try { _tempFixtureFolderName.Delete(true); } catch {} _tempFixtureFolderName.CreateDirectory(); _sessionFactory = DataUtility.CreateSessionFactory( _tempFolderName, types); var builder = new ContainerBuilder(); _folders = new StubFolders(); var manager = (IDataServicesProviderFactory) new DataServicesProviderFactory(new[] { new Meta <CreateDataServicesProvider>( (dataFolder, connectionString) => new SqlCeDataServicesProvider(dataFolder, connectionString), new Dictionary <string, object> { { "ProviderName", "SqlCe" } }) }); builder.RegisterInstance(new ShellSettings { Name = ShellSettings.DefaultName, DataTablePrefix = "TEST", DataProvider = "SqlCe" }); builder.RegisterInstance(AppDataFolderTests.CreateAppDataFolder(_tempFixtureFolderName)).As <IAppDataFolder>(); builder.RegisterType <SessionConfigurationCache>().As <ISessionConfigurationCache>(); builder.RegisterType <SqlCeDataServicesProvider>().As <IDataServicesProvider>(); builder.RegisterInstance(manager).As <IDataServicesProviderFactory>(); builder.RegisterType <NullInterpreter>().As <IDataMigrationInterpreter>(); builder.RegisterType <SessionFactoryHolder>().As <ISessionFactoryHolder>(); builder.RegisterType <DefaultDatabaseCacheConfiguration>().As <IDatabaseCacheConfiguration>(); builder.RegisterType <CompositionStrategy>().As <ICompositionStrategy>(); builder.RegisterInstance(_folders).As <IExtensionFolders>(); builder.RegisterType <StubLoaders>().As <IExtensionLoader>(); builder.RegisterType <ExtensionManager>().As <IExtensionManager>(); builder.RegisterType <SchemaCommandGenerator>().As <ISchemaCommandGenerator>(); builder.RegisterGeneric(typeof(Repository <>)).As(typeof(IRepository <>)); builder.RegisterType <StubCacheManager>().As <ICacheManager>(); builder.RegisterType <StubParallelCacheContext>().As <IParallelCacheContext>(); builder.RegisterType <StubAsyncTokenProvider>().As <IAsyncTokenProvider>(); builder.RegisterType <StubHostEnvironment>().As <IHostEnvironment>(); _session = _sessionFactory.OpenSession(); builder.RegisterInstance(new DefaultContentManagerTests.TestSessionLocator(_session)).As <ISessionLocator>(); builder.RegisterInstance(new ShellBlueprint()); _container = builder.Build(); _generator = _container.Resolve <ISchemaCommandGenerator>(); _folders.Manifests.Add("Feature1", @" Name: Module1 Version: 0.1 CoeveryVersion: 1 Features: Feature1: Description: Feature "); }
public void CreateDb() { var types = new[] { typeof(BlogRecord), typeof(BodyRecord), typeof(BlogArchiveRecord), typeof(ContentItemVersionRecord), typeof(ContentItemRecord), typeof(ContentTypeRecord)}; _tempFolderName = _tempFixtureFolderName.Combine(System.IO.Path.GetRandomFileName()); try { _tempFixtureFolderName.Delete(true); } catch {} _tempFixtureFolderName.CreateDirectory(); _sessionFactory = DataUtility.CreateSessionFactory( _tempFolderName, types); var builder = new ContainerBuilder(); _folders = new StubFolders(); var manager = (IDataServicesProviderFactory)new DataServicesProviderFactory(new[] { new Meta<CreateDataServicesProvider>( (dataFolder, connectionString) => new SqlCeDataServicesProvider(dataFolder, connectionString), new Dictionary<string, object> {{"ProviderName", "SqlCe"}}) }); builder.RegisterInstance(new ShellSettings { Name = ShellSettings.DefaultName, DataTablePrefix = "TEST", DataProvider = "SqlCe" }); builder.RegisterInstance(AppDataFolderTests.CreateAppDataFolder(_tempFixtureFolderName)).As<IAppDataFolder>(); builder.RegisterType<SessionConfigurationCache>().As<ISessionConfigurationCache>(); builder.RegisterType<SqlCeDataServicesProvider>().As<IDataServicesProvider>(); builder.RegisterInstance(manager).As<IDataServicesProviderFactory>(); builder.RegisterType<NullInterpreter>().As<IDataMigrationInterpreter>(); builder.RegisterType<SessionFactoryHolder>().As<ISessionFactoryHolder>(); builder.RegisterType<CompositionStrategy>().As<ICompositionStrategy>(); builder.RegisterInstance(_folders).As<IExtensionFolders>(); builder.RegisterType<StubLoaders>().As<IExtensionLoader>(); builder.RegisterType<ExtensionManager>().As<IExtensionManager>(); builder.RegisterType<SchemaCommandGenerator>().As<ISchemaCommandGenerator>(); builder.RegisterGeneric(typeof(Repository<>)).As(typeof(IRepository<>)); builder.RegisterType<StubCacheManager>().As<ICacheManager>(); builder.RegisterType<StubParallelCacheContext>().As<IParallelCacheContext>(); builder.RegisterType<StubAsyncTokenProvider>().As<IAsyncTokenProvider>(); builder.RegisterType<StubHostEnvironment>().As<IHostEnvironment>(); _session = _sessionFactory.OpenSession(); builder.RegisterInstance(new DefaultContentManagerTests.TestSessionLocator(_session)).As<ISessionLocator>(); builder.RegisterInstance(new ShellBlueprint()); _container = builder.Build(); _generator = _container.Resolve<ISchemaCommandGenerator>(); _folders.Manifests.Add("Feature1", @" Name: Module1 Version: 0.1 OrchardVersion: 1 Features: Feature1: Description: Feature "); }
private bool IsOrchardExtensionFile(Path path) { return(_knownModules.Where(name => StringComparer.OrdinalIgnoreCase.Equals(name, path.FileNameWithoutExtension)).Any() || _knownThemes.Where(name => StringComparer.OrdinalIgnoreCase.Equals(name, path.FileNameWithoutExtension)).Any()); }
public void Initialize(string templateName, string virtualDirectory, DynamicCompilationOption dynamicCompilationOption) { var stopwatch = new Stopwatch(); stopwatch.Start(); var baseDir = Path.Get(AppDomain.CurrentDomain.BaseDirectory); _tempSite = _orchardTemp.Combine(System.IO.Path.GetRandomFileName()); try { _tempSite.Delete(); } catch { } // Trying the two known relative paths to the Orchard.Web directory. // The second one is for the target "spec" in orchard.proj. _orchardWebPath = baseDir; while (!_orchardWebPath.Combine("Orchard.proj").Exists&& _orchardWebPath.Parent != null) { _orchardWebPath = _orchardWebPath.Parent; } _orchardWebPath = _orchardWebPath.Combine("src").Combine("Orchard.Web"); Log("Initialization of ASP.NET host for template web site \"{0}\":", templateName); Log(" Source location: \"{0}\"", _orchardWebPath); Log(" Temporary location: \"{0}\"", _tempSite); _knownModules = _orchardWebPath.Combine("Modules").Directories.Where(d => d.Combine("module.txt").Exists).Select(d => d.FileName).ToList(); //foreach (var filename in _knownModules) // Log("Available Module: \"{0}\"", filename); _knownThemes = _orchardWebPath.Combine("Themes").Directories.Where(d => d.Combine("theme.txt").Exists).Select(d => d.FileName).ToList(); //foreach (var filename in _knownThemes) // Log("Available Theme: \"{0}\"", filename); _knownBinAssemblies = _orchardWebPath.Combine("bin").GetFiles("*.dll").Select(f => f.FileNameWithoutExtension); //foreach (var filename in _knownBinAssemblies) // Log("Assembly in ~/bin: \"{0}\"", filename); Log("Copy files from template \"{0}\"", templateName); baseDir.Combine("Hosting").Combine(templateName) .DeepCopy(_tempSite); if (dynamicCompilationOption != DynamicCompilationOption.Enabled) { var sourceConfig = baseDir.Combine("Hosting").Combine("TemplateConfigs"); var siteConfig = _tempSite.Combine("Config"); switch (dynamicCompilationOption) { case DynamicCompilationOption.Disabled: File.Copy(sourceConfig.Combine("DisableDynamicCompilation.HostComponents.config"), siteConfig.Combine("HostComponents.config")); break; case DynamicCompilationOption.Force: File.Copy(sourceConfig.Combine("ForceDynamicCompilation.HostComponents.config"), siteConfig.Combine("HostComponents.config")); break; } } Log("Copy binaries of the \"Orchard.Web\" project"); _orchardWebPath.Combine("bin") .ShallowCopy("*.dll", _tempSite.Combine("bin")) .ShallowCopy("*.pdb", _tempSite.Combine("bin")); Log("Copy SqlCe native binaries"); if (_orchardWebPath.Combine("bin").Combine("x86").IsDirectory) { _orchardWebPath.Combine("bin").Combine("x86") .DeepCopy("*.*", _tempSite.Combine("bin").Combine("x86")); } if (_orchardWebPath.Combine("bin").Combine("amd64").IsDirectory) { _orchardWebPath.Combine("bin").Combine("amd64") .DeepCopy("*.*", _tempSite.Combine("bin").Combine("amd64")); } // Copy binaries of this project, so that remote execution of lambda // can be achieved through serialization to the ASP.NET appdomain // (see Execute(Action) method) Log("Copy Orchard.Specflow test project binaries"); baseDir.ShallowCopy( path => IsSpecFlowTestAssembly(path) && !_tempSite.Combine("bin").Combine(path.FileName).Exists, _tempSite.Combine("bin")); Log("Copy Orchard recipes"); _orchardWebPath.Combine("Modules").Combine("Orchard.Setup").Combine("Recipes").DeepCopy("*.xml", _tempSite.Combine("Modules").Combine("Orchard.Setup").Combine("Recipes")); StartAspNetHost(virtualDirectory); Log("ASP.NET host initialization completed in {0} sec", stopwatch.Elapsed.TotalSeconds); }
public static Path ShallowCopy(this Path sourcePath, string pattern, Path targetPath) { sourcePath .GetFiles(pattern, false /*recursive*/) .ForEach(file => FileCopy(sourcePath, targetPath, file)); return sourcePath; }
private bool IsAssemblyFile(Path path) { return(StringComparer.OrdinalIgnoreCase.Equals(path.Extension, ".exe") || StringComparer.OrdinalIgnoreCase.Equals(path.Extension, ".dll") || StringComparer.OrdinalIgnoreCase.Equals(path.Extension, ".pdb")); }
public static Path ShallowCopy(this Path sourcePath, Predicate<Path> predicatePath, Path targetPath) { sourcePath .GetFiles(predicatePath, false /*recursive*/) .ForEach(file => FileCopy(sourcePath, targetPath, file)); return sourcePath; }
private static void FileCopy(Path sourcePath, Path targetPath, Path sourceFile) { var targetFile = targetPath.Combine(sourceFile.GetRelativePath(sourcePath)); targetFile.Parent.CreateDirectory(); File.Copy(sourceFile, targetFile, true /*overwrite*/); }