Watch Aspire live streamsDocsTry Aspire

JavaScriptHostingExtensions Methods

ClassMethods36 members
Fluent flag-surface extensions for DenoAppResource.
AddBunApp(IDistributedApplicationBuilder, string, string, string)Section titled AddBunApp(IDistributedApplicationBuilder, string, string, string)extensionIResourceBuilder<BunAppResource>
Adds a Bun application to the application model. Bun should be available on the PATH.
public static class JavaScriptHostingExtensions
{
public static IResourceBuilder<BunAppResource> AddBunApp(
this IDistributedApplicationBuilder builder,
string name,
string appDirectory,
string scriptPath)
{
// ...
}
}
builderIDistributedApplicationBuilderThe Hosting.IDistributedApplicationBuilder to add the resource to.
namestringThe name of the resource.
appDirectorystringThe path to the directory containing the Bun application.
scriptPathstringThe path to the script (for example, server.ts) relative to appDirectory to run.
IResourceBuilder<BunAppResource>A reference to the ApplicationModel.IResourceBuilder`1.
This method executes the script directly using bun <script>. Bun natively runs JavaScript and TypeScript files so no transpile step is required. If the application directory contains a package.json file, Bun will be added as the default package manager. When publishing to a container, the default base image is oven/bun:1 for both the build and runtime stages.

Add a Bun app to the application model:

var builder = DistributedApplication.CreateBuilder(args);
builder.AddBunApp("api", "../api", "server.ts");
builder.Build().Run();
AddDenoApp(IDistributedApplicationBuilder, string, string, string)Section titled AddDenoApp(IDistributedApplicationBuilder, string, string, string)extensionIResourceBuilder<DenoAppResource>
Adds a Deno application to the application model. Deno should be available on the PATH.
public static class JavaScriptHostingExtensions
{
public static IResourceBuilder<DenoAppResource> AddDenoApp(
this IDistributedApplicationBuilder builder,
string name,
string appDirectory,
string scriptPath)
{
// ...
}
}
builderIDistributedApplicationBuilderThe Hosting.IDistributedApplicationBuilder to add the resource to.
namestringThe name of the resource.
appDirectorystringThe path to the directory containing the Deno application.
scriptPathstringThe path to the script (for example, main.ts) relative to appDirectory to run.
IResourceBuilder<DenoAppResource>A reference to the ApplicationModel.IResourceBuilder`1.
In run mode this method executes the script directly using deno run -A <script>. Generated containers use the more restrictive deno run --allow-net --allow-env <script> default. Deno natively runs JavaScript and TypeScript files so no transpile step is required. Deno's built-in OpenTelemetry integration is enabled via the OTEL_DENO environment variable, so traces, metrics, and logs flow to the Aspire dashboard with no application-level SDK wiring. The full Deno flag surface (granular permissions, --config / --import-map / --lock, unstable features, --watch, inspector flags, script args, and the run / task / serve sub-command modes) can be configured with the fluent WithDeno* methods (for example JavaScriptHostingExtensions.WithDenoAllow, JavaScriptHostingExtensions.WithDenoConfig, JavaScriptHostingExtensions.WithDenoUnstable, JavaScriptHostingExtensions.WithDenoServe). Configuring any of these fully replaces the default arg vector, so a Deno workload never has to fall back to AddExecutable. If the application directory contains a package.json, deno.json, or deno.jsonc file, Deno will be added as the default package manager. When publishing to a container, the default base image is denoland/deno:2.9.0 for both the build and runtime stages.

Add a Deno app to the application model:

