This project is read-only.
1

Closed

Combinator does not support site applications

description

I have created application o in test.dev site.

Image

And I'm getting "Error when combining Style files" in logs:

2014-10-07 22:29:50,284 [11] Piedone.Combinator.CombinedResourceManager - Default - Error when combining Style files
http://test.dev/o
System.ArgumentNullException: Value cannot be null.
Parameter name: virtualPath
at System.Web.VirtualPath.Create(String virtualPath, VirtualPathOptions options)
at System.Web.VirtualPathUtility.ToAbsolute(String virtualPath, String applicationPath)
at Piedone.Combinator.Models.CombinatorResource.get_RelativeUrl() in d:\dev\test.dev\subapp\orchard\src\Orchard.Web\Modules\Piedone.Combinator\Models\CombinatorResource.cs:line 53
at Piedone.Combinator.Models.CombinatorResource.get_AbsoluteUrl() in d:\dev\test.dev\subapp\orchard\src\Orchard.Web\Modules\Piedone.Combinator\Models\CombinatorResource.cs:line 44
at Piedone.Combinator.Services.CombinatorService.<ProcessCombinedResources>b__12(CombinatorResource resource) in d:\dev\test.dev\subapp\orchard\src\Orchard.Web\Modules\Piedone.Combinator\Services\CombinatorService.cs:line 340
at System.Linq.Lookup2.Create[TSource](IEnumerable1 source, Func2 keySelector, Func2 elementSelector, IEqualityComparer1 comparer)
at System.Linq.GroupedEnumerable
3.GetEnumerator()
at System.Linq.Enumerable.WhereSelectEnumerableIterator2.MoveNext()
at System.Linq.Enumerable.Count[TSource](IEnumerable
1 source)
at Piedone.Combinator.Services.CombinatorService.ProcessCombinedResources(IEnumerable1 combinedResources, Uri resourceBaseUri) in d:\dev\test.dev\subapp\orchard\src\Orchard.Web\Modules\Piedone.Combinator\Services\CombinatorService.cs:line 342
at Piedone.Combinator.Services.CombinatorService.CombineStylesheets(IList
1 resources, ICombinatorSettings settings) in d:\dev\test.dev\subapp\orchard\src\Orchard.Web\Modules\Piedone.Combinator\Services\CombinatorService.cs:line 60
at Piedone.Combinator.CombinedResourceManager.BuildRequiredResources(String stringResourceType) in d:\dev\test.dev\subapp\orchard\src\Orchard.Web\Modules\Piedone.Combinator\CombinedResourceManager.cs:line 107



I have debugged this problem, and I see that CombinatorResource does not contain application path segment:
Image

That reason why it cannot calculate RelativeVirtualPath by VirtualPathUtility.ToAppRelative

Image

file attachments

Closed Jul 12, 2015 at 2:29 PM by Piedone

comments

musukvl wrote Oct 7, 2014 at 7:51 PM

I have debugged this problem, and I see that CombinatorResource does not contain application path.Image

Piedone wrote Oct 7, 2014 at 10:17 PM

Thanks for the detailed bugreport.

So if I understand correctly the root of the issue is that VirtualPathUtility.ToAppRelative("/Media/Default...", "/o") returns null, right?

musukvl wrote Oct 8, 2014 at 9:23 AM

Yes.

Looks like this bug reason is my fault, I used wrong url for setUrl:
manifest.DefineStyle("ES_Style")
          .SetUrl("/Themes/MyTheme/Content/site.css");
manifest.DefineScript("ES_Script")
            .SetUrl("/Themes/MyTheme/Content/script.js");

Piedone wrote Oct 8, 2014 at 9:44 AM

So I can close this issue?

musukvl wrote Oct 8, 2014 at 12:34 PM

I mistaken in define script path, but Combinator failed because of wrong cache file path. As you see there is some unobvious relation between cache path and resource path.
I think, it needs more convenient error message.

Piedone wrote Oct 8, 2014 at 2:47 PM

I'm got lost. So why did you changing the files in the manifest fix the issue? And what did you change them from?

musukvl wrote Oct 8, 2014 at 2:49 PM

.SetUrl("/Themes/MyTheme/Content/script.js") - is wrong, it needs to be

.SetUrl("/o/Themes/MyTheme/Content/script.js") for /o/ application.

Changing manifest fixes issue.

musukvl wrote Oct 8, 2014 at 3:14 PM

Try to install this theme, add Orchard to subapplication, like it shown on my first screenshot.
So you will see exceptions in errorlog.

But if you change this:
manifest.DefineScript("ES_Script").SetUrl("/Themes/MyTheme/Content/myscript.js");
manifest.DefineStyle("ES_Style").SetUrl("/Themes/MyTheme/Content/mystyle.css");

to following:

manifest.DefineScript("ES_Script").SetUrl("/o/Themes/MyTheme/Content/myscript.js");
manifest.DefineStyle("ES_Style").SetUrl("/o/Themes/MyTheme/Content/mystyle.css");

everything will be ok.

musukvl wrote Oct 8, 2014 at 3:14 PM

check MyTheme.zip

musukvl wrote Oct 8, 2014 at 3:37 PM

Also, I see here another issue:

See my site:
Image
I want to use http://test.dev/css/style.css in Orchard Theme with relations, but Orchard located in /o/ subapplication.
As I understand SetUrl just sets url to Style definition, so if I'm setting manifest.DefineStyle("ES_Style").SetUrl("/css/style.css");
I'm expecting <link href="/css/style.css" rel="stylesheet" type="text/css" /> should be inserted to HTML.
And so it works in Orchard. But when I'm enabling Combinator it fails.
In my point of view, Combinator should be transparent maximum as it is possible. Or it will be nice to get the exception like: "Style /css/style.css content is inaccessible, please add it to ignore list".

However, /css/style.css serverpath can be reached by
HttpContext.Server.MapPath("/css/style.css");

Piedone wrote Oct 8, 2014 at 4:22 PM

Start your paths with the tilde instead, i.e. manifest.DefineScript("ES_Script").SetUrl("~/Themes/MyTheme/Content/myscript.js"); The tilde will make it include the app path.

The strange symptom is that the cached file's path doesn't start with /o and that's because the app path isn't set to /o. Combinator can't do anything about that. This is the root cause of your problems.

Running Orchard from a sub-app is kind of hackish and I'd suggest you not to try to do it.

musukvl wrote Oct 8, 2014 at 4:52 PM

Start your paths with the tilde instead, i.e.
manifest.DefineScript("ES_Script").SetUrl("~/Themes/MyTheme/Content/myscript.js");
Yes, I have done that.
But problem is in relation between cache file and resource file. Why this relation exists? Why tilda in resource files affects path to cache? In my point of view cache file should be indepenent entity.
Running Orchard as sub-app is a not a hack. It is the good way to integrate Orchard to existing application.
Also hostings, like discountasp.net hosts sites in sub-apps.

Piedone wrote Oct 8, 2014 at 9:49 PM

There is no connection between the path of the cache file and the original file. The issue here is that VirtualPathUtility.ToAppRelative("/Media/Default...", "/o") returns null. Now this is not something Combinator can deal with: the first argument is ultimately produced by Orchard (generated with virtual paths) and the second one from ASP.NET. Something is not right here in the setup if this is not working as intended.