What I am trying to do:
Use MainLayout on my webapp to make use of the RCL's razor component to pass in a navmenu and use the shared libraries styling etc.
I have a RCL that contains 2 razor components 'NavMenu.razor' and 'SharedLayout.razor'.
So any new team can bring in the nuget package and work with the default mainlayout styling component we determine. (later to add in a shared IdentityService).
TLDR : I need some help with working with a RCL as a Nuget Package. Using the Styling in the RCL to provide a consistent look for all my webapps. I can't figure out how to bring in as a nuget and actually get it to work as expected. Been researching a fair bit and have hit a wall.
Hopefully I am just doing something dumb and can be pointed in the right direction. I've never made NuGet packages before let alone for RCL.
What Works - as Project Ref
When I reference the project in a solution (not use NuGet) it works
This is what my project looks like when referenced :
The code works in this setup, just to share quickly what's going on with it for context:
This looks like this when loaded:
What I am Stuck on - as NuGet
However for the next step I wanted to create a NuGet to share the RCL across projects.So I setup the RCL project file like this:
The Example Server project I marked as false.
From within the command terminal for the RCL project I then build the NuGet
Then push to a local feed nuget location.
I can then reference this nuget source from another project:
Solution Structure with Nuget:
It placed the NuGets razor files in the solution.
Problems:
Log File - Proj Reload (resolved? via clean)Right away I was having issues with Visual Studio telling me that there was an unexpected problem loading of my project.
By mucking around with _import and fully declaring components I can get this error to clear.Deleting .vs bin obj...
The log file talks about an issue with Base path:I can provide the full log if anyone thinks it'll help.
Multiple Components Named the same.
When I brought in the nuget I received a multiple components using same tag error for both the SharedLayout and the NavMenu from the RCL NuGet.
I added in a @ using statement to the _Import.razor of the NuGet to reference the components. Which wasn't needed when using the proj ref as they were in the same namespace.
I also explicitly referenced the NavMenu component in the SharedLayout.razor file.
In the MainLayout of the actual webapp I fully referenced the SharedLayout... all these seemed to clear up this error.
I'd rather find a different way to handle this error. As there is only 1 component of that name, so the error's a bit strange, like it's duplicating components into namespace.
No Errors but failure
A mix of me referencing components in the RCL before producing as a nuget allowed it to build with no errors. But It's obviously failed to load correctly. Is this still something I've gotten wrong with working with a RCL NuGet or is this some incompatibility to send @ body to a Nuget?
I was expecting to be able to bring in a NuGet package that contained a Razor Component, and pass in parameters and values into the components. Including the body render fragment.
To use the NuGets Styling sheet (not included in this example as failure occurred before this attempt). To allow for a consistent look across any app that uses the sharedlayout component.
Allowing dynamic Nav by passing in the items to display.(as shown in the MainLayout.razor file and working as shown in proj example picture).
To work as it did when referencing a project.