{"record":{"id":"83febbc177006171","repo":"microsoft/aspire","slug":"bicep-file-not-found-at-biceppath-ensure-the-publish-step","errorCode":null,"errorMessage":"Bicep file not found at '{bicepPath}'. Ensure the publish step completed successfully before deploying.","messagePattern":"Bicep file not found at '(.+?)'\\. Ensure the publish step completed successfully before deploying\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.Radius/Publishing/RadiusDeploymentPipelineStep.cs","lineNumber":530,"sourceCode":"\n        // Detect rad CLI availability\n        var radAvailable = await DetectRadCliAsync(cancellationToken).ConfigureAwait(false);\n        if (!radAvailable)\n        {\n            logger.LogError(\"The 'rad' CLI was not found on PATH. Install it from {InstallUrl}\", RadInstallUrl);\n            throw CreateRadCliNotFoundException();\n        }\n\n        logger.LogInformation(\"rad CLI detected on PATH for environment '{EnvironmentName}'\", _environment.Name);\n\n        // Resolve the output directory where Bicep was generated\n        var outputDir = PublishingContextUtils.GetEnvironmentOutputPath(context, _environment);\n        var bicepPath = Path.Combine(outputDir, \"app.bicep\");\n\n        if (!File.Exists(bicepPath))\n        {\n            logger.LogError(\"Bicep file not found at {BicepPath}. Ensure the publish step completed successfully.\", bicepPath);\n            throw new InvalidOperationException(\n                $\"Bicep file not found at '{bicepPath}'. Ensure the publish step completed successfully before deploying.\");\n        }\n\n        logger.LogInformation(\"Starting rad deploy with Bicep file '{BicepPath}'\", bicepPath);\n\n        // Declared outside the try so the finally can always clean up the temp secrets file, even\n        // if resolving/writing it (below) fails partway.\n        string? parametersFilePath = null;\n\n        var deployTask = await context.ReportingStep.CreateTaskAsync(\n            $\"Deploying Radius environment '{_environment.Name}' via rad deploy...\",\n            cancellationToken).ConfigureAwait(false);\n\n        try\n        {\n            // Resolve secret/parameter values at deploy time and write them to an owner-only\n            // temporary ARM JSON parameters file. This supplies the `@secure()` Bicep params\n            // emitted by publish without inlining secrets into the artifact or exposing them on the","sourceCodeStart":512,"sourceCodeEnd":548,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.Radius/Publishing/RadiusDeploymentPipelineStep.cs#L512-L548","documentation":"Before running `rad deploy`, RadiusDeploymentPipelineStep expects the publish phase to have produced app.bicep under the environment's output directory. If the file does not exist, deployment cannot proceed, so the step logs and throws this InvalidOperationException.","triggerScenarios":"Calling deploy (ExecuteAsync on RadiusDeploymentPipelineStep) when the publish step that generates app.bicep did not run, failed midway, or wrote to a different output directory (e.g. PublishingContextUtils.GetEnvironmentOutputPath points elsewhere).","commonSituations":"Running only the deploy step in a custom pipeline without running publish first; a prior publish step failed and the pipeline continued; cleaned or deleted artifacts/ output between steps; misconfigured environment output path.","solutions":["Run the publish step before deploy so app.bicep is generated.","Check the earlier publish step's logs for the real failure and fix it.","Verify the environment's output directory (artifacts path) matches where publish wrote the Bicep; do not delete artifacts between publish and deploy."],"exampleFix":"// before (pipeline setup)\nawait pipeline.RunAsync(deployStep, ...);   // publish never ran\n\n// after\nawait pipeline.RunAsync(publishStep, ...);\nawait pipeline.RunAsync(deployStep, ...);","handlingStrategy":"validation","validationCode":"// Ensure publish ran and produced the Bicep before deploying\nvar bicepPath = Path.Combine(outputDir, \"app.bicep\");\nif (!File.Exists(bicepPath))\n    throw new InvalidOperationException($\"Publish must run before deploy; missing {bicepPath}\");","typeGuard":null,"tryCatchPattern":"try { await deployStep.ExecuteAsync(context, ct); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"Bicep file not found\"))\n{\n    logger.LogError(ex, \"app.bicep missing — the publish step likely failed or was skipped; inspect publish logs.\");\n}","preventionTips":["Always run the publish step before the deploy step in the pipeline","Check the publish step's exit/logs before starting deploy","Do not clean the artifacts/output directory between publish and deploy","Verify the environment's output path configuration matches where publish writes"],"tags":["radius","bicep","file-not-found","deploy","publish-pipeline"],"backgroundTag":"file-not-found","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"}