Quantcast
Channel: Active questions tagged nuget-package - Stack Overflow
Viewing all articles
Browse latest Browse all 3067

Need some help - Blazor Web App (.net 8 server) - Razor Component Library RCL as NuGet (Local Feed) w MainLayout style sharing

$
0
0

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 :Working Project Reference to RCL

The code works in this setup, just to share quickly what's going on with it for context:Routes file references this MainLayout.razor as the default layout

This looks like this when loaded:Working with proj ref

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:

proj file for the RCL

The Example Server project I marked as false.

From within the command terminal for the RCL project I then build the NuGet

building the nuget

Then push to a local feed nuget location.push to local feed

I can then reference this nuget source from another project:Nuget local feed with package

Solution Structure with Nuget:

What my solution looks like after bringing in the 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.

On bringing in the NuGet

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.

log for project load failure

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.webapp mainlayout componentref

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.

_import razor of RCL using statement

I also explicitly referenced the NavMenu component in the SharedLayout.razor file.

shared layout in RCL explicit ref but failure?

In the MainLayout of the actual webapp I fully referenced the SharedLayout... all these seemed to clear up this error.

mainlayout on WebApp explicit

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?

failure on run with no errors

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.


Viewing all articles
Browse latest Browse all 3067

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>