var builder = DistributedApplication.CreateBuilder(args);
builder.AddDenoApp("api", "../api", "main.ts");
builder.Build().Run();
AddJavaScriptApp(IDistributedApplicationBuilder, string, string, string)Section titled AddJavaScriptApp(IDistributedApplicationBuilder, string, string, string)extensionIResourceBuilder<JavaScriptAppResource>
Adds a JavaScript application resource to the distributed application using the specified app directory and run script.
public static class JavaScriptHostingExtensions
{
public static IResourceBuilder<JavaScriptAppResource> AddJavaScriptApp(
this IDistributedApplicationBuilder builder,
string name,
string appDirectory,
string runScriptName = "dev")
{
// ...
}
}
builderIDistributedApplicationBuilderThe distributed application builder to which the JavaScript application resource will be added.
namestringThe unique name of the JavaScript application resource. Cannot be null or empty.
appDirectorystringThe path to the directory containing the JavaScript application.
runScriptNamestringoptionalThe name of the npm script to run when starting the application. Defaults to "dev". Cannot be null or empty.
IResourceBuilder<JavaScriptAppResource>A resource builder for the newly added JavaScript application resource.
If a Dockerfile does not exist in the application's directory, one will be generated automatically when publishing. The method configures the resource with Node.js defaults and sets up npm integration.
AddNextJsApp(IDistributedApplicationBuilder, string, string, string)Section titled AddNextJsApp(IDistributedApplicationBuilder, string, string, string)extensionIResourceBuilder<NextJsAppResource>
Adds a Next.js app to the distributed application builder.
public static class JavaScriptHostingExtensions
{
public static IResourceBuilder<NextJsAppResource> AddNextJsApp(
this IDistributedApplicationBuilder builder,
string name,
string appDirectory,
string runScriptName = "dev")
{
// ...
}
}
builderIDistributedApplicationBuilderThe Hosting.IDistributedApplicationBuilder to add the resource to.
namestringThe name of the Next.js app.
appDirectorystringThe path to the directory containing the Next.js app.
runScriptNamestringoptionalThe name of the script that runs the Next.js dev server. Defaults to "dev".
IResourceBuilder<NextJsAppResource>A reference to the ApplicationModel.IResourceBuilder`1.

This method configures the Next.js application for both local development and publishing. In run mode, it starts the Next.js dev server with the correct port binding. In publish mode, it generates a multi-stage Dockerfile using Next.js standalone output mode, which copies public/, .next/standalone/, and .next/static/ into a Node.js runtime container.

The Next.js application must have output: "standalone" configured in next.config.ts and a public/ directory (even if empty) for the published container to build correctly.

The following example creates a Next.js app.
var builder = DistributedApplication.CreateBuilder(args);
builder.AddNextJsApp("frontend", "./frontend");
builder.Build().Run();
AddNodeApp(IDistributedApplicationBuilder, string, string, string)Section titled AddNodeApp(IDistributedApplicationBuilder, string, string, string)extensionIResourceBuilder<NodeAppResource>
Adds a node application to the application model. Node should be available on the PATH.
public static class JavaScriptHostingExtensions
{
public static IResourceBuilder<NodeAppResource> AddNodeApp(
this IDistributedApplicationBuilder builder,
string name,
string appDirectory,
string scriptPath)
{
// ...
}
}
builderIDistributedApplicationBuilderThe Hosting.IDistributedApplicationBuilder to add the resource to.
namestringThe name of the resource.
appDirectorystringThe path to the directory containing the node application.
scriptPathstringThe path to the script relative to the app directory to run.
IResourceBuilder<NodeAppResource>A reference to the ApplicationModel.IResourceBuilder`1.
This method executes a Node script directly using node script.js. If you want to use a package manager you can add one and configure the install and run scripts using the provided extension methods. If the application directory contains a package.json file, npm will be added as the default package manager.

Add a Node app to the application model using yarn and 'yarn run dev' for running during development:

