Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

System.InvalidOperationException: Could not find 'UserSecretsIdAttribute' on assembly 'System.Private.CoreLib' #2441

Open
aggieben opened this issue Oct 2, 2019 · 4 comments

Comments

@aggieben
Copy link

commented Oct 2, 2019

Describe 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:

  1. Using this version of ASP.NET Core: 3.0.0 with SDK 3.0.100 on macOS.
  2. Run this code: see attached zip
  3. See error

gssext.zip

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]
@Pilchie

This comment has been minimized.

Copy link
Contributor

commented Oct 2, 2019

Starting with hosting like the linked bug.

@Pilchie

This comment has been minimized.

Copy link
Contributor

commented Oct 2, 2019

Also tagging @cartermp in case of something F# specific.

@Tratcher Tratcher transferred this issue from aspnet/AspNetCore Oct 2, 2019
@Tratcher Tratcher added the area-config label Oct 2, 2019
@aggieben

This comment has been minimized.

Copy link
Author

commented Oct 3, 2019

Another data point: removing the property from the .fsproj and removing my manual AssemblyInfo.fs also didn't fix the problem. It wasn't until I removed the line where I called IServiceCollection.AddUserSecrets() that the exception cleared up.

@aggieben

This comment has been minimized.

Copy link
Author

commented Oct 15, 2019

Another: this problem happens on Windows also, not just macOS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.