mcintyre321 / EmbeddedResourceVirtualPathProvider

A custom VirtualPathProvider for IIS - load views and assets from Embedded Resources in referenced assemblies
http://www.adverseconditionals.com/2011/07/portable-aspnet-code-using.html
MIT License
63 stars 42 forks source link

Bundling and filenames with dots #36

Open pkmckay147 opened 7 years ago

pkmckay147 commented 7 years ago

Hi there,

I know I've read this somewhere in an article about this project - but I can't seem to find it now so I thought I would put it on here.

I am running into issues when attempting to use the VPP with bundling. In particular, with files from commonly used libraries (jQuery and Kendo).

`var assemblies = System.Web.Compilation.BuildManager.GetReferencedAssemblies() .Cast() .Where(a => a.GetName().Name.StartsWith("MyNamespace"));

        BundleTable.VirtualPathProvider = new Vpp(assemblies.ToArray());

        bundles.Add(new ScriptBundle("~/bundles/kendo").Include(
          "~/Scripts/kendo/2017.2.504/kendo.all.min.js",
          "~/Scripts/kendo/2017.2.504/kendo.aspnetmvc.min.js"));`

This is failing due to the dots in the javascript filenames. I should point out that these scripts aren't actually in my class library, but are instead in my local MVC project.

I have downloaded the source code and attempted to debug this myself, but am not really getting anywhere. I can see that if I rename the files to not have any dots, the Vpp.GetFile method is called and everything works from there. If the dots are there, this method never gets called.

Why does it not get called? Where is the code that is preventing this?

Thanks

mcintyre321 commented 7 years ago

First of all it's worth knowing that when you embed resources, you lose some path information (e.g. some characters get turned to . and -, and if you're using VS2017 csproj, the compiler has a slightly different algorithm). Use IlSpy to look at the final resource names in your assembly.

Secondly I didn't implement the bundling feature myself, it came in a PR so all I can suggest is that you download the source and add the project locally to your solution so you can debug it. Sorry!