Microsoft has only Microsoft.NET.Sdk.Web the "Manage User Secrets"/"Manage User Secrets" menu item in the right-click menu of the VS project. There is no such thing in the common console project using MICROSOFT.NET.SDK, so you have to do it yourself.
Ideas
Use the "External tools" of VS to implement scripts to create usersecrets files and open directories for the same functions as "Manage User Secrets" menu items
Realize
Script here
Operation
Save scripts locally, add new tools in VS "Tools-external Tools" (tools–external tools)
Then save it as the following configuration
- Title:
管理用户机密 (or own name)
- Command:
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe (path of Powershell.exe)
- Parameters: Script path (e.g.
D:\VisualStudioTools\usersecrets.ps1 )
- Initial directory:
$(ProjectDir) (VS macro, point to current project directory)
Example:
Use
After adding the tool, select the menu item under the item that requires access/create a user secret to 工具-管理用户机密 open the Secrets.json file
Using user Secrets in the. NET Core Console Application