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

FileNotFoundException thrown in GenerateCacheKey after upgrading from WebOptimizer.Core 3.0.357 to 3.0.372 #59

Open
InfiniteSpirals opened this issue Oct 26, 2022 · 1 comment

Comments

@InfiniteSpirals
Copy link

InfiniteSpirals commented Oct 26, 2022

I was facing this exception yesterday, using WebOptimizer.Sass 3.0.91 with Umbraco 10.

The setup had been stable on WebOptimizer.Core 3.0.357 and WebOptimizer.Sass 3.0.84 but updating introduced this breaking change.

After some investigation, I tracked this down a commit in the WebOptimizer.Core project ligershark/WebOptimizer@5f83850

Line 265

? (env.WebRootFileProvider as CompositeFileProvider).FileProviders.Last()

Umbraco10 invisibly adds a number of FileProviders, meaning that the PhysicalFileProvider one would expect to map to wwwroot was not the one used in the Sass compilation pipeline.

Specifcally re-adding a PhysicalFileProvider in after the Umbraco middleware was required in order to get things working as expected again.

IWebHostEnvironment? webHostEnvironment = app.ApplicationServices.GetService<IWebHostEnvironment>(); if (webHostEnvironment is not null) { webHostEnvironment.WebRootFileProvider = new CompositeFileProvider( new PhysicalFileProvider(env.WebRootPath), env.WebRootFileProvider); }

I'm not sure how flexible / intuitive it is that FileProviders.Last() is the one that all assets are routed through...

I'm adding this issue in case it helps anyone facing the same problem.

@nick-hoang
Copy link

nick-hoang commented Jul 1, 2024

I'm using Umbraco 12.3.7 and getting the last FileProvider doesn't work, just leave it as a CompositeFileProvider works well for me.
Here's my code:
Line 265, function GetFileProvider:
public static IFileProvider GetFileProvider(this IAsset asset, IWebHostEnvironment env) { return asset.GetCustomFileProvider(env) ?? env.WebRootFileProvider; }

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

No branches or pull requests

2 participants