skoruba / Duende.IdentityServer.Admin

The administration for the Duende IdentityServer and Asp.Net Core Identity ⚡
Apache License 2.0
576 stars 197 forks source link

Admin project styles don't work with other from Development environment variable #65

Closed Diponchik closed 1 year ago

Diponchik commented 2 years ago

Hello there. I was trying to run an admin project with my "Local" ASPNETCORE_ENVIRONMENT, but I discovered, that styles don't work on this environment and after I changed it back to development, then it started working.

Steps to reproduce: Change ASPNETCORE_ENVIRONMENT to something else ("Local" for example) and run the project. Styles should be missed.

image

JacksonHamner commented 2 years ago

We are seeing this in our project too, any idea what might be causing this?

selangley-wa commented 2 years ago

It appears to be something strange with how the staticwebassets for the Skoruba.Duende.IdentityServer.Admin.UI NuGet package are handled / processed when running in a non-development environment.

For my custom Duende.IdentityServer.Admin project generated using the template, if I:

  1. Move the directory:

{$USERPROFILE}.nuget\packages\skoruba.duende.identityserver.admin.ui\1.1.0\staticwebassets

to {$MyTemplateGeneratedProjectName}\src{$MyTemplateGeneratedProjectName}.Admin\wwwroot

  1. Remove the importing of the staticwebassests as a dependency for the Skoruba.Duende.IdentityServer.Admin.UI NuGet package, which I achieved in a "hacky" way by deleting the line:

    from the file:

    {$USERPROFILE}.nuget\packages\skoruba.duende.identityserver.admin.ui\1.1.0\build\Skoruba.Duende.IdentityServer.Admin.UI.props

  2. Finally, rebuild my custom Duende.IdentityServer.Admin project.

Then the styles for the Admin project are found successfully when running in an non-development configuration.

Perhaps the manner in which the staticwebassets are being packaged can be improved upon?

The only real documentation I found from Microsoft on this is the following blog post:

https://devblogs.microsoft.com/dotnet/build-client-web-assets-for-your-razor-class-library/

and this documentation page:

https://docs.microsoft.com/en-us/aspnet/core/razor-pages/ui-class?view=aspnetcore-6.0&tabs=visual-studio

Diponchik commented 2 years ago

Thank you @selangley-wa. Just added webBuilder.UseStaticWebAssets(); to Programs.cs file for Duende.IdentityServer.Admin project and it works!

skoruba commented 2 years ago

Thank you for your PR, I will merge, sorry for the delay, I was busy.