LayerZero.Tools.Web 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package LayerZero.Tools.Web --version 1.0.0
                    
NuGet\Install-Package LayerZero.Tools.Web -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="LayerZero.Tools.Web" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="LayerZero.Tools.Web" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="LayerZero.Tools.Web" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add LayerZero.Tools.Web --version 1.0.0
                    
#r "nuget: LayerZero.Tools.Web, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package LayerZero.Tools.Web@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=LayerZero.Tools.Web&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=LayerZero.Tools.Web&version=1.0.0
                    
Install as a Cake Tool

📦 Dynamic Bundle Loader for ASP.NET Core

A convention-based asset bundling system for .NET 8+ using WebOptimizer. Automatically discovers and injects CSS/JS bundles per controller and action using Razor TagHelpers.

🔍 Purpose

Eliminates manual asset management in Razor views by scanning controller/action folder structures and auto-generating optimized bundles at runtime.

🗂 Folder Convention

wwwroot/
├── js/
│   └── controller/
│       ├── Home/
│       │   ├── Common.js
│       │   ├── Layout.js
│       │   └── Index/
│       │     └── Page.js
│       └── Dashboard/
│           └── overview.js
└── css/
    └── controller/
        ├── Home/
        │   ├── index.css
        │   └── shared.css
        └── Dashboard/
            └── overview.css

Controller/Action structure drives bundle discovery.

⚙️ Installation

  1. Create and reference the library project
dotnet new classlib -n LayerZero.Tools.Web

Add the reference in your web app:

dotnet add reference ../LayerZero.Tools.Web.csproj
  1. NuGet Dependencies
<PackageReference Include="LigerShark.WebOptimizer.Core" Version="3.0.456" />
<FrameworkReference Include="Microsoft.AspNetCore.App" />

🚀 Usage

Register bundles in Program.cs

builder.Services.AddSingleton(DynamicBundleMapper.Bundles);
builder.Services.AddWebOptimizer(pipeline =>
{
    DynamicBundleMapper.Register(pipeline);
});

Middleware setup

Ensure the WebOptimizer middleware is added:

app.UseWebOptimizer();

Custom asset folder paths

If you use a custom structure:

builder.Services.AddWebOptimizer(pipeline =>
{
    DynamicBundleMapper.Register(pipeline, JsRoot: "assets/js", CssRoot: "assets/styles");
});

Make sure the paths are relative to wwwroot/. Absolute paths or incorrect base folders will result in missing bundles.

⚠️ CSS Path Warning

When using relative URLs in CSS (e.g. url('../images/icon.svg')), remember:

Bundles are served from /bundles/...

Asset references like images or fonts must resolve correctly from the bundle's URL, not the source folder.

Fix: Use root-relative paths (/images/icon.svg) or ensure your build pipeline rewrites paths.

🧠 TagHelpers

Add to _ViewImports.cshtml

@addTagHelper *, LayerZero.Tools.Web

In _Layout.cshtml

<head>
    <style-bundle-loader />
</head>
<body>
    @RenderBody()
    <script-bundle-loader />
</body>

Action-specific bundles override controller-wide ones (loaded after).

📦 Features

✅ Convention-over-configuration

✅ Minification via WebOptimizer

✅ Controller & action bundle granularity

✅ TagHelpers for clean layout injection

✅ Auto-registers bundles at startup

✅ Supports custom asset folder paths

✨ Example

Requesting /Home/Index loads:

<link rel="stylesheet" href="/bundles/home.min.css" />
<script src="/bundles/home.min.js"></script>
<script src="/bundles/home/index.min.js"></script>

🔮 Roadmap (optional additions)

Asset versioning (?v=hash)

Inline critical CSS

TagHelper preload hints

Razor directives for explicit override

👤 Author

RuneForgePrime Team – Built for clean architecture and developer clarity.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.3.0 68 7/5/2025
1.2.0 61 6/28/2025
1.1.1 100 6/22/2025
1.1.0 97 6/22/2025
1.0.1 188 6/13/2025
1.0.0 284 6/11/2025