public async Task BuildSite(BuilderUserInfo userInfo) { var args = new BuildEventArgs(buildStatusTracker, this, userInfo); args.Tracker.AddMessage("Building website."); //Pre build tasks foreach (var task in preBuildTasks) { await task.Execute(args); } //Look for .git folder, if one exists delete files individually var gitPath = Path.GetFullPath(Path.Combine(settings.OutDir, ".git")); if (Directory.Exists(gitPath)) { //Delete all top level files and folders except the .git folder. foreach (var file in Directory.EnumerateFiles(settings.OutDir)) { IOExtensions.MultiTryFileDelete(file); } foreach (var dir in Directory.EnumerateDirectories(settings.OutDir).Where(i => !i.EndsWith(".git"))) { IOExtensions.MultiTryDirDelete(dir, true); } } else { //No .git directory erase and recreate output folder IOExtensions.MultiTryDirDelete(settings.OutDir, true); //Create output folder Directory.CreateDirectory(settings.OutDir); } var compilers = contentCompilerFactory.CreateCompilers(fileFinder, settings.OutDir, fileFinder.Project.Compilers); var query = fileFinder.EnumerateContentFiles("/", "*.html", SearchOption.AllDirectories); totalFiles = query.Count(); foreach (var file in query) { ++currentFile; foreach (var compiler in compilers) { compiler.buildPage(file); } } foreach (var compiler in compilers) { compiler.copyProjectContent(); } //Post build tasks foreach (var task in postBuildTasks) { await task.Execute(args); } //Publish tasks foreach (var task in publishTasks) { await task.Execute(args); } //PostPublish tasks foreach (var task in postPublishTasks) { await task.Execute(args); } }