Tips for dotnet user-secrets

  • On the Windows platform, the secrets file are saved at /Users/yourusername/%APPDATA%/Microsoft/UserSecrets/{projectid}/secrets.json;
  • On Linux/Mac platform, the secrets file are saved at ~/.microsfot/usersecrets/{projectid}/secrets.json.

Believe it or not, .NET Core console application doesn't support user secrets in its default configuration. You can use dotnet command set or list your secrets, but actually, you cannot get its value through the IConfiguration object. What's a shame!

Finally, you may want to import secrets from one project to another project. I just wrote a small single-file script to save myself. Certainly, you can also use it if you like.

The tool has been published on Github, here it is.