private void GenerateScript(Stream dacpac) { _log.Info("Building script..."); _log.Verbose("DacPackage loading..."); var package = DacPackage.Load(dacpac, DacSchemaModelStorageType.Memory); var dacOptions = GetDacDeployOptions(); var targetDbName = GetTargetDatabaseName(); _log.Verbose("Transforming dacpac to create script."); var script = DacServices.GenerateCreateScript(package, targetDbName, dacOptions); using (var output = GetScriptStreamWriter()) output.Write(script); _log.Success("Schema script created. Total {0:N0}kb.", script.Length / 1024f); if (_options.CopyLooseScripts) { _log.Verbose("Attempting to copy loose files."); _log.Info("Loading loose files..."); var looseFiles = _project.GetLooseFiles().ToList(); foreach (var file in looseFiles) { string src = file.PhysicalPath; string dest = Path.Combine(_options.Output, file.Path, file.Filename); CopyLooseFile(src, dest); } _log.Success("{0} loose file(s) copied..", looseFiles.Count); } }
public IEnumerable <ProjectFile> GetBuildFiles() { XmlNodeList nodes = _doc.GetElementsByTagName("Build"); foreach (XmlNode node in nodes) { var path = NormalizePath(node.Attributes["Include"]?.Value); if (path == null) { continue; } if (!Path.GetExtension(path).Equals(".sql", StringComparison.OrdinalIgnoreCase)) { continue; } if (!Path.IsPathRooted(path)) { path = Path.Combine(Root, path); } _log.Verbose("Build: {0}", path); yield return(new ProjectFile(Path.GetFileName(path), Path.GetDirectoryName(path), Root)); } }