JavaScriptHostingExtensions Methods
DenoAppResource . AddBunApp(IDistributedApplicationBuilder, string, string, string) Section titled AddBunApp(IDistributedApplicationBuilder, string, string, string)extensionIResourceBuilder<BunAppResource> public static class JavaScriptHostingExtensions{ public static IResourceBuilder<BunAppResource> AddBunApp( this IDistributedApplicationBuilder builder, string name, string appDirectory, string scriptPath) { // ... }}Parameters
builderIDistributedApplicationBuilder The Hosting.IDistributedApplicationBuilder to add the resource to.namestringThe name of the resource.appDirectory stringThe path to the directory containing the Bun application.scriptPath stringThe path to the script (for example, server.ts ) relative to appDirectory to run.Returns
IResourceBuilder<BunAppResource> A reference to the ApplicationModel.IResourceBuilder`1 .Remarks
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. Examples
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> public static class JavaScriptHostingExtensions{ public static IResourceBuilder<DenoAppResource> AddDenoApp( this IDistributedApplicationBuilder builder, string name, string appDirectory, string scriptPath) { // ... }}Parameters
builderIDistributedApplicationBuilder The Hosting.IDistributedApplicationBuilder to add the resource to.namestringThe name of the resource.appDirectory stringThe path to the directory containing the Deno application.scriptPath stringThe path to the script (for example, main.ts ) relative to appDirectory to run.Returns
IResourceBuilder<DenoAppResource> A reference to the ApplicationModel.IResourceBuilder`1 .Remarks
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. Examples
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> public static class JavaScriptHostingExtensions{ public static IResourceBuilder<JavaScriptAppResource> AddJavaScriptApp( this IDistributedApplicationBuilder builder, string name, string appDirectory, string runScriptName = "dev") { // ... }}Parameters
builderIDistributedApplicationBuilder The 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.appDirectory stringThe path to the directory containing the JavaScript application.runScriptName stringoptionalThe name of the npm script to run when starting the application. Defaults to "dev". Cannot be null or empty.Returns
IResourceBuilder<JavaScriptAppResource> A resource builder for the newly added JavaScript application resource.Remarks
AddNextJsApp(IDistributedApplicationBuilder, string, string, string) Section titled AddNextJsApp(IDistributedApplicationBuilder, string, string, string)extensionIResourceBuilder<NextJsAppResource> public static class JavaScriptHostingExtensions{ public static IResourceBuilder<NextJsAppResource> AddNextJsApp( this IDistributedApplicationBuilder builder, string name, string appDirectory, string runScriptName = "dev") { // ... }}Parameters
builderIDistributedApplicationBuilder The Hosting.IDistributedApplicationBuilder to add the resource to.namestringThe name of the Next.js app.appDirectory stringThe path to the directory containing the Next.js app.runScriptName stringoptionalThe name of the script that runs the Next.js dev server. Defaults to "dev".Returns
IResourceBuilder<NextJsAppResource> A reference to the ApplicationModel.IResourceBuilder`1 .Remarks
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/, and .next/ into a Node.js runtime container.
The Next.js application must have output: configured in next. and a public/ directory (even if empty) for the published container to build correctly.
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> public static class JavaScriptHostingExtensions{ public static IResourceBuilder<NodeAppResource> AddNodeApp( this IDistributedApplicationBuilder builder, string name, string appDirectory, string scriptPath) { // ... }}Parameters
builderIDistributedApplicationBuilder The Hosting.IDistributedApplicationBuilder to add the resource to.namestringThe name of the resource.appDirectory stringThe path to the directory containing the node application.scriptPath stringThe path to the script relative to the app directory to run.Returns
IResourceBuilder<NodeAppResource> A reference to the ApplicationModel.IResourceBuilder`1 .Remarks
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. Examples
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> public static class JavaScriptHostingExtensions{ public static IResourceBuilder<ViteAppResource> AddViteApp( this IDistributedApplicationBuilder builder, string name, string appDirectory, string runScriptName = "dev") { // ... }}Parameters
builderIDistributedApplicationBuilder The Hosting.IDistributedApplicationBuilder to add the resource to.namestringThe name of the Vite app.appDirectory stringThe path to the directory containing the Vite app.runScriptName stringoptionalThe name of the script that runs the Vite app. Defaults to "dev".Returns
IResourceBuilder<ViteAppResource> A reference to the ApplicationModel.IResourceBuilder`1 .Remarks
var builder = DistributedApplication.CreateBuilder(args);
builder.AddViteApp("frontend", "./frontend");
builder.Build().Run();DisableBuildValidation(IResourceBuilder<NextJsAppResource>) Section titled DisableBuildValidation(IResourceBuilder<NextJsAppResource>)extensionIResourceBuilder<NextJsAppResource> public static class JavaScriptHostingExtensions{ public static IResourceBuilder<NextJsAppResource> DisableBuildValidation( this IResourceBuilder<NextJsAppResource> builder) { // ... }}Parameters
builderIResourceBuilder<NextJsAppResource> The resource builder.Returns
IResourceBuilder<NextJsAppResource> The resource builder for chaining.Remarks
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> public static class JavaScriptHostingExtensions{ public static IResourceBuilder<TResource> PublishAsNodeServer<TResource>( this IResourceBuilder<TResource> builder, string entryPoint, string outputPath = ".") { // ... }}Parameters
builderIResourceBuilder<TResource> The JavaScript resource builder.entryPoint string 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 . outputPath stringoptional The relative path containing the built runtime files to copy into the published container. Defaults to the application root. Returns
IResourceBuilder<TResource> The updated resource builder.Exceptions
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. Remarks
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 output 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> public static class JavaScriptHostingExtensions{ public static IResourceBuilder<TResource> PublishAsPackageScript<TResource>( this IResourceBuilder<TResource> builder, string scriptName = "start", string? runScriptArguments = null) { // ... }}Parameters
builderIResourceBuilder<TResource> The JavaScript resource builder.scriptName stringoptional 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. runScriptArguments string?optional Optional arguments appended after the script name at runtime, such as -- --port "$PORT" . Returns
IResourceBuilder<TResource> The updated resource builder.Remarks
Use this method for frameworks where the production server depends on packages resolved at runtime, either from node_ 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 use / use requires the full Nitro environment), Remix (where react- 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 and copies the populated DENO_ 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_ is carried forward as-is rather than being pruned.
deno install only resolves the dependencies declared in deno. or package.. An import written as a bare specifier in source, such as import { assert } from "jsr:, 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. if the container has to start without network access.
For frameworks that produce a self-contained server artifact that does not require node_, use Java instead for a smaller runtime image.
PublishAsStaticWebsite(IResourceBuilder<TResource>, Action<PublishAsStaticWebsiteOptions>) Section titled PublishAsStaticWebsite(IResourceBuilder<TResource>, Action<PublishAsStaticWebsiteOptions>)extensionIResourceBuilder<TResource> public static class JavaScriptHostingExtensions{ public static IResourceBuilder<TResource> PublishAsStaticWebsite<TResource>( this IResourceBuilder<TResource> builder, Action<PublishAsStaticWebsiteOptions>? configure = null) { // ... }}Parameters
builderIResourceBuilder<TResource> The JavaScript resource builder.configureAction<PublishAsStaticWebsiteOptions> optionalOptional callback to configure PublishAsStaticWebsiteOptions .Returns
IResourceBuilder<TResource> The updated resource builder.Exceptions
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. Remarks
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 api and api.
PublishAsStaticWebsite(IResourceBuilder<TResource>, string, IResourceBuilder<IResourceWithServiceDiscovery>, Action<PublishAsStaticWebsiteOptions>) Section titled PublishAsStaticWebsite(IResourceBuilder<TResource>, string, IResourceBuilder<IResourceWithServiceDiscovery>, Action<PublishAsStaticWebsiteOptions>)extensionIResourceBuilder<TResource> public static class JavaScriptHostingExtensions{ public static IResourceBuilder<TResource> PublishAsStaticWebsite<TResource>( this IResourceBuilder<TResource> builder, string apiPath, IResourceBuilder<IResourceWithServiceDiscovery> apiTarget, Action<PublishAsStaticWebsiteOptions>? configure = null) { // ... }}Parameters
builderIResourceBuilder<TResource> The JavaScript resource builder.apiPath string A path prefix to reverse-proxy to a backend API. For example, /api proxies all requests matching /api/{"{**catch-all}"} to the backend resource. apiTarget IResourceBuilder<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 .Returns
IResourceBuilder<TResource> The updated resource builder.Exceptions
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. Remarks
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> public static class JavaScriptHostingExtensions{ public static IResourceBuilder<T> WithBrowserDebugger<T>( this IResourceBuilder<T> builder, string browser = "msedge") { // ... }}Parameters
builderIResourceBuilder<T> The resource builder for the JavaScript application.browserstringoptionalThe browser to use for debugging. Defaults to "msedge". Supported values include "msedge" and "chrome".Returns
IResourceBuilder<T> A reference to the ApplicationModel.IResourceBuilder`1 for chaining additional configuration.Exceptions
InvalidOperationException Thrown when the parent resource does not have an HTTP or HTTPS endpoint, or when the IDE extension does not support browser debugging. Remarks
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. Examples
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> public static class JavaScriptHostingExtensions{ public static IResourceBuilder<TResource> WithBuildScript<TResource>( this IResourceBuilder<TResource> resource, string scriptName, string[]? args = null) { // ... }}Parameters
resourceIResourceBuilder<TResource> The resource builder to which the build script annotation will be added.scriptName stringThe 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.Returns
IResourceBuilder<TResource> The same resource builder instance with the build script annotation applied.Remarks
WithBun(IResourceBuilder<TResource>, bool, string[]?) Section titled WithBun(IResourceBuilder<TResource>, bool, string[]?)extensionIResourceBuilder<TResource> public static class JavaScriptHostingExtensions{ public static IResourceBuilder<TResource> WithBun<TResource>( this IResourceBuilder<TResource> resource, bool install = true, string[]? installArgs = null) { // ... }}Parameters
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.installArgs string[]? optionalAdditional command-line arguments passed to "bun install". When null, defaults are applied based on publish mode and lockfile presence.Returns
IResourceBuilder<TResource> A reference to the ApplicationModel.IResourceBuilder`1 .Remarks
-- 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 . Examples
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> public static class JavaScriptHostingExtensions{ public static IResourceBuilder<TResource> WithDeno<TResource>( this IResourceBuilder<TResource> resource, bool install = false, string[]? installArgs = null) { // ... }}Parameters
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. installArgs string[]? optionalAdditional command-line arguments passed to deno install.Returns
IResourceBuilder<TResource> A reference to the ApplicationModel.IResourceBuilder`1 .Remarks
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. Examples
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> public static class JavaScriptHostingExtensions{ public static IResourceBuilder<DenoAppResource> WithDenoAllow( this IResourceBuilder<DenoAppResource> builder, DenoPermissionKind kind, params string[] values) { // ... }}Parameters
builderIResourceBuilder<DenoAppResource> The Deno app resource builder.kindDenovaluesstring[]Optional values that scope the permission. When empty, all access of the selected kind is allowed.Returns
IResourceBuilder<DenoAppResource> A reference to the ApplicationModel.IResourceBuilder`1 .Exceptions
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> -A / --allow-all grant. public static class JavaScriptHostingExtensions{ public static IResourceBuilder<DenoAppResource> WithDenoAllowAll( this IResourceBuilder<DenoAppResource> builder, bool enabled = true) { // ... }}Parameters
builderIResourceBuilder<DenoAppResource> The Deno app resource builder.enabledbooloptional Whether to emit -A / --allow-all . Pass false to grant only permissions configured with JavaScriptHostingExtensions.WithDenoAllow . Returns
IResourceBuilder<DenoAppResource> A reference to the ApplicationModel.IResourceBuilder`1 .Remarks
-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> --config <file> (path to a deno.json / deno.jsonc ).public static class JavaScriptHostingExtensions{ public static IResourceBuilder<DenoAppResource> WithDenoConfig( this IResourceBuilder<DenoAppResource> builder, string configFile) { // ... }}Parameters
builderIResourceBuilder<DenoAppResource> The Deno app resource builder.configFile stringThe Deno configuration file path.Returns
IResourceBuilder<DenoAppResource> A reference to the ApplicationModel.IResourceBuilder`1 .WithDenoDeny(IResourceBuilder<DenoAppResource>, DenoPermissionKind, string[]) Section titled WithDenoDeny(IResourceBuilder<DenoAppResource>, DenoPermissionKind, string[])extensionIResourceBuilder<DenoAppResource> public static class JavaScriptHostingExtensions{ public static IResourceBuilder<DenoAppResource> WithDenoDeny( this IResourceBuilder<DenoAppResource> builder, DenoPermissionKind kind, params string[] values) { // ... }}Parameters
builderIResourceBuilder<DenoAppResource> The Deno app resource builder.kindDenovaluesstring[]Optional values that scope the permission. When empty, all access of the selected kind is denied.Returns
IResourceBuilder<DenoAppResource> A reference to the ApplicationModel.IResourceBuilder`1 .Exceptions
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> --import-map <file> .public static class JavaScriptHostingExtensions{ public static IResourceBuilder<DenoAppResource> WithDenoImportMap( this IResourceBuilder<DenoAppResource> builder, string importMapFile) { // ... }}Parameters
builderIResourceBuilder<DenoAppResource> The Deno app resource builder.importMapFile stringThe import map file path.Returns
IResourceBuilder<DenoAppResource> A reference to the ApplicationModel.IResourceBuilder`1 .WithDenoInspect(IResourceBuilder<DenoAppResource>, DenoInspectMode, string?) Section titled WithDenoInspect(IResourceBuilder<DenoAppResource>, DenoInspectMode, string?)extensionIResourceBuilder<DenoAppResource> 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) { // ... }}Parameters
builderIResourceBuilder<DenoAppResource> The Deno app resource builder.modeDenohostPort string?optionalThe optional inspector host:port value.Returns
IResourceBuilder<DenoAppResource> A reference to the ApplicationModel.IResourceBuilder`1 .Exceptions
ArgumentOutOfRangeExceptionThrown when mode is not a defined DenoInspectMode value.WithDenoLock(IResourceBuilder<DenoAppResource>, string) Section titled WithDenoLock(IResourceBuilder<DenoAppResource>, string)extensionIResourceBuilder<DenoAppResource> --lock <file> .public static class JavaScriptHostingExtensions{ public static IResourceBuilder<DenoAppResource> WithDenoLock( this IResourceBuilder<DenoAppResource> builder, string lockFile) { // ... }}Parameters
builderIResourceBuilder<DenoAppResource> The Deno app resource builder.lockFile stringThe lockfile path.Returns
IResourceBuilder<DenoAppResource> A reference to the ApplicationModel.IResourceBuilder`1 .WithDenoNodeModulesDir(IResourceBuilder<DenoAppResource>, DenoNodeModulesDirMode?) Section titled WithDenoNodeModulesDir(IResourceBuilder<DenoAppResource>, DenoNodeModulesDirMode?)extensionIResourceBuilder<DenoAppResource> --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) { // ... }}Parameters
builderIResourceBuilder<DenoAppResource> The Deno app resource builder.modeDenonull, emits --node-modules-dir without a value.Returns
IResourceBuilder<DenoAppResource> A reference to the ApplicationModel.IResourceBuilder`1 .Exceptions
ArgumentOutOfRangeExceptionThrown when mode is not a defined DenoNodeModulesDirMode value.Remarks
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> --no-lock , disabling lockfile use.public static class JavaScriptHostingExtensions{ public static IResourceBuilder<DenoAppResource> WithDenoNoLock( this IResourceBuilder<DenoAppResource> builder) { // ... }}Parameters
builderIResourceBuilder<DenoAppResource> The Deno app resource builder.Returns
IResourceBuilder<DenoAppResource> A reference to the ApplicationModel.IResourceBuilder`1 .WithDenoRun(IResourceBuilder<DenoAppResource>) Section titled WithDenoRun(IResourceBuilder<DenoAppResource>)extensionIResourceBuilder<DenoAppResource> deno run <entrypoint> mode (the default).public static class JavaScriptHostingExtensions{ public static IResourceBuilder<DenoAppResource> WithDenoRun( this IResourceBuilder<DenoAppResource> builder) { // ... }}Parameters
builderIResourceBuilder<DenoAppResource> The Deno app resource builder.Returns
IResourceBuilder<DenoAppResource> A reference to the ApplicationModel.IResourceBuilder`1 .WithDenoRuntimeArgs(IResourceBuilder<DenoAppResource>, string[]) Section titled WithDenoRuntimeArgs(IResourceBuilder<DenoAppResource>, string[])extensionIResourceBuilder<DenoAppResource> 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) { // ... }}Parameters
builderIResourceBuilder<DenoAppResource> The Deno app resource builder.argsstring[]The runtime arguments to append before the entrypoint or task name.Returns
IResourceBuilder<DenoAppResource> A reference to the ApplicationModel.IResourceBuilder`1 .WithDenoScriptArgs(IResourceBuilder<DenoAppResource>, string[]) Section titled WithDenoScriptArgs(IResourceBuilder<DenoAppResource>, string[])extensionIResourceBuilder<DenoAppResource> public static class JavaScriptHostingExtensions{ public static IResourceBuilder<DenoAppResource> WithDenoScriptArgs( this IResourceBuilder<DenoAppResource> builder, params string[] args) { // ... }}Parameters
builderIResourceBuilder<DenoAppResource> The Deno app resource builder.argsstring[]The script arguments to append after the entrypoint or task name.Returns
IResourceBuilder<DenoAppResource> A reference to the ApplicationModel.IResourceBuilder`1 .WithDenoServe(IResourceBuilder<DenoAppResource>) Section titled WithDenoServe(IResourceBuilder<DenoAppResource>)extensionIResourceBuilder<DenoAppResource> deno serve <entrypoint> mode for serving an HTTP entrypoint.public static class JavaScriptHostingExtensions{ public static IResourceBuilder<DenoAppResource> WithDenoServe( this IResourceBuilder<DenoAppResource> builder) { // ... }}Parameters
builderIResourceBuilder<DenoAppResource> The Deno app resource builder.Returns
IResourceBuilder<DenoAppResource> A reference to the ApplicationModel.IResourceBuilder`1 .WithDenoTask(IResourceBuilder<DenoAppResource>, string) Section titled WithDenoTask(IResourceBuilder<DenoAppResource>, string)extensionIResourceBuilder<DenoAppResource> 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) { // ... }}Parameters
builderIResourceBuilder<DenoAppResource> The Deno app resource builder.taskName stringThe name of the task in deno.json to run.Returns
IResourceBuilder<DenoAppResource> A reference to the ApplicationModel.IResourceBuilder`1 .WithDenoUnstable(IResourceBuilder<DenoAppResource>, string[]) Section titled WithDenoUnstable(IResourceBuilder<DenoAppResource>, string[])extensionIResourceBuilder<DenoAppResource> --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) { // ... }}Parameters
builderIResourceBuilder<DenoAppResource> The Deno app resource builder.featuresstring[]The unstable feature names or fully-qualified --unstable-* flags to emit.Returns
IResourceBuilder<DenoAppResource> A reference to the ApplicationModel.IResourceBuilder`1 .WithDenoWatch(IResourceBuilder<DenoAppResource>, bool) Section titled WithDenoWatch(IResourceBuilder<DenoAppResource>, bool)extensionIResourceBuilder<DenoAppResource> --watch (or --watch-hmr when hmr is true).public static class JavaScriptHostingExtensions{ public static IResourceBuilder<DenoAppResource> WithDenoWatch( this IResourceBuilder<DenoAppResource> builder, bool hmr = false) { // ... }}Parameters
builderIResourceBuilder<DenoAppResource> The Deno app resource builder.hmrbooloptionalWhether to emit --watch-hmr instead of --watch .Returns
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> public static class JavaScriptHostingExtensions{ public static IResourceBuilder<TResource> WithNpm<TResource>( this IResourceBuilder<TResource> resource, bool install = true, string? installCommand = null, string[]? installArgs = null) { // ... }}Parameters
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.installCommand string?optionalThe install command itself passed to npm to install dependencies.installArgs string[]? optionalThe command-line arguments passed to npm to install dependencies.Returns
IResourceBuilder<TResource> A reference to the ApplicationModel.IResourceBuilder`1 .WithPnpm(IResourceBuilder<TResource>, bool, string[]?) Section titled WithPnpm(IResourceBuilder<TResource>, bool, string[]?)extensionIResourceBuilder<TResource> public static class JavaScriptHostingExtensions{ public static IResourceBuilder<TResource> WithPnpm<TResource>( this IResourceBuilder<TResource> resource, bool install = true, string[]? installArgs = null) { // ... }}Parameters
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.installArgs string[]? optionalThe command-line arguments passed to "pnpm install".Returns
IResourceBuilder<TResource> A reference to the ApplicationModel.IResourceBuilder`1 .Exceptions
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> public static class JavaScriptHostingExtensions{ public static IResourceBuilder<TResource> WithRunScript<TResource>( this IResourceBuilder<TResource> resource, string scriptName, string[]? args = null) { // ... }}Parameters
resourceIResourceBuilder<TResource> The resource builder to which the run script annotation will be added.scriptName stringThe name of the script to be executed when the resource is run.argsstring[]? optionalAn array of arguments to pass to the script.Returns
IResourceBuilder<TResource> The same resource builder instance with the run script annotation applied, enabling further configuration.Remarks
WithViteConfig(IResourceBuilder<ViteAppResource>, string) Section titled WithViteConfig(IResourceBuilder<ViteAppResource>, string)extensionIResourceBuilder<ViteAppResource> public static class JavaScriptHostingExtensions{ public static IResourceBuilder<ViteAppResource> WithViteConfig( this IResourceBuilder<ViteAppResource> builder, string configPath) { // ... }}Parameters
builderIResourceBuilder<ViteAppResource> The resource builder.configPath stringThe path to the Vite configuration file. Relative to the Vite service project root.Returns
IResourceBuilder<ViteAppResource> The resource builder.Remarks
Examples
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> public static class JavaScriptHostingExtensions{ public static IResourceBuilder<TResource> WithYarn<TResource>( this IResourceBuilder<TResource> resource, bool install = true, string[]? installArgs = null) { // ... }}Parameters
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.installArgs string[]? optionalThe command-line arguments passed to "yarn install".Returns
IResourceBuilder<TResource> A reference to the ApplicationModel.IResourceBuilder`1 .