{"record":{"id":"74ef56bee6e03df2","repo":"microsoft/aspire","slug":"javascript-app-resource-resource-name-is-configured-to-run","errorCode":null,"errorMessage":"JavaScript app resource '{resource.Name}' is configured to run script '{runScript.ScriptName}'{argsClause}, but publish is using the existing Dockerfile '{dockerfileBuildAnnotation.DockerfilePath}'. An existing Dockerfile entrypoint cannot be changed automatically from runScriptName or WithRunScript. Remove or rename the Dockerfile so Aspire can generate one, or call PublishAsDockerFile(...) and set the container entrypoint explicitly.","messagePattern":"JavaScript app resource '(.+?)' is configured to run script '(.+?)'(.+?), but publish is using the existing Dockerfile '(.+?)'\\. An existing Dockerfile entrypoint cannot be changed automatically from runScriptName or WithRunScript\\. Remove or rename the Dockerfile so Aspire can generate one, or call PublishAsDockerFile\\(\\.\\.\\.\\) and set the container entrypoint explicitly\\.","errorType":"exception","errorClass":"DistributedApplicationException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.JavaScript/JavaScriptHostingExtensions.cs","lineNumber":1982,"sourceCode":"            !string.Equals(runScript.ScriptName, DefaultJavaScriptRunScriptName, StringComparison.Ordinal) ||\n            runScript.Args is { Length: > 0 };\n\n        if (!hasExplicitRunScript)\n        {\n            return;\n        }\n\n        // Include the args in the message when they are the trigger, so the user can see why\n        // a default-named script (e.g. \"dev\") still produced a conflict.\n        var argsClause = runScript.Args is { Length: > 0 }\n            ? $\" with args [{string.Join(\", \", runScript.Args)}]\"\n            : string.Empty;\n\n        // Existing Dockerfiles are user-authored, so Aspire cannot safely assume that replacing\n        // their entrypoint with a package-manager script will work for the image shape.\n        // If the user provides an explicit container entrypoint above, honor it; otherwise fail\n        // instead of silently publishing an image that ignores the requested run script.\n        throw new DistributedApplicationException(\n            $\"JavaScript app resource '{resource.Name}' is configured to run script '{runScript.ScriptName}'{argsClause}, but publish is using the existing Dockerfile '{dockerfileBuildAnnotation.DockerfilePath}'. \" +\n            \"An existing Dockerfile entrypoint cannot be changed automatically from runScriptName or WithRunScript. \" +\n            \"Remove or rename the Dockerfile so Aspire can generate one, or call PublishAsDockerFile(...) and set the container entrypoint explicitly.\");\n    }\n\n    /// <summary>\n    /// Adds a Vite app to the distributed application builder.\n    /// </summary>\n    /// <param name=\"builder\">The <see cref=\"IDistributedApplicationBuilder\"/> to add the resource to.</param>\n    /// <param name=\"name\">The name of the Vite app.</param>\n    /// <param name=\"appDirectory\">The path to the directory containing the Vite app.</param>\n    /// <param name=\"runScriptName\">The name of the script that runs the Vite app. Defaults to \"dev\".</param>\n    /// <returns>A reference to the <see cref=\"IResourceBuilder{T}\"/>.</returns>\n    /// <ats-returns>The resource builder.</ats-returns>\n    /// <remarks>\n    /// <example>\n    /// The following example creates a Vite app using npm as the package manager.\n    /// <code lang=\"csharp\">","sourceCodeStart":1964,"sourceCodeEnd":2000,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.JavaScript/JavaScriptHostingExtensions.cs#L1964-L2000","documentation":"At publish time Aspire detected both a run-script configuration (WithRunScript/runScriptName) and a user-authored existing Dockerfile (DockerfileBuildAnnotation with a DockerfilePath). Aspire cannot safely rewrite the ENTRYPOINT of a hand-written Dockerfile to the package-manager script, so it throws instead of silently producing an image that ignores your run script.","triggerScenarios":"Calling WithRunScript (or passing runScriptName/args) on a JavaScript resource published via an existing Dockerfile without setting an explicit container entrypoint.","commonSituations":"Adding a Dockerfile to a project that previously relied on Aspire's generated Dockerfile; the default 'Dockerfile' filename in the project directory is now picked up; switching to a custom Dockerfile without removing run-script configuration.","solutions":["Remove or rename the existing Dockerfile so Aspire generates one that honors the run script.","Call PublishAsDockerFile(...) and set the container entrypoint explicitly (WithEntrypoint).","Remove the WithRunScript call if the Dockerfile's own entrypoint already runs the right command."],"exampleFix":"// before\nbuilder.AddViteApp(\"frontend\", \"./frontend\")\n    .PublishAsDockerFile(c => c.DockerfilePath = \"./Dockerfile\")\n    .WithRunScript(\"start\"); // conflicts\n// after\nbuilder.AddViteApp(\"frontend\", \"./frontend\")\n    .PublishAsDockerFile(c => c.DockerfilePath = \"./Dockerfile\")\n    .WithEntrypoint(\"./entrypoint.sh\"); // explicit entrypoint for existing Dockerfile","handlingStrategy":"validation","validationCode":"var usesExistingDockerfile = File.Exists(Path.Combine(resource.WorkingDirectory, \"Dockerfile\"));\nif (usesExistingDockerfile && usesRunScript)\n    throw new InvalidOperationException(\"Existing Dockerfile conflicts with WithRunScript; set an explicit entrypoint.\");","typeGuard":null,"tryCatchPattern":"try { builder.PublishAsDockerFile(); }\ncatch (DistributedApplicationException ex) when (ex.Message.Contains(\"existing Dockerfile\"))\n{\n    // rename/remove the Dockerfile or set an explicit entrypoint, then retry\n}","preventionTips":["Do not mix WithRunScript with a committed Dockerfile in the same project.","Name custom Dockerfiles explicitly and set an explicit entrypoint via PublishAsDockerFile.","Decide once per project: Aspire-generated Dockerfile (run scripts) or custom Dockerfile (explicit entrypoint)."],"tags":["aspire","javascript","dockerfile","publish","conflicting-options"],"backgroundTag":"conflicting-config-options","analyzedSha":"25830f84bd145686607ad00c057b3f84e2e51d43","analyzedAt":"2026-09-16T11:10:06.193Z","contentChangedAt":"2026-09-16T11:10:06.193Z","schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}