-
Notifications
You must be signed in to change notification settings - Fork 17
Using user secrets with dotnet cli requires publishing the project.json file #62
Comments
Ugh, interesting. Yeah, we don't want to project.json be there just for userSecretsId... @anurse @davidfowl any idea where we can store this for published applications? |
|
Let's look into some options in the next milestone. |
I'm currently hitting this bug. Is there any workaround ? this is a RC2 web app and running dotnet run. If i remove UserSecrets it works as expected.
|
@Bartmax You can move project.json file manually to publish folder (or write a script to to this each time you build.) |
It worked if I added project.json to the content section of project.json so it gets published. |
one issue i find moving the file is that next restore will try to restore the bin folder. first lines of dotnet restore, with and without project.json copied over.
|
@Bartmax Yeah, that's unfortunately the case. I guess you can remove it before restore in your build script, and copy over after publish. |
To be clear. Are people trying to use UserSecrets in production? |
@glennc That's not supported. The scenario here is you're testing a published app on a dev box. |
Or they're running in a staging environment and hit an error they want to debug. They enable Development to turn on the DeveloperExceptionPage, and also end up with UserSecrets being turned on. |
Yeah, I understand the issue when you want to turn on debug on the server to get some errors. It makes me think this whole setup isn't quite right. IsDevelopment has too many things hanging off it. |
@glennc I agree. Let's talk about this. Perhaps making things more granular makes sense. |
I just spent about 4 hours troubleshooting my deploy to find out that in production (Azure App Service) I can't call I believe that the _configuration = new ConfigurationBuilder()
.SetBasePath(_hostingEnvironment.ContentRootPath)
.AddUserSecrets()
.Build(); has to turn into this: var configurationBuilder = new ConfigurationBuilder()
.SetBasePath(_hostingEnvironment.ContentRootPath);
if (hostingEnvironment.IsDevelopment())
configurationBuilder.AddUserSecrets();
_configuration = configurationBuilder.Build(); A couple related issues: |
Workaround: Create the following extension method and use it instead of the built-in one:
This doesn't solve the problem of running |
Another related issue: dotnet/efcore#5726 |
If you are using the Development environment to test but do not need user secrets, you can use a workaround to test for project.json:
|
Does this error persist if you supply the UserSecretsId as a parameter to builder.AddUserSecrets("userSecretsId") extension method? EDIT: I was able to recreate this bug using a "dotnet publish" command without including the project.json in the outputs and running the application. Passing the UserSecretsId as a parameter to AddUserSecrets() method gets around this exception. This is the work around I'll be using for deployment to our dev environment. |
This issue was moved to aspnet/DotNetTools#167 |
It needs to read
userSecretsId
from the project.json. We should find a different way to publish this value.The text was updated successfully, but these errors were encountered: