Interface IDotnetUserSecrets
An interface that, when implemented on a build definition, enables sourcing secrets from the .NET user secrets store.
[ConfigureHostBuilder]
public interface IDotnetUserSecrets
Examples
// 1. Implement the interface in your build definition
[BuildDefinition]
partial class Build : BuildDefinition, IDotnetUserSecrets, IMyTarget;
// 2. Define a secret parameter
[SecretDefinition("my-secret", "A secret from user secrets.")]
string MySecret => GetParam(() => MySecret);
// The value for "my-secret" will now be resolved from the user secrets store.
Remarks
This interface uses source generation to automatically register the Invex.Atom.Build.Secrets.DotnetUserSecretsProvider with the dependency injection container. This allows the IParamService to resolve secrets marked with SecretDefinitionAttribute from the local user secrets store, which is ideal for development-time secrets that should not be committed to source control.
This interface is not included in BuildDefinition by default; implement it explicitly on
your build definition to enable the user secrets store. The build project also needs a
UserSecretsId.
Methods
ConfigureHostBuilderFromIDotnetUserSecrets(IHostApplicationBuilder)
Configures the host builder to register the Invex.Atom.Build.Secrets.DotnetUserSecretsProvider.
protected static void ConfigureHostBuilderFromIDotnetUserSecrets(IHostApplicationBuilder builder)
Parameters
builderIHostApplicationBuilder