FileNotFoundException thrown in GenerateCacheKey after upgrading from WebOptimizer.Core 3.0.357 to 3.0.372 #59
Description
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.