private bool TryGetArtifactsBaseDirectory(SqlProject project, ConfigurationModel configuration, out string artifactsBaseDirectory) { var projectPath = project.FullName; var projectDirectory = Path.GetDirectoryName(projectPath); if (projectDirectory == null) { _visualStudioAccess.ShowModalError("ERROR: Cannot determine project directory."); artifactsBaseDirectory = null; return(false); } var artifactPathErrors = ConfigurationModelValidations.ValidateArtifactsPath(configuration); if (artifactPathErrors.Any()) { _visualStudioAccess.ShowModalError("ERROR: The configured artifacts path is not valid. Please ensure that the configuration is correct."); artifactsBaseDirectory = null; return(false); } artifactsBaseDirectory = Path.Combine(projectDirectory, configuration.ArtifactsPath); return(true); }
private async Task <ConfigurationModel> GetConfigurationOrDefaultInternalAsync(SqlProject project, string path) { var sourcePath = path ?? GetConfigurationPath(project); string serialized; try { if (!_fileSystemAccess.CheckIfFileExists(sourcePath)) { return(GetValidatedDefaultInstance()); } serialized = await _fileSystemAccess.ReadFileAsync(sourcePath); } catch (Exception e) { await _logger.LogErrorAsync(e, $"Failed to read the configuration from file '{sourcePath}' - please ensure you have access to the file"); _visualStudioAccess.ShowModalError("Accessing the configuration file failed. " + "Please check the SSDT Lifecycle output window for more details. " + "Falling back to default configuration."); return(GetValidatedDefaultInstance()); } var settings = new JsonSerializerSettings { ContractResolver = this }; var deserialized = JsonConvert.DeserializeObject <ConfigurationModel>(serialized, settings); deserialized.ValidateAll(); return(deserialized); }
private async Task ValidateTargetVersionInternal <TStateModel>(TStateModel stateModel, Func <TStateModel, bool> isValid, Func <TStateModel, string> getLogMessage) where TStateModel : IStateModel { // Check version if (isValid(stateModel)) { stateModel.CurrentState = StateModelState.FormattedTargetVersionValidated; return; } stateModel.Result = false; stateModel.CurrentState = StateModelState.FormattedTargetVersionValidated; await _logger.LogErrorAsync(getLogMessage(stateModel)); _visualStudioAccess.ShowModalError("Please change the DAC version in the SQL project settings (see output window)."); }