Updated after finding answer for future reference of those with issue
What I was 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 : Answered on Reddit kept here for others with some edits for clarity and expediency.
The problem was that I had included a tag that explicitly caused the NuGet to generate razor files and place them into the project that added the NuGet, causing all manner of issues with naming conflicts and lack of references.
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 was 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.
** note the tag in the project calling for 'includeRazorContentInPack' this was the problem**
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. (resolved after moving tag)
Problems:
I have not edited the below problem section from when written. for fix see answer comment.
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.