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 VerifyPathsInternal(IStateModel stateModel, PathCollection paths) { await _logger.LogInfoAsync("Verifying paths ..."); if (string.IsNullOrWhiteSpace(paths.DeploySources.PublishProfilePath)) { stateModel.Result = false; stateModel.CurrentState = StateModelState.PathsVerified; await _logger.LogErrorAsync("Failed to find publish profile. " + $"The {nameof(ConfigurationModel.PublishProfilePath)} is set to \"{ConfigurationModel.UseSinglePublishProfileSpecialKeyword}\", but there's more than one publish profile in the directory. " + $"Please read the documentation at {_logger.DocumentationBaseUrl}publish-profile-path for more details."); return; } if (_fileSystemAccess.CheckIfFileExists(paths.DeploySources.PublishProfilePath)) { stateModel.CurrentState = StateModelState.PathsVerified; return; } stateModel.Result = false; stateModel.CurrentState = StateModelState.PathsVerified; await _logger.LogErrorAsync($"Failed to find publish profile at \"{paths.DeploySources.PublishProfilePath}\". " + $"Please read the documentation at {_logger.DocumentationBaseUrl}publish-profile-path for more details."); }