-
Notifications
You must be signed in to change notification settings - Fork 10.1k
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
Blazor: Static assets not found when using server/client projects at publish. [Includes workaround] #12073
Comments
[Blazor] Preview 6 blazorhosted project publish is broken #11185 |
For completeness and to help others with this issue, I include the complete workaround on server
|
Thanks for contacting us, @Bartmax. |
I still have this issue with preview7 when running a blazor client side application in a docker container. |
@javiercn do we have a separate issue where we track the Docker specific scenario? |
@mkArtakMSFT No. We have an issue for static web assets and docker, which partially impacts blazor client-side. The reason is currently blazor client-side uses two ways of bringing assets into the project.
Publishing was broken for blazor client-side in preview6, but we fixed it in preview7. I added a tracking issue for blazor client-side specific bits #12588 The staticweb assets piece I consider them tracked by #11609 |
Describe the bug
referencing a file like
<img src="/images/test.jpg" />
will work on development but not when publishing.This means that you cannot dev and publish your project and reference the same files using the same request path, making the dev experience and publishing a pain.
To Reproduce
Steps to reproduce the behavior:
dotnet publish -o {destinationFolder}
Expected behavior
Both in development and publish the reference URL should match via the
UseClientSideBlazorFiles
middlewareScreenshots
Additional context
The problem looks like the static file provider is configured to look into a wrong?
dist
folder.Inside the dist folder there are NuGet static assets, so I think this is not wrong but we are missing some glue or consistency.
Workaround
on client project csproj, use the "newer" way to set static file path like this:
Note: PackageId is the name of your client project, something like
WebApplication1.Client
UseStaticSideBlazorFiles
middleware still fails to find the assets on this location, so you can use another staticfilesmiddleware like this:On server project:
The text was updated successfully, but these errors were encountered: