System.InvalidOperationException: Could not find 'UserSecretsIdAttribute' on assembly 'System.Private.CoreLib'
See original GitHub issueDescribe the bug
This bug seems to me to be very similar to aspnet/AspNetCore#7649. I’m using F# with Giraffe to fiddle around with a simple api project, but when I start it, I get the exception shown in the title. Here’s the full backtrace:
23:55 $ dotnet run
Unhandled exception. System.InvalidOperationException: Could not find 'UserSecretsIdAttribute' on assembly 'System.Private.CoreLib'.
Check that the project for 'System.Private.CoreLib' has set the 'UserSecretsId' build property.
If the 'UserSecretsId' property is already set then add a reference to the Microsoft.Extensions.Configuration.UserSecrets package.
at Microsoft.Extensions.Configuration.UserSecretsConfigurationExtensions.AddUserSecrets(IConfigurationBuilder configuration, Assembly assembly, Boolean optional, Boolean reloadOnChange)
at Microsoft.Extensions.Configuration.UserSecretsConfigurationExtensions.AddUserSecrets[T](IConfigurationBuilder configuration)
at GinghamStreet.Shopify.IntegrationApi.App.configureServices(IServiceCollection services) in /Users/ben/proj/c9/gssext/src/GinghamStreet.Shopify.IntegrationApi/Program.fs:line 116
at GinghamStreet.Shopify.IntegrationApi.App.main@141-1.Invoke(IServiceCollection delegateArg0) in /Users/ben/proj/c9/gssext/src/GinghamStreet.Shopify.IntegrationApi/Program.fs:line 141
at Microsoft.AspNetCore.Hosting.WebHostBuilder.<>c__DisplayClass10_0.<ConfigureServices>b__0(WebHostBuilderContext _, IServiceCollection services)
at Microsoft.AspNetCore.Hosting.WebHostBuilder.BuildCommonServices(AggregateException& hostingStartupErrors)
at Microsoft.AspNetCore.Hosting.WebHostBuilder.Build()
at GinghamStreet.Shopify.IntegrationApi.App.main(String[] _arg1) in /Users/ben/proj/c9/gssext/src/GinghamStreet.Shopify.IntegrationApi/Program.fs:line 134
At first I just used the dotnet tooling to set up user secrets:
dotnet user-secrets init
, which added the UserSecretsIdAttribute
property to my .fsproj file; followed by a couple of dotnet user-secrets set "key:value"
commands. When the above error was thrown when I tried to run at this point, I tried disabling AssemblyInfo generation with GenerateUserSecretsAttribute
set to false and then writing my own AssemblyInfo.fs, but that didn’t change anything.
To Reproduce
Steps to reproduce the behavior:
- Using this version of ASP.NET Core: 3.0.0 with SDK 3.0.100 on macOS.
- Run this code: see attached zip
- See error
Expected behavior
I expected to just run the dotnet user-secrets
tools and have things work.
Additional context
01:23 $ dotnet --info
.NET Core SDK (reflecting any global.json):
Version: 3.0.100
Commit: 04339c3a26
Runtime Environment:
OS Name: Mac OS X
OS Version: 10.14
OS Platform: Darwin
RID: osx.10.14-x64
Base Path: /usr/local/share/dotnet/sdk/3.0.100/
Host (useful for support):
Version: 3.0.0
Commit: 7d57652f33
.NET Core SDKs installed:
2.2.300 [/usr/local/share/dotnet/sdk]
3.0.100 [/usr/local/share/dotnet/sdk]
.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.1.6 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.7 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.8 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.9 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.2.5 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.6 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.7 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.8 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.9 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.2.5 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.0.0-preview4-19216-03 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.0.0-preview5-19227-01 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.0.0 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.1.6 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.7 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.8 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.9 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 2.2.5 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 3.0.0-preview4-27615-11 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 3.0.0-preview5-27626-15 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 3.0.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (2 by maintainers)
Top GitHub Comments
Also tagging @cartermp in case of something F# specific.
This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. If it is closed, feel free to comment when you are able to provide the additional information and we will re-investigate.
See our Issue Management Policies for more information.