ligershark / WebOptimizer

A bundler and minifier for ASP.NET Core
Apache License 2.0
757 stars 113 forks source link

Custom file provider is not applied when using globing pattern #63

Closed AlexBar closed 6 years ago

AlexBar commented 6 years ago

Steps: Add files via globing pattern in services.AddWebOptimizer and specify custom file provider via UseFileProvider/UseContentRoot:

// ...
services.AddWebOptimizer(pipeline =>
{
   //  ...
    pipeline.AddFiles("application/javascript; charset=UTF-8", "scripts/**/*.js")
                 .MinifyJavaScript()
                 .ForEach(asset => asset.UseContentRoot());
   //  ...
}

Actual result: An exception is thrown

FileNotFoundException: No files found matching "/scripts/list.js" exist in "D:\Dev\TestProject\wwwroot\"
WebOptimizer.Asset.ExpandGlobs(IAsset asset, IHostingEnvironment env)

Expected result: Processed with no errors. File should be searched in project root.

Root cause: asset.Items collection is not copied into newly created asset.

PS: it works only if script is exlicitly specified without using globbing pattern.

AlexBar commented 6 years ago

Fixed in #64

AlexBar commented 6 years ago

@madskristensen, can you update nuget package?