private static void RewriteWebConfig(AutoRemovableDirectory tempFiles, ConfigReplacements replacements) { var webConfig = tempFiles.ReadFile("Web.config"); var configRewriter = new ConfigRewriter(new ConfigSources(new Dictionary <string, string>())); var rewrittenWebConfig = configRewriter.Rewrite(webConfig, replacements); tempFiles.WriteFile("Web.config", rewrittenWebConfig); }
private static void CopyFilesFromDir(AutoRemovableDirectory tempFiles, Uri rootUri, DirectoryInfo dir) { tempFiles.AddDirectory(ToRelativePath(rootUri, Commons.EnsureTrailingSlash(dir.FullName))); foreach (var file in dir.GetFiles()) { var fileUri = new Uri(file.FullName); var relativeFileUri = rootUri.MakeRelativeUri(fileUri); var relativePath = Uri.UnescapeDataString(relativeFileUri.ToString()); tempFiles.AddFile(relativePath, file.FullName); } }
public IStartedServerApp Start(ServerAppConfiguration appConfig) { var tempFiles = new AutoRemovableDirectory(); var root = new DirectoryInfo(sourcePath); var rootUri = new Uri(Commons.EnsureTrailingSlash(sourcePath)); CopyFilesFromDir(tempFiles, rootUri, root); foreach (var dir in root.GetDirectories("*.*", SearchOption.AllDirectories)) { CopyFilesFromDir(tempFiles, rootUri, dir); } RewriteWebConfig(tempFiles, replacements); return(new DeployedServerApp(tempFiles)); }
public DeployedServerApp(AutoRemovableDirectory dir) { this.directory = dir; this.PhysicalPath = dir.BasePath; }