WebOptimizer
WebOptimizer copied to clipboard
FileNotFoundException: No files found matching exist in an asset
Hello,
I can't understand the exception bellow when WebOptimizer's tag helper try to access any bundle after a deployment on an Azure App Service. Locally everything works as expected.
Exception details :
System.IO.FileNotFoundException: No files found matching exist in an asset
at WebOptimizer.Asset.ExpandGlobs(IAsset asset, IWebHostEnvironment env)
at WebOptimizer.Asset.GenerateCacheKey(HttpContext context)
at WebOptimizer.Taghelpers.BaseTagHelper.GenerateHash(IAsset asset)
at WebOptimizer.Taghelpers.LinkTagHelper.Process(TagHelperContext context, TagHelperOutput output)
at Microsoft.AspNetCore.Razor.TagHelpers.TagHelper.ProcessAsync(TagHelperContext context, TagHelperOutput output)
at Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperRunner.RunAsync(TagHelperExecutionContext executionContext)
at AspNetCore.Views_Shared__Layout.<>c__DisplayClass15_0.<<ExecuteAsync>b__0>d.MoveNext() in C:\Users\quent\Source\Repos\hitmanstat.us.v2\hitmanstat.us\Views\Shared\_Layout.cshtml:line 29
--- End of stack trace from previous location ---
at Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperExecutionContext.SetOutputContentAsync()
at AspNetCore.Views_Shared__Layout.ExecuteAsync() in C:\Users\quent\Source\Repos\hitmanstat.us.v2\hitmanstat.us\Views\Shared\_Layout.cshtml:line 2
at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderPageCoreAsync(IRazorPage page, ViewContext context)
at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderPageAsync(IRazorPage page, ViewContext context, Boolean invokeViewStarts)
at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderLayoutAsync(ViewContext context, ViewBufferTextWriter bodyWriter)
at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderAsync(ViewContext context)
at Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.ExecuteAsync(ViewContext viewContext, String contentType, Nullable`1 statusCode)
at Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.ExecuteAsync(ViewContext viewContext, String contentType, Nullable`1 statusCode)
at Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.ExecuteAsync(ActionContext actionContext, IView view, ViewDataDictionary viewData, ITempDataDictionary tempData, String contentType, Nullable`1 statusCode)
at Microsoft.AspNetCore.Mvc.ViewFeatures.ViewResultExecutor.ExecuteAsync(ActionContext context, ViewResult result)
at Microsoft.AspNetCore.Mvc.ViewResult.ExecuteResultAsync(ActionContext context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeResultAsync>g__Logged|21_0(ResourceInvoker invoker, IActionResult result)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResultFilterAsync>g__Awaited|29_0[TFilter,TFilterAsync](ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResultExecutedContextSealed context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.ResultNext[TFilter,TFilterAsync](State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeResultFilters()
--- End of stack trace from previous location ---
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|24_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeFilterPipelineAsync()
--- End of stack trace from previous location ---
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)
at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
at Microsoft.AspNetCore.Diagnostics.StatusCodePagesMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.ResponseCaching.ResponseCachingMiddleware.Invoke(HttpContext httpContext)
at hitmanstat.us.Startup.<>c.<<Configure>b__5_0>d.MoveNext() in C:\Users\quent\Source\Repos\hitmanstat.us.v2\hitmanstat.us\Startup.cs:line 166
--- End of stack trace from previous location ---
at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.<Invoke>g__Awaited|6_0(ExceptionHandlerMiddleware middleware, HttpContext context, Task task)
at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.HandleException(HttpContext context, ExceptionDispatchInfo edi)
at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.<Invoke>g__Awaited|6_0(ExceptionHandlerMiddleware middleware, HttpContext context, Task task)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
Line (_Layout.cshtml:35) :
<link rel="stylesheet" href="/css/bundle.css" />
Pipeline :
// Bundling and minification
services.AddWebOptimizer(pipeline =>
{
/*
* Stylesheets
*/
// All pages
pipeline.AddCssBundle("/css/bundle.css",
"Lib/external/twitter-bootstrap/css/bootstrap.min.css",
"Lib/external/toastr.js/toastr.min.css",
"Lib/external/mapbox-gl/mapbox-gl.min.css",
"Lib/local/css/site.css")
.UseContentRoot();
/*
* Javascript
*/
// Index page
pipeline.AddJavaScriptBundle("/js/index.bundle.js",
"Lib/external/jquery/jquery.min.js",
"Lib/external/twitter-bootstrap/js/bootstrap.bundle.min.js",
"Lib/external/mithril/mithril.min.js",
"Lib/external/moment.js/moment.min.js",
"Lib/external/toastr.js/toastr.min.js",
"Lib/external/apexcharts/apexcharts.min.js",
"Lib/local/js/site.js",
"Lib/local/js/mithril/models/*.js",
"Lib/local/js/mithril/views/index/*.js")
.UseContentRoot();
// World map page
pipeline.AddJavaScriptBundle("/js/map.bundle.js",
"Lib/external/jquery/jquery.min.js",
"Lib/external/twitter-bootstrap/js/bootstrap.bundle.min.js",
"Lib/external/mithril/mithril.min.js",
"Lib/local/js/site.js",
"Lib/local/js/mithril/views/map/*.js")
.UseContentRoot();
// All other pages
pipeline.AddJavaScriptBundle("/js/catchall.bundle.js",
"Lib/external/jquery/jquery.min.js",
"Lib/external/moment.js/moment.min.js",
"Lib/external/twitter-bootstrap/js/bootstrap.bundle.min.js",
"Lib/local/js/site.js",
"Lib/local/js/mithril/views/events/*.js")
.UseContentRoot();
});
https://github.com/hardware/hitmanstat.us.v2/blob/assets/hitmanstat.us/Startup.cs
There must be something that prevents the taghelper from finding the right file after deployment but I can't figure out what. If I comment the <link rel="stylesheet" href="/css/bundle.css" />
, an exception on the JS files is raised as well, if I remove @addTagHelper *, WebOptimizer.Core
in _ViewImports.cshtml, I got no exception but obviously the web browser can't find any CSS/JS asset.
Does anyone have an idea?
LigerShark.WebOptimizer.Core 3.0.319 ASP.NET Core 5.0.11
App URL : https://hitmanstatus-pprod.azurewebsites.net/ App source code : https://github.com/hardware/hitmanstat.us.v2/tree/assets
@hardware I have the Same Issue. Have you found a solution?
For me it seemed that one of the target files had a typo, be mindful of the naming conventions specified in the readme and make sure the file names don't have any typos.
May this be the same error as mine? I am getting it locally (no docker or anything, just Visual Studio, .Net 5.0 and LigerShark.WebOptimizer.Core 3.0.335 + LigerShark.WebOptimizer.Sass 3.0.58-beta, no incompatibility error on install or build):
pipeline.AddScssBundle(
GetScssSettings(), // nothing relevant
"/css/bootstrap.css",
"/_wwwroot/bootstrap/scss/bootstrap.scss").UseContentRoot();
Bootstrap SCSS files are really in project-folder/_wwwroot/bootstrap/scss/bootstrap.scss
. Notice the _
, it is on a folder name named differently than wwwroot.
Then I include it as:
<link type="text/css" rel="stylesheet" href="css/bootstrap.css" />
But I get a similar exception stack (most significant parts for brevity)
An unhandled exception occurred while processing the request.
FileNotFoundException: No files found matching exist in an asset
WebOptimizer.Asset.ExpandGlobs(IAsset asset, IWebHostEnvironment env)
WebOptimizer.Taghelpers.LinkTagHelper.WriteIndividualTags(TagHelperOutput output, IAsset asset)
WebOptimizer.Taghelpers.LinkTagHelper.Process(TagHelperContext context, TagHelperOutput output)
Microsoft.AspNetCore.Razor.TagHelpers.TagHelper.ProcessAsync(TagHelperContext context, TagHelperOutput output)
Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperRunner.RunAsync(TagHelperExecutionContext executionContext)
ElegiaWebsite.App.Pages.Shared.App_Pages_Shared__Layout.<ExecuteAsync>b__17_0() in _Layout.cshtml
...
Am I missing something? I can't find any typo for now. As an extra test, I did set every cache to false, but no luck.
@ezaca My recommendation would be to only include one library at time and test, for me it one of them had a typo and i found it when including library files iteratively.
I got this issue after updating LigerShark.WebOptimizer.Sass to 3.0.82-beta. I think it must also occur when it can't find a bundle file because after a bit of trial and error I found if I changed pipeline.AddScssBundle("css/site.css", ...
to pipeline.AddScssBundle("/css/site.css", ...
then it would work again.