Visual Studio Mac: manage user secrets
Somewhat surprisingly and inconveniently, Visual Studio for Mac does not have the handy command Manage User Secrets
. It’s not hidden in a different menu, it’s simply not there.
If you need to add a single secret to your project, you can use a one-liner in the project folder:
cd repo/project
dotnet user-secrets set "ConnectionStrings:Project" "Server=127.0.0.1"
To add a number of secrets, save your secrets in a temporary .json
file:
{
"ConnectionStrings": {
"Project": "Server=127.0.0.1"
}
}
Then navigate to the project folder in a terminal and use dotnet
to import the file:
cd repo/project
cat /tmp/secrets.json | dotnet user-secrets set
The secrets are stored in ~/.microsoft/usersecrets
under the appropriate hash.
To see the currently stored secrets, use dotnet user-secrets list
. For more examples, see the app secrets docs page.