var builder = DistributedApplication.CreateBuilder(args);
builder.AddNodeApp("frontend", "../frontend", "app.js")
.WithYarn()
.WithRunScript("dev");
builder.Build().Run();
AddViteApp(IDistributedApplicationBuilder, string, string, string)Section titled AddViteApp(IDistributedApplicationBuilder, string, string, string)extensionIResourceBuilder<ViteAppResource>
Adds a Vite app to the distributed application builder.
public static class JavaScriptHostingExtensions
{
public static IResourceBuilder<ViteAppResource> AddViteApp(
this IDistributedApplicationBuilder builder,
string name,
string appDirectory,
string runScriptName = "dev")
{
// ...
}
}
builderIDistributedApplicationBuilderThe Hosting.IDistributedApplicationBuilder to add the resource to.
namestringThe name of the Vite app.
appDirectorystringThe path to the directory containing the Vite app.
runScriptNamestringoptionalThe name of the script that runs the Vite app. Defaults to "dev".
IResourceBuilder<ViteAppResource>A reference to the ApplicationModel.IResourceBuilder`1.
The following example creates a Vite app using npm as the package manager.
var builder = DistributedApplication.CreateBuilder(args);
builder.AddViteApp("frontend", "./frontend");
builder.Build().Run();
DisableBuildValidation(IResourceBuilder<NextJsAppResource>)Section titled DisableBuildValidation(IResourceBuilder<NextJsAppResource>)extensionIResourceBuilder<NextJsAppResource>
Disables deploy-time build validation checks for the Next.js application.
public static class JavaScriptHostingExtensions
{
public static IResourceBuilder<NextJsAppResource> DisableBuildValidation(
this IResourceBuilder<NextJsAppResource> builder)
{
// ...
}
}
builderIResourceBuilder<NextJsAppResource>The resource builder.
IResourceBuilder<NextJsAppResource>The resource builder for chaining.
By default, JavaScriptHostingExtensions.AddNextJsApp adds publish prerequisite steps that verify the Next.js configuration (e.g. that output: "standalone" is set). Use this method to suppress those checks when the configuration is set dynamically or via an external mechanism that cannot be detected by static file inspection.
PublishAsNodeServer(IResourceBuilder<TResource>, string, string)Section titled PublishAsNodeServer(IResourceBuilder<TResource>, string, string)extensionIResourceBuilder<TResource>
Configures the JavaScript application to publish as a standalone Node.js server that runs a built artifact directly.
public static class JavaScriptHostingExtensions
{
public static IResourceBuilder<TResource> PublishAsNodeServer<TResource>(
this IResourceBuilder<TResource> builder,
string entryPoint,
string outputPath = ".")
{
// ...
}
}
builderIResourceBuilder<TResource>The JavaScript resource builder.
entryPointstring The relative path to the Node.js entry point to execute in the published container after the build completes, such as .output/server/index.mjs or build/index.js.
outputPathstringoptional The relative path containing the built runtime files to copy into the published container. Defaults to the application root.
IResourceBuilder<TResource>The updated resource builder.
InvalidOperationException Thrown during generated Dockerfile creation when this method is used with a Deno app added by AddDenoApp. Use AddJavaScriptApp(...).WithDeno() or provide a custom Dockerfile.

Use this method for frameworks that produce a Node.js server artifact during the build and recommend running that artifact directly in production rather than invoking a package manager script at runtime. The application source is still built using the configured package manager and build script; this method only changes the publish-time runtime container shape.

The container files source path is automatically set to outputPath so that only the built output directory is copied into the runtime container, not the full application source.

PublishAsPackageScript(IResourceBuilder<TResource>, string, string?)Section titled PublishAsPackageScript(IResourceBuilder<TResource>, string, string?)extensionIResourceBuilder<TResource>
Configures the JavaScript application to publish as a server that runs a package manager script at runtime.
public static class JavaScriptHostingExtensions
{
public static IResourceBuilder<TResource> PublishAsPackageScript<TResource>(
this IResourceBuilder<TResource> builder,
string scriptName = "start",
string? runScriptArguments = null)
{
// ...
}
}
builderIResourceBuilder<TResource>The JavaScript resource builder.
scriptNamestringoptional The name of the script to run in the published container. For Node.js and Bun applications this is a package.json script; for Deno applications it is a task defined in deno.json. For example, start invokes the configured package manager's run command for the start script, such as npm run start, pnpm run start, yarn run start, bun run start, or deno task start.
runScriptArgumentsstring?optional Optional arguments appended after the script name at runtime, such as -- --port "$PORT".
IResourceBuilder<TResource>The updated resource builder.

Use this method for frameworks where the production server depends on packages resolved at runtime, either from node_modules or from the Deno dependency cache. The resulting container includes the full application with its production dependencies already installed.

This method is appropriate for frameworks like Nuxt (where useAsyncData / useFetch requires the full Nitro environment), Remix (where react-router-serve is an npm dependency), and Astro SSR (where the built entry point imports unbundled @astrojs/* packages).

For Deno applications the generated container runs deno task <scriptName> and copies the populated DENO_DIR cache from the build stage, so whatever the build resolved is already present at runtime. Unlike the Node.js and Bun package managers there is no separate production install step, because the build stage runs deno install and DENO_DIR is carried forward as-is rather than being pruned.

deno install only resolves the dependencies declared in deno.json or package.json. An import written as a bare specifier in source, such as import { assert } from "jsr:@std/assert", is not declared anywhere the installer can see, so it is fetched on first use and the container needs network access at startup. The same applies to anything reachable only from inside the build script's own task command, which Aspire cannot inspect. Add those imports to the imports map in deno.json if the container has to start without network access.

For frameworks that produce a self-contained server artifact that does not require node_modules, use JavaScriptHostingExtensions.PublishAsNodeServer instead for a smaller runtime image.

PublishAsStaticWebsite(IResourceBuilder<TResource>, Action<PublishAsStaticWebsiteOptions>)Section titled PublishAsStaticWebsite(IResourceBuilder<TResource>, Action<PublishAsStaticWebsiteOptions>)extensionIResourceBuilder<TResource>
Configures the JavaScript application to publish as a standalone static website served by YARP.
public static class JavaScriptHostingExtensions
{
public static IResourceBuilder<TResource> PublishAsStaticWebsite<TResource>(
this IResourceBuilder<TResource> builder,
Action<PublishAsStaticWebsiteOptions>? configure = null)
{
// ...
}
}
builderIResourceBuilder<TResource>The JavaScript resource builder.
configureAction<PublishAsStaticWebsiteOptions>optionalOptional callback to configure PublishAsStaticWebsiteOptions.
IResourceBuilder<TResource>The updated resource builder.
InvalidOperationException Thrown during generated Dockerfile creation when this method is used with a Deno app added by AddDenoApp. Use AddJavaScriptApp(...).WithDeno() or provide a custom Dockerfile.

The published container uses a YARP reverse proxy image for static file serving. To add an API reverse-proxy, use the overload that accepts an apiPath and apiTarget.

PublishAsStaticWebsite(IResourceBuilder<TResource>, string, IResourceBuilder<IResourceWithServiceDiscovery>, Action<PublishAsStaticWebsiteOptions>)Section titled PublishAsStaticWebsite(IResourceBuilder<TResource>, string, IResourceBuilder<IResourceWithServiceDiscovery>, Action<PublishAsStaticWebsiteOptions>)extensionIResourceBuilder<TResource>
Configures the JavaScript application to publish as a standalone static website served by YARP, with an API reverse-proxy to the specified resource.
public static class JavaScriptHostingExtensions
{
public static IResourceBuilder<TResource> PublishAsStaticWebsite<TResource>(
this IResourceBuilder<TResource> builder,
string apiPath,
IResourceBuilder<IResourceWithServiceDiscovery> apiTarget,
Action<PublishAsStaticWebsiteOptions>? configure = null)
{
// ...
}
}
builderIResourceBuilder<TResource>The JavaScript resource builder.
apiPathstring A path prefix to reverse-proxy to a backend API. For example, /api proxies all requests matching /api/{"{**catch-all}"} to the backend resource.
apiTargetIResourceBuilder<IResourceWithServiceDiscovery> The backend resource to proxy API requests to. YARP uses service discovery to resolve the appropriate endpoint, preferring HTTPS when available.
configureAction<PublishAsStaticWebsiteOptions>optionalOptional callback to configure PublishAsStaticWebsiteOptions.
IResourceBuilder<TResource>The updated resource builder.
InvalidOperationException Thrown during generated Dockerfile creation when this method is used with a Deno app added by AddDenoApp. Use AddJavaScriptApp(...).WithDeno() or provide a custom Dockerfile.

The published container uses a YARP reverse proxy image for static file serving and API reverse-proxy. YARP natively supports HTTPS backends and service discovery, so API proxy requests work correctly across all deployment targets (Docker Compose, Azure App Service, etc.).

WithBrowserDebugger(IResourceBuilder<T>, string)Section titled WithBrowserDebugger(IResourceBuilder<T>, string)extensionIResourceBuilder<T>
Configures a browser debugger for the JavaScript application resource, enabling browser-based debugging through a child resource that launches when the parent application is ready.
public static class JavaScriptHostingExtensions
{
public static IResourceBuilder<T> WithBrowserDebugger<T>(
this IResourceBuilder<T> builder,
string browser = "msedge")
{
// ...
}
}
builderIResourceBuilder<T>The resource builder for the JavaScript application.
browserstringoptionalThe browser to use for debugging. Defaults to "msedge". Supported values include "msedge" and "chrome".
IResourceBuilder<T>A reference to the ApplicationModel.IResourceBuilder`1 for chaining additional configuration.
InvalidOperationException Thrown when the parent resource does not have an HTTP or HTTPS endpoint, or when the IDE extension does not support browser debugging.
This method creates a child JavaScript.BrowserDebuggerResource that waits for the parent JavaScript application to start, then launches a browser debug session targeting the parent's HTTP or HTTPS endpoint. The parent resource must have at least one HTTP or HTTPS endpoint configured.

Add browser debugging to a JavaScript application:

var builder = DistributedApplication.CreateBuilder(args);
builder.AddViteApp("frontend", "./frontend")
.WithBrowserDebugger();
WithBuildScript(IResourceBuilder<TResource>, string, string[]?)Section titled WithBuildScript(IResourceBuilder<TResource>, string, string[]?)extensionIResourceBuilder<TResource>
Adds a build script annotation to the resource builder using the specified command-line arguments.
public static class JavaScriptHostingExtensions
{
public static IResourceBuilder<TResource> WithBuildScript<TResource>(
this IResourceBuilder<TResource> resource,
string scriptName,
string[]? args = null)
{
// ...
}
}
resourceIResourceBuilder<TResource>The resource builder to which the build script annotation will be added.
scriptNamestringThe name of the script to be executed when the resource is built.
argsstring[]?optionalAn array of command-line arguments to use for the build script.
IResourceBuilder<TResource>The same resource builder instance with the build script annotation applied.
Use this method to specify custom build scripts for JavaScript application resources during deployment.
WithBun(IResourceBuilder<TResource>, bool, string[]?)Section titled WithBun(IResourceBuilder<TResource>, bool, string[]?)extensionIResourceBuilder<TResource>
Configures the JavaScript resource to use Bun as the package manager and optionally installs packages before the application starts.
public static class JavaScriptHostingExtensions
{
public static IResourceBuilder<TResource> WithBun<TResource>(
this IResourceBuilder<TResource> resource,
bool install = true,
string[]? installArgs = null)
{
// ...
}
}
resourceIResourceBuilder<TResource>The JavaScript application resource builder.
installbooloptionalWhen true (default), automatically installs packages before the application starts. When false, only sets the package manager annotation without creating an installer resource.
installArgsstring[]?optionalAdditional command-line arguments passed to "bun install". When null, defaults are applied based on publish mode and lockfile presence.
IResourceBuilder<TResource>A reference to the ApplicationModel.IResourceBuilder`1.
Bun forwards script arguments without requiring the -- command separator, so this method configures the resource to omit it. When publishing and a bun lockfile ( bun.lock or bun.lockb) is present, --frozen-lockfile is used by default. Publishing to a container requires Bun to be present in the build image. This method configures a Bun build image when one is not already specified. JavaScriptHostingExtensions.PublishAsPackageScript also uses the Bun image for the runtime stage unless a custom runtime image is configured. To use a specific Bun version, configure a custom build image (for example, oven/bun:<tag>) using ContainerResourceBuilderExtensions.WithDockerfileBaseImage.

Run a Vite app using Bun as the package manager:

var builder = DistributedApplication.CreateBuilder(args);
builder.AddViteApp("frontend", "./frontend")
.WithBun()
.WithDockerfileBaseImage(buildImage: "oven/bun:latest"); // To use a specific Bun image
builder.Build().Run();
WithDeno(IResourceBuilder<TResource>, bool, string[]?)Section titled WithDeno(IResourceBuilder<TResource>, bool, string[]?)extensionIResourceBuilder<TResource>
Configures the JavaScript resource to use Deno as the package manager.
public static class JavaScriptHostingExtensions
{
public static IResourceBuilder<TResource> WithDeno<TResource>(
this IResourceBuilder<TResource> resource,
bool install = false,
string[]? installArgs = null)
{
// ...
}
}
resourceIResourceBuilder<TResource>The JavaScript application resource builder.
installbooloptional When true, creates an installer resource that runs deno install before the application starts. Defaults to false: unlike npm/Bun, Deno does not require a separate install step — deno run fetches and caches dependencies under DENO_DIR on first use — so no installer is wired by default. Set to true to pre-cache dependencies or to materialize a node_modules folder for Node compatibility.
installArgsstring[]?optionalAdditional command-line arguments passed to deno install.
IResourceBuilder<TResource>A reference to the ApplicationModel.IResourceBuilder`1.
Package scripts are run through Deno's task runner ( deno task <name>) rather than run. Publishing to a container requires Deno to be present in the build image. This method configures a Deno build image ( denoland/deno:2.9.0) when one is not already specified.

Run a Deno app using a deno.json task:

var builder = DistributedApplication.CreateBuilder(args);
builder.AddDenoApp("api", "../api", "main.ts")
.WithDeno()
.WithRunScript("dev");
builder.Build().Run();
WithDenoAllow(IResourceBuilder<DenoAppResource>, DenoPermissionKind, string[])Section titled WithDenoAllow(IResourceBuilder<DenoAppResource>, DenoPermissionKind, string[])extensionIResourceBuilder<DenoAppResource>
Grants a Deno permission, optionally scoped to the supplied values.
public static class JavaScriptHostingExtensions
{
public static IResourceBuilder<DenoAppResource> WithDenoAllow(
this IResourceBuilder<DenoAppResource> builder,
DenoPermissionKind kind,
params string[] values)
{
// ...
}
}
builderIResourceBuilder<DenoAppResource>The Deno app resource builder.
kindDenoPermissionKindThe permission to grant.
valuesstring[]Optional values that scope the permission. When empty, all access of the selected kind is allowed.
IResourceBuilder<DenoAppResource>A reference to the ApplicationModel.IResourceBuilder`1.
ArgumentExceptionThrown when values contains a null or empty value, or a value containing a comma.
ArgumentOutOfRangeExceptionThrown when kind is not a defined DenoPermissionKind value.
WithDenoAllowAll(IResourceBuilder<DenoAppResource>, bool)Section titled WithDenoAllowAll(IResourceBuilder<DenoAppResource>, bool)extensionIResourceBuilder<DenoAppResource>
Controls the blanket -A / --allow-all grant.
public static class JavaScriptHostingExtensions
{
public static IResourceBuilder<DenoAppResource> WithDenoAllowAll(
this IResourceBuilder<DenoAppResource> builder,
bool enabled = true)
{
// ...
}
}
builderIResourceBuilder<DenoAppResource>The Deno app resource builder.
enabledbooloptional Whether to emit -A / --allow-all. Pass false to grant only permissions configured with JavaScriptHostingExtensions.WithDenoAllow.
IResourceBuilder<DenoAppResource>A reference to the ApplicationModel.IResourceBuilder`1.
Without explicit permission configuration, local run mode emits -A for parity with Node and Bun, while generated containers default direct run / serve entrypoints to --allow-net --allow-env. Calling this method with true explicitly emits -A in both modes.
WithDenoConfig(IResourceBuilder<DenoAppResource>, string)Section titled WithDenoConfig(IResourceBuilder<DenoAppResource>, string)extensionIResourceBuilder<DenoAppResource>
Sets --config <file> (path to a deno.json / deno.jsonc).
public static class JavaScriptHostingExtensions
{
public static IResourceBuilder<DenoAppResource> WithDenoConfig(
this IResourceBuilder<DenoAppResource> builder,
string configFile)
{
// ...
}
}
builderIResourceBuilder<DenoAppResource>The Deno app resource builder.
configFilestringThe Deno configuration file path.
IResourceBuilder<DenoAppResource>A reference to the ApplicationModel.IResourceBuilder`1.
WithDenoDeny(IResourceBuilder<DenoAppResource>, DenoPermissionKind, string[])Section titled WithDenoDeny(IResourceBuilder<DenoAppResource>, DenoPermissionKind, string[])extensionIResourceBuilder<DenoAppResource>
Denies a Deno permission, optionally scoped to the supplied values.
public static class JavaScriptHostingExtensions
{
public static IResourceBuilder<DenoAppResource> WithDenoDeny(
this IResourceBuilder<DenoAppResource> builder,
DenoPermissionKind kind,
params string[] values)
{
// ...
}
}
builderIResourceBuilder<DenoAppResource>The Deno app resource builder.
kindDenoPermissionKindThe permission to deny.
valuesstring[]Optional values that scope the permission. When empty, all access of the selected kind is denied.
IResourceBuilder<DenoAppResource>A reference to the ApplicationModel.IResourceBuilder`1.
ArgumentExceptionThrown when values contains a null or empty value, or a value containing a comma.
ArgumentOutOfRangeExceptionThrown when kind is not a defined DenoPermissionKind value.
WithDenoImportMap(IResourceBuilder<DenoAppResource>, string)Section titled WithDenoImportMap(IResourceBuilder<DenoAppResource>, string)extensionIResourceBuilder<DenoAppResource>
Sets --import-map <file>.
public static class JavaScriptHostingExtensions
{
public static IResourceBuilder<DenoAppResource> WithDenoImportMap(
this IResourceBuilder<DenoAppResource> builder,
string importMapFile)
{
// ...
}
}
builderIResourceBuilder<DenoAppResource>The Deno app resource builder.
importMapFilestringThe import map file path.
IResourceBuilder<DenoAppResource>A reference to the ApplicationModel.IResourceBuilder`1.
WithDenoInspect(IResourceBuilder<DenoAppResource>, DenoInspectMode, string?)Section titled WithDenoInspect(IResourceBuilder<DenoAppResource>, DenoInspectMode, string?)extensionIResourceBuilder<DenoAppResource>
Enables a Deno inspector mode, optionally at hostPort (for example 127.0.0.1:9229).
public static class JavaScriptHostingExtensions
{
public static IResourceBuilder<DenoAppResource> WithDenoInspect(
this IResourceBuilder<DenoAppResource> builder,
DenoInspectMode mode = DenoInspectMode.Inspect,
string? hostPort = null)
{
// ...
}
}
builderIResourceBuilder<DenoAppResource>The Deno app resource builder.
modeDenoInspectModeoptionalThe inspector mode to enable.
hostPortstring?optionalThe optional inspector host:port value.
IResourceBuilder<DenoAppResource>A reference to the ApplicationModel.IResourceBuilder`1.
ArgumentOutOfRangeExceptionThrown when mode is not a defined DenoInspectMode value.
WithDenoLock(IResourceBuilder<DenoAppResource>, string)Section titled WithDenoLock(IResourceBuilder<DenoAppResource>, string)extensionIResourceBuilder<DenoAppResource>
Sets --lock <file>.
public static class JavaScriptHostingExtensions
{
public static IResourceBuilder<DenoAppResource> WithDenoLock(
this IResourceBuilder<DenoAppResource> builder,
string lockFile)
{
// ...
}
}
builderIResourceBuilder<DenoAppResource>The Deno app resource builder.
lockFilestringThe lockfile path.
IResourceBuilder<DenoAppResource>A reference to the ApplicationModel.IResourceBuilder`1.
WithDenoNodeModulesDir(IResourceBuilder<DenoAppResource>, DenoNodeModulesDirMode?)Section titled WithDenoNodeModulesDir(IResourceBuilder<DenoAppResource>, DenoNodeModulesDirMode?)extensionIResourceBuilder<DenoAppResource>
Sets --node-modules-dir, optionally with a mode emitted as --node-modules-dir=<mode>.
public static class JavaScriptHostingExtensions
{
public static IResourceBuilder<DenoAppResource> WithDenoNodeModulesDir(
this IResourceBuilder<DenoAppResource> builder,
DenoNodeModulesDirMode? mode = null)
{
// ...
}
}
builderIResourceBuilder<DenoAppResource>The Deno app resource builder.
modeDenoNodeModulesDirMode?optionalThe node_modules mode. When null, emits --node-modules-dir without a value.
IResourceBuilder<DenoAppResource>A reference to the ApplicationModel.IResourceBuilder`1.
ArgumentOutOfRangeExceptionThrown when mode is not a defined DenoNodeModulesDirMode value.
The generated Deno Dockerfile publisher does not support manual mode because it excludes local node_modules from the build context. Use auto or provide a custom Dockerfile for that mode.
WithDenoNoLock(IResourceBuilder<DenoAppResource>)Section titled WithDenoNoLock(IResourceBuilder<DenoAppResource>)extensionIResourceBuilder<DenoAppResource>
Sets --no-lock, disabling lockfile use.
public static class JavaScriptHostingExtensions
{
public static IResourceBuilder<DenoAppResource> WithDenoNoLock(
this IResourceBuilder<DenoAppResource> builder)
{
// ...
}
}
builderIResourceBuilder<DenoAppResource>The Deno app resource builder.
IResourceBuilder<DenoAppResource>A reference to the ApplicationModel.IResourceBuilder`1.
WithDenoRun(IResourceBuilder<DenoAppResource>)Section titled WithDenoRun(IResourceBuilder<DenoAppResource>)extensionIResourceBuilder<DenoAppResource>
Selects the deno run <entrypoint> mode (the default).
public static class JavaScriptHostingExtensions
{
public static IResourceBuilder<DenoAppResource> WithDenoRun(
this IResourceBuilder<DenoAppResource> builder)
{
// ...
}
}
builderIResourceBuilder<DenoAppResource>The Deno app resource builder.
IResourceBuilder<DenoAppResource>A reference to the ApplicationModel.IResourceBuilder`1.
WithDenoRuntimeArgs(IResourceBuilder<DenoAppResource>, string[])Section titled WithDenoRuntimeArgs(IResourceBuilder<DenoAppResource>, string[])extensionIResourceBuilder<DenoAppResource>
Appends raw runtime arguments injected verbatim BEFORE the entrypoint. This is the escape hatch that gives full parity with AddExecutable("name", "deno", workdir, args...) for any flag not covered by a dedicated WithDeno* method.
public static class JavaScriptHostingExtensions
{
public static IResourceBuilder<DenoAppResource> WithDenoRuntimeArgs(
this IResourceBuilder<DenoAppResource> builder,
params string[] args)
{
// ...
}
}
builderIResourceBuilder<DenoAppResource>The Deno app resource builder.
argsstring[]The runtime arguments to append before the entrypoint or task name.
IResourceBuilder<DenoAppResource>A reference to the ApplicationModel.IResourceBuilder`1.
WithDenoScriptArgs(IResourceBuilder<DenoAppResource>, string[])Section titled WithDenoScriptArgs(IResourceBuilder<DenoAppResource>, string[])extensionIResourceBuilder<DenoAppResource>
Appends arguments passed to the script AFTER the entrypoint. Deno forwards everything after the entrypoint to the running program.
public static class JavaScriptHostingExtensions
{
public static IResourceBuilder<DenoAppResource> WithDenoScriptArgs(
this IResourceBuilder<DenoAppResource> builder,
params string[] args)
{
// ...
}
}
builderIResourceBuilder<DenoAppResource>The Deno app resource builder.
argsstring[]The script arguments to append after the entrypoint or task name.
IResourceBuilder<DenoAppResource>A reference to the ApplicationModel.IResourceBuilder`1.
WithDenoServe(IResourceBuilder<DenoAppResource>)Section titled WithDenoServe(IResourceBuilder<DenoAppResource>)extensionIResourceBuilder<DenoAppResource>
Selects the deno serve <entrypoint> mode for serving an HTTP entrypoint.
public static class JavaScriptHostingExtensions
{
public static IResourceBuilder<DenoAppResource> WithDenoServe(
this IResourceBuilder<DenoAppResource> builder)
{
// ...
}
}
builderIResourceBuilder<DenoAppResource>The Deno app resource builder.
IResourceBuilder<DenoAppResource>A reference to the ApplicationModel.IResourceBuilder`1.
WithDenoTask(IResourceBuilder<DenoAppResource>, string)Section titled WithDenoTask(IResourceBuilder<DenoAppResource>, string)extensionIResourceBuilder<DenoAppResource>
Selects the deno task <taskName> mode, running a task defined in deno.json instead of a script entrypoint. Permissions are defined by the task itself and are not emitted for this mode.
public static class JavaScriptHostingExtensions
{
public static IResourceBuilder<DenoAppResource> WithDenoTask(
this IResourceBuilder<DenoAppResource> builder,
string taskName)
{
// ...
}
}
builderIResourceBuilder<DenoAppResource>The Deno app resource builder.
taskNamestringThe name of the task in deno.json to run.
IResourceBuilder<DenoAppResource>A reference to the ApplicationModel.IResourceBuilder`1.
WithDenoUnstable(IResourceBuilder<DenoAppResource>, string[])Section titled WithDenoUnstable(IResourceBuilder<DenoAppResource>, string[])extensionIResourceBuilder<DenoAppResource>
Adds one or more --unstable-* flags. Each feature may be supplied bare (for example "kv", "worker-options", "sloppy-imports") or fully qualified ( "--unstable-kv").
public static class JavaScriptHostingExtensions
{
public static IResourceBuilder<DenoAppResource> WithDenoUnstable(
this IResourceBuilder<DenoAppResource> builder,
params string[] features)
{
// ...
}
}
builderIResourceBuilder<DenoAppResource>The Deno app resource builder.
featuresstring[]The unstable feature names or fully-qualified --unstable-* flags to emit.
IResourceBuilder<DenoAppResource>A reference to the ApplicationModel.IResourceBuilder`1.
WithDenoWatch(IResourceBuilder<DenoAppResource>, bool)Section titled WithDenoWatch(IResourceBuilder<DenoAppResource>, bool)extensionIResourceBuilder<DenoAppResource>
Enables --watch (or --watch-hmr when hmr is true).
public static class JavaScriptHostingExtensions
{
public static IResourceBuilder<DenoAppResource> WithDenoWatch(
this IResourceBuilder<DenoAppResource> builder,
bool hmr = false)
{
// ...
}
}
builderIResourceBuilder<DenoAppResource>The Deno app resource builder.
hmrbooloptionalWhether to emit --watch-hmr instead of --watch.
IResourceBuilder<DenoAppResource>A reference to the ApplicationModel.IResourceBuilder`1.
WithNpm(IResourceBuilder<TResource>, bool, string?, string[]?)Section titled WithNpm(IResourceBuilder<TResource>, bool, string?, string[]?)extensionIResourceBuilder<TResource>
Configures the Node.js resource to use npm as the package manager and optionally installs packages before the application starts.
public static class JavaScriptHostingExtensions
{
public static IResourceBuilder<TResource> WithNpm<TResource>(
this IResourceBuilder<TResource> resource,
bool install = true,
string? installCommand = null,
string[]? installArgs = null)
{
// ...
}
}
resourceIResourceBuilder<TResource>The NodeAppResource.
installbooloptionalWhen true (default), automatically installs packages before the application starts. When false, only sets the package manager annotation without creating an installer resource.
installCommandstring?optionalThe install command itself passed to npm to install dependencies.
installArgsstring[]?optionalThe command-line arguments passed to npm to install dependencies.
IResourceBuilder<TResource>A reference to the ApplicationModel.IResourceBuilder`1.
WithPnpm(IResourceBuilder<TResource>, bool, string[]?)Section titled WithPnpm(IResourceBuilder<TResource>, bool, string[]?)extensionIResourceBuilder<TResource>
Configures the Node.js resource to use pnpm as the package manager and optionally installs packages before the application starts.
public static class JavaScriptHostingExtensions
{
public static IResourceBuilder<TResource> WithPnpm<TResource>(
this IResourceBuilder<TResource> resource,
bool install = true,
string[]? installArgs = null)
{
// ...
}
}
resourceIResourceBuilder<TResource>The NodeAppResource.
installbooloptionalWhen true (default), automatically installs packages before the application starts. When false, only sets the package manager annotation without creating an installer resource.
installArgsstring[]?optionalThe command-line arguments passed to "pnpm install".
IResourceBuilder<TResource>A reference to the ApplicationModel.IResourceBuilder`1.
InvalidOperationExceptionThrown when package.json declares an invalid pnpm package manager version or integrity.
WithRunScript(IResourceBuilder<TResource>, string, string[]?)Section titled WithRunScript(IResourceBuilder<TResource>, string, string[]?)extensionIResourceBuilder<TResource>
Adds a run script annotation to the specified JavaScript application resource builder, specifying the script to execute and its arguments during run mode.
public static class JavaScriptHostingExtensions
{
public static IResourceBuilder<TResource> WithRunScript<TResource>(
this IResourceBuilder<TResource> resource,
string scriptName,
string[]? args = null)
{
// ...
}
}
resourceIResourceBuilder<TResource>The resource builder to which the run script annotation will be added.
scriptNamestringThe name of the script to be executed when the resource is run.
argsstring[]?optionalAn array of arguments to pass to the script.
IResourceBuilder<TResource>The same resource builder instance with the run script annotation applied, enabling further configuration.
Use this method to specify a custom script and its arguments that should be executed when the resource is executed in RunMode.
WithViteConfig(IResourceBuilder<ViteAppResource>, string)Section titled WithViteConfig(IResourceBuilder<ViteAppResource>, string)extensionIResourceBuilder<ViteAppResource>
Configures the Vite app to use the specified Vite configuration file instead of the default resolution behavior.
public static class JavaScriptHostingExtensions
{
public static IResourceBuilder<ViteAppResource> WithViteConfig(
this IResourceBuilder<ViteAppResource> builder,
string configPath)
{
// ...
}
}
builderIResourceBuilder<ViteAppResource>The resource builder.
configPathstringThe path to the Vite configuration file. Relative to the Vite service project root.
IResourceBuilder<ViteAppResource>The resource builder.
Use this method to specify a specific Vite configuration file if you need to override the default Vite configuration resolution behavior.

Use a custom Vite configuration file:

var builder = DistributedApplication.CreateBuilder(args);
var viteApp = builder.AddViteApp("frontend", "./frontend")
.WithViteConfig("./vite.production.config.js");
WithYarn(IResourceBuilder<TResource>, bool, string[]?)Section titled WithYarn(IResourceBuilder<TResource>, bool, string[]?)extensionIResourceBuilder<TResource>
Configures the Node.js resource to use yarn as the package manager and optionally installs packages before the application starts.
public static class JavaScriptHostingExtensions
{
public static IResourceBuilder<TResource> WithYarn<TResource>(
this IResourceBuilder<TResource> resource,
bool install = true,
string[]? installArgs = null)
{
// ...
}
}
resourceIResourceBuilder<TResource>The NodeAppResource.
installbooloptionalWhen true (default), automatically installs packages before the application starts. When false, only sets the package manager annotation without creating an installer resource.
installArgsstring[]?optionalThe command-line arguments passed to "yarn install".
IResourceBuilder<TResource>A reference to the ApplicationModel.IResourceBuilder`1.