Register resources from nuget packages in custom module #764
Replies: 5 comments 41 replies
-
@PoisnFang Yes I download the nuget package and manually extract the assets into my module. |
Beta Was this translation helpful? Give feedback.
-
@PoisnFang Here is what I do to "embed" the assets into my external module. I will use your nuget package as an example.
You can organize the files any way you like in the Modules folder. I put my css files in a css folder...you get the idea. Also in this class you don't have access to ModulePath, so you need to set the path somehow. Hardcoding it is not a big deal because I don't think you are going to be updating you project name and structure. See Shaun's guidance below. Let me know if you have any questions and the above makes sense. |
Beta Was this translation helpful? Give feedback.
-
In the majority of cases you should not need the IHostResources interface. It is only available if you need to include resources that will be used across your entire site ( ie. such as a UI component library which you are using in every module ). Typically you should access your resources using the method in the DNF.Projects example repo. I actually published a video series a while ago where I used DNF.Projects as an example - and I included instructions on adding Nuget packages and static asset references https://www.youtube.com/watch?v=JPfUZPlRRCE&list=PLYhXmd7yV0elLNLfQwZBUlM7ZSMYPTZ_f The main thing you need to keep in mind when building external modules is that you need to deploy them as well as all of their dependencies into the Oqtane framework using the specific folder conventions it requires. So you can pull Nuget packages into your module just like any other .NET application... but you need to ensure all of the contents of the Nuget package are deployed to Oqtane. An easy way to do this is to do a mock Publish from Visual Studio to a folder and locate all of the DLLs and static assets - these will need to be deployed to your Oqtane instance. |
Beta Was this translation helpful? Give feedback.
-
@sbwalker Just a thought but, shouldn't |
Beta Was this translation helpful? Give feedback.
-
@PoisnFang in #829 I added enhancements based on the conversation in this thread. It is now possible to declare Resources in your module or theme and specify a property Declaration of "Global". By setting this property, the framework will inject the resource into the _host.cshtml as a global resource. This should make it simpler for you to use components like ChartJSBlazor. @markdav-is the changes in #829 also support a new property for Location where you can specify Head or Body. Specifying a Declaration of Global and a Location of Body will instruct the framework to add the script reference to the end of the body in _host.cshtml @mikecasas note that IHostedResources is still available and supports the enhancements mentioned above. This should not be a breaking change. It will need some thorough testing. |
Beta Was this translation helpful? Give feedback.
-
I was looking through this discussion: #690 but I didn't see where you were able to pull the resources directly from the nuget package into a custom Module. It appears that they downloaded the resources directly into their custom module/theme. Is that right @mikecasas ? I am specifically trying to use ChartJs.Blazor
Edit 1:
I think one of the big problems I see here is this:
As far as I understand, Oqtane loads the resources into the
<head></head>
Edit 2:
I believe that one of the problems I am experiencing is the same as here: #727 I need to be copying the nuget .dll from the Custom Module folder to the Oqtane folder when it is packaged.
Beta Was this translation helpful? Give feedback.
All reactions