static void DeploySecrets() { var attribute = Assembly.GetEntryAssembly().GetCustomAttribute <UserSecretsIdAttribute>(); if (attribute == null) { Core.Log.Debug("Failed to get UserSecretsIdAttribute"); return; } string path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), $@"Microsoft\UserSecrets\{attribute.UserSecretsId}\secrets.json"); try { using (Stream stream = new FileStream(path, FileMode.Open)) { string protectedSecrets = ProtectedConfigurationProvider.Protect(stream, Environment.GetEnvironmentVariable(Core.MelEnvKey)); File.WriteAllText(Path.Combine(BASE_DIR, "appsettings.secrets.json"), protectedSecrets); Core.Log.Debug("User-Secrets have successfully been protected"); } } catch (Exception ex) { Core.Log.Error($"An error occured while exporting protecting user secrets\n{ex}"); } }