コード例 #1
0
        private async Task <PathCollection> DeterminePathsAsync([NotNull] SqlProject project,
                                                                [NotNull] ConfigurationModel configuration,
                                                                [CanBeNull] Version previousVersion,
                                                                bool createLatest)
        {
            var projectPath      = project.FullName;
            var projectDirectory = Path.GetDirectoryName(projectPath);

            if (projectDirectory == null)
            {
                await _logger.LogErrorAsync($"Cannot get project directory for {project.FullName}");

                return(null);
            }

            // Versions
            const string latestKeyword         = "latest";
            var          previousVersionString = previousVersion == null ? null : _versionService.FormatVersion(previousVersion, configuration);
            var          newVersionString      = createLatest ? latestKeyword : _versionService.FormatVersion(project.ProjectProperties.DacVersion, configuration);

            // Directories
            var            artifactsPath = Path.Combine(projectDirectory, configuration.ArtifactsPath);
            DirectoryPaths directories;
            {
                var latestDirectory     = Path.Combine(artifactsPath, latestKeyword);
                var newVersionDirectory = Path.Combine(artifactsPath, newVersionString);
                directories = new DirectoryPaths(projectDirectory,
                                                 latestDirectory,
                                                 newVersionDirectory);
            }

            // Source paths
            var newVersionPath           = Path.Combine(directories.NewArtifactsDirectory, $"{project.ProjectProperties.SqlTargetName}.dacpac");
            var profilePath              = DeterminePublishProfilePath(configuration, projectDirectory);
            var previousVersionDirectory = previousVersion == null ? null : Path.Combine(artifactsPath, previousVersionString);
            var previousVersionPath      = previousVersion == null ? null : Path.Combine(previousVersionDirectory, $"{project.ProjectProperties.SqlTargetName}.dacpac");
            var sources = new DeploySourcePaths(newVersionPath,
                                                profilePath,
                                                previousVersionPath);

            // Target paths
            var deployScriptPath = previousVersion == null
                                       ? null
                                       : Path.Combine(directories.NewArtifactsDirectory, $"{project.ProjectProperties.SqlTargetName}_{previousVersionString}_{newVersionString}.sql");
            var deployReportPath = previousVersion != null && // Can only create report when comparing against a previous version
                                   configuration.CreateDocumentationWithScriptCreation
                                       ? Path.Combine(directories.NewArtifactsDirectory, $"{project.ProjectProperties.SqlTargetName}_{previousVersionString}_{newVersionString}.xml")
                                       : null;
            var targets = new DeployTargetPaths(deployScriptPath, deployReportPath);

            return(new PathCollection(directories,
                                      sources,
                                      targets));
        }
コード例 #2
0
        Task IWorkUnit <ScaffoldingStateModel> .Work(ScaffoldingStateModel stateModel,
                                                     CancellationToken cancellationToken)
        {
            if (stateModel == null)
            {
                throw new ArgumentNullException(nameof(stateModel));
            }

            stateModel.FormattedTargetVersion = Version.Parse(_versionService.FormatVersion(stateModel.TargetVersion, stateModel.Configuration));
            stateModel.CurrentState           = StateModelState.FormattedTargetVersionLoaded;
            return(Task.CompletedTask);
        }