Zeu*_*s82 17 c# .net-core asp.net-core visual-studio-2017
使用 Visual Studio 2017,当我尝试设置用户密码时,出现以下错误:
> dotnet user-secrets set Authentication:Google:ClientId mysecretclientid
> Could not find the global property 'UserSecretsId' in MSBuild project 'c:\test\myproj.csproj'. Ensure this property is set in the project or use the '--id' command line option.
Run Code Online (Sandbox Code Playgroud)
我的 Startup.cs 中有这个:
[assembly: UserSecretsId("project-8084c8e7-0000-0000-b266-b33f42dd88c0")]
...
builder.AddUserSecrets<Startup>();
Run Code Online (Sandbox Code Playgroud)
如果我将此添加到我的 csproj:
<PropertyGroup>
<UserSecretsId>project-8084c8e7-0000-0000-b266-b33f42dd88c0</UserSecretsId>
</PropertyGroup>
Run Code Online (Sandbox Code Playgroud)
我收到一条错误消息
Duplicate 'Microsoft.Extensions.Configuration.UserSecrets.UserSecretsIdAttribute'
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?
Tea*_*erd 46
在 VS Code 2019 中,您可以使用以下命令在 csproj 文件中生成 UserSecret 部分。运行命令时,请确保您位于包含所需 csproj 文件的目录中。
dotnet user-secrets init
Run Code Online (Sandbox Code Playgroud)
我遇到了同样的错误,我通过生成一个新的 UserSecretsId 来修复它。
如果您在解决方案资源管理器中右键单击项目并按 ,将自动生成 UserSecretsId Manage User Secrets。
好的,所以我开始工作了,看起来在 VS 2017 中您应该删除“ [assembly: UserSecretsId("project-8084c8e7-0000-0000-b266-b33f42dd88c0")]”属性并在 csproj 文件中包含以下内容:
<PropertyGroup>
<UserSecretsId>project-8084c8e7-0000-0000-b266-b33f42dd88c0</UserSecretsId>
</PropertyGroup>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
11289 次 |
| 最近记录: |