NetPack.Build

NetPack.Build wires netpack into MSBuild: on dotnet build (or publish) it bundles your web entry point straight into wwwroot. It’s ideal for ASP.NET Core apps. See Using netpack from .NET for how it compares to the CLI and to the NetPack.Core library.

It’s built on NetPack.Core and ships a pure-managed, cross-platform image processor (ImageSharp) — no SkiaSharp, no native/OS dependency. Everything the task needs is bundled, so it adds no package references to your project.

Install and enable

dotnet add package NetPack.Build

Point it at an entry file and build:

<PropertyGroup>
  <NetpackEntry>ClientApp/src/index.html</NetpackEntry>
</PropertyGroup>
dotnet build
# -> wwwroot/index.html, wwwroot/index.js, wwwroot/styles.css, …

Bundling runs after Build whenever NetpackEntry is set; it’s a no-op otherwise, so the package is safe to reference from projects that don’t use it.

Options

All options are MSBuild properties with sensible defaults:

PropertyDefaultPurpose
NetpackEntryentry file (enables the integration when set)
NetpackOutputDirectory$(MSBuildProjectDirectory)/wwwrootoutput folder
NetpackMinifytrueminify + tree-shake
NetpackSourceMapsfalseemit source maps
NetpackFormatesmesm / cjs / umd / systemjs
NetpackPlatformwebweb / node / deno
NetpackEntryNames[name]naming template, e.g. [name]-[hash]
NetpackPublicPathbase URL/path for emitted-file references

Relative paths (NetpackEntry, NetpackOutputDirectory) are resolved against the project directory.

Externals

Keep dependencies out of the bundle with an item group:

<ItemGroup>
  <NetpackExternal Include="react" />
  <NetpackExternal Include="react-dom" />
</ItemGroup>

Image processing

Image resizing and re-encoding use ImageSharp — pure-managed and cross-platform, with no native/OS dependency. Formats it doesn’t cover (.avif, .ico) are copied as-is. If you need those, use the NetPack.Core library and register your own IAssetProcessor.

Build with the .NET SDK

The task targets .NET 8, so build via dotnet build / dotnet msbuild (the SDK’s .NET-based MSBuild). Node.js is only needed for the optional Sass/Less/PostCSS/Svelte features; plain JS/TS/JSX/CSS/HTML bundling needs nothing extra.