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

Static file, multiple locations #32891

Closed
ventureaaron opened this issue Jun 19, 2024 · 7 comments · Fixed by #33118
Closed

Static file, multiple locations #32891

ventureaaron opened this issue Jun 19, 2024 · 7 comments · Fixed by #33118

Comments

@ventureaaron
Copy link

ventureaaron commented Jun 19, 2024

[EDIT by guardrex to update the metadata]

Description

In the final blazor example for serving from multiple locations, the compiled css file seems to get lost (appname.styles.css). Debugging the webrootfileprovider seems to indicate the culprit is the Microsoft.AspNetCore.StaticWebAssets.ManifestStaticWebAssetFileProvider dropping out when we replace the webrootprovider with the compositeProvider in the example.

I worked around this with this below, but it's almost certain to not be the proper way:

var secondaryProvider = new PhysicalFileProvider(
    builder.Configuration.GetValue<String>("serverDir:HomePath")!);
var oldProvider = app.Environment.WebRootFileProvider;
var compositeProvider = new CompositeFileProvider(oldProvider, secondaryProvider);
app.Environment.WebRootFileProvider = compositeProvider;

Cheers on fantastic documentation! Really appreciating all the efforts.

Page URL

https://learn.microsoft.com/en-us/aspnet/core/blazor/fundamentals/static-files?view=aspnetcore-8.0

Content source URL

https://github.com/dotnet/AspNetCore.Docs/blob/main/aspnetcore/blazor/fundamentals/static-files.md

Document ID

25458428-030f-6acb-457e-1b4dfa722043

Article author

@guardrex

@guardrex
Copy link
Collaborator

Hello @ventureaaron ...

Please open this for the product unit at ...

https://github.com/dotnet/aspnetcore/issues

... with a few updates ...

@Rick-Anderson ... I'll relabel this issue for the Blazor article and assign to myself for work.

@ventureaaron
Copy link
Author

ventureaaron commented Jun 19, 2024 via email

@guardrex
Copy link
Collaborator

guardrex commented Jun 19, 2024

Sorry that it didn't work out the way that I expected. Our normal workflow would've been to get an answer on the product unit's repo that I could then work into the Static Files article here if it turns out to be a special case for Blazor apps. Your issue was transferred back over here. I sent an email to Artak to ask him what the plan is for this issue. I'll comment back here after he lets me know how this one is going to be handled.

@ventureaaron
Copy link
Author

ventureaaron commented Jun 19, 2024 via email

@guardrex
Copy link
Collaborator

Let's wait for Artak to respond to my email. I'll report back when I hear from him.

@guardrex
Copy link
Collaborator

There was no response to my email.

I'm going to see if I can repro this, and I'll send Artak another email to ask how he wants to proceed. His transferred issue (your PU issue) is now a duplicate here, and I don't think Javier sees the pings from this repo ... i.e., your issue has "gone into a black hole" at the moment 😆. I'll see if I can get some action going on this.

@guardrex
Copy link
Collaborator

Confirmed that this is only a problem for BWAs (Blazor Server works with the approach in the main doc set article).

Your approach ...

var secondaryProvider = new PhysicalFileProvider(
    Path.Combine(builder.Environment.ContentRootPath, "MyStaticFiles"));
app.Environment.WebRootFileProvider = new CompositeFileProvider(
    app.Environment.WebRootFileProvider, secondaryProvider);

... ✨ Just Works!™ ✨ ... and seems fine with me as a suggested alternative.

I'm going to close the transferred issue and work from this issue.

I'll take the following actions ...

  • Add a section to the Blazor Static Files article for this for 8.0 or later targeting BWA development.
  • Place a remark in the main doc set's Static Files article section with a cross-link to the new guidance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants