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

UP FOR GRABS - No support for directories, limits usefulness in bundles #11

Closed cherrydev closed 7 years ago

cherrydev commented 9 years ago

Because the Vpp doesn't implement GetDirectory or DirectoryExists, the Bundle.IncludeDirectory method doesn't work at all, which unfortunately makes it rather limiting. I'm going to try to implement it, if that's alright with you.

mcintyre321 commented 9 years ago

Excellent, that sounds very useful. On 19 Nov 2014 02:21, "cherrydev" notifications@github.com wrote:

Because the Vpp doesn't implement GetDirectory or DirectoryExists, the Bundle.IncludeDirectory method doesn't work at all, which unfortunately makes it rather limiting. I'm going to try to implement it, if that's alright with you.

— Reply to this email directly or view it on GitHub https://github.com/mcintyre321/EmbeddedResourceVirtualPathProvider/issues/11 .

ulrichb commented 8 years ago

Yes, would also need this feature. Without, I cannot use "*"-Includes when using System.Web.Optimization bundles.

MatejSpin commented 7 years ago

I will implement this in following days.

thorgeir commented 7 years ago

I've made a pull request #32 that should fulfill this issue. But it comes with one big caveat, it only works for files that have exactly one period (filename.ext)

mcintyre321 commented 7 years ago

Awesome work @thorgeir . I'll need a bit of time to review this.

WRT the caveat - would it be possible to change is so files which contain multiple periods can be found at multuiple paths? e.g.

\foo\bar.baz.js, which would become a resource foo.bar.baz.js would be available at all combinations of virtual paths from /foo.bar.baz.js, /foo/bar.baz.js, /foo.bar/baz.js, /foo/bar/baz.js, if you see what I mean?

I haven't really though this through yet, so there may be a very good reason why this won't work.

If not though, it might be better if you could make this change, as it will stop people who aren't aware of the caveat from raising issues.

thorgeir commented 7 years ago

We could generate every possible combination. but the main usage for this would be with bundles and if you know about this limitation you should be able to adjust your filenames to fit the pattern. Right? :)

thorgeir commented 7 years ago

Also, if we make files accessible through all combinations, including ~/foo/*.js in a bundle would include all .js files in all sub-directories.

mcintyre321 commented 7 years ago

So a big problem is it's pretty common for something to be called \js\jquery-1.5.1.min.js, - could some client of (configurable?) heuristic be used, that works with version numbers and .min?

Also, would my suggestion result in multiple identical files being returned? I'm not that familiar with the ins and outs of bundling.

thorgeir commented 7 years ago

Some thing like this?

^(?<assembly>Assembly.Name)(\.(?<directory>.*?))?\.(?<filename>[^.]*([\.-](?<version>[0-9]\.[0-9]\.[0-9])(\.min)?)?\.[^.]*)$ Fiddle

mcintyre321 commented 7 years ago

Very nice! Do you need the assembly name bit?

mcintyre321 commented 7 years ago

Also, might be worth treating .less.css, .ts.js specially too... although that can be done later, .min is by far the most common case

thorgeir commented 7 years ago

The initial resource name includes the assembly name, but it could be remove that before running the regex. Also we could also make this configurable like the CacheControl bit.

thorgeir commented 7 years ago

Ok, i've pushed these changes to the pull request. Review this and let me know what you think.