You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Change line 3 in ExtCore-Sample\src\WebApplication.ExtensionA\project.json from "buildOptions": { "embed": [ "Styles/**", "Views/**" ],
To: "buildOptions": { "embed": [ "Styles/**", "Views/**" ], "outputName": "Something.ExtensionA"},
Remove WebApplication.ExtensionA.dll from the Extensions folder of WebApplication
Move Something.ExtensionA.dll from the output folder of the WebApplication.ExtensionA project into the Extensions folder in WebApplication
You should receive an error like this:
InvalidOperationException: The view 'Index' was not found. The following locations were searched:
/Views/ExtensionA/Index.cshtml
/Views/Shared/Index.cshtml
Maybe a.GetName().Name returns 'WebApplication.ExtensionA' so resources will have default namespace 'WebApplication.ExtensionA', not 'Something.ExtensionA', but I'm not sure so far.
I have explored this issue and found that when you set outputName to any value your embedded resources still have original names (prefix = project name). So in this case line https://github.com/ExtCore/ExtCore/blob/master/src/ExtCore.Mvc/MvcExtension.cs#L122 will set wrong base namespace so resources will not be discovered. To fix that we need to be able to get original namespace from the assembly. I don't know how to do that so far.
Ideally grabbing it from the Assembly would be ideal. However, I can't find anything that would work.
It might be possible to load the correct namespace by getting access to the extension's Startup class and calling this.GetType().GetTypeInfo(). It has properties for Assembly and Namespace which would work for this scenario - I'll investigate a little later on.
As far as I can tell the EmbeddedFileProvider works by taking a path like '/Views/Home/Index.cshtml' and transforming it to 'Views.Home.Index.cshtml', and then prepending the baseNamespace to form the full resource name, like 'WebApplication.ExtensionA' .
It's possible that we could write our own provider that simply queries the GetManifestResourceNames() inside the assembly for the correct resource. The only problem is that there would be a conflict between extensions that contain the same view in the same location - but this problem must already exist with the current setup too?
Yes, there will be a conflict if we have the same view with the same location in the different extensions. And I think it is normal, because the point is that you can specify the views for the extensions inside your main web application of inside the different extensions... It is the way it should work as I think. So your solution may work.
Activity
DmitrySikorsky commentedon Aug 5, 2016
Hm, I think it might be related to something like https://github.com/ExtCore/ExtCore/blob/master/src/ExtCore.Mvc/MvcExtension.cs#L122
Maybe a.GetName().Name returns 'WebApplication.ExtensionA' so resources will have default namespace 'WebApplication.ExtensionA', not 'Something.ExtensionA', but I'm not sure so far.
DmitrySikorsky commentedon Sep 4, 2016
I have explored this issue and found that when you set outputName to any value your embedded resources still have original names (prefix = project name). So in this case line https://github.com/ExtCore/ExtCore/blob/master/src/ExtCore.Mvc/MvcExtension.cs#L122 will set wrong base namespace so resources will not be discovered. To fix that we need to be able to get original namespace from the assembly. I don't know how to do that so far.
mwgriffiths88 commentedon Oct 26, 2016
Ideally grabbing it from the Assembly would be ideal. However, I can't find anything that would work.
It might be possible to load the correct namespace by getting access to the extension's
Startupclass and callingthis.GetType().GetTypeInfo(). It has properties forAssemblyandNamespacewhich would work for this scenario - I'll investigate a little later on.DmitrySikorsky commentedon Oct 26, 2016
Problem is that assembly may have only resources, without any classes. So still don't know how to fix. Maybe we should ask on asp.net core project.
mwgriffiths88 commentedon Oct 27, 2016
As far as I can tell the EmbeddedFileProvider works by taking a path like '/Views/Home/Index.cshtml' and transforming it to 'Views.Home.Index.cshtml', and then prepending the
baseNamespaceto form the full resource name, like 'WebApplication.ExtensionA' .It's possible that we could write our own provider that simply queries the
GetManifestResourceNames()inside the assembly for the correct resource. The only problem is that there would be a conflict between extensions that contain the same view in the same location - but this problem must already exist with the current setup too?DmitrySikorsky commentedon Oct 27, 2016
Yes, there will be a conflict if we have the same view with the same location in the different extensions. And I think it is normal, because the point is that you can specify the views for the extensions inside your main web application of inside the different extensions... It is the way it should work as I think. So your solution may work.
bdparrish commentedon Feb 23, 2017
Should this issue be closed?
mwgriffiths88 commentedon Feb 23, 2017
The issue still exists, the submitted solution was a workaround and nothing more. I'm happy for the issue to be closed.
DmitrySikorsky commentedon Feb 23, 2017
Agree with @mwgriffiths88. I will be happy to know how to fix the issue (not workaround).