You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Azure DevOps中SqlAzureDacpacDeployment找不到Dacpac文件报错求助

Troubleshooting "File not found" error for SqlAzureDacpacDeployment task in Azure DevOps

Let’s break down why your SqlAzureDacpacDeployment task can’t locate the AzureSQL.dacpac file, and walk through actionable fixes step by step:

1. Confirm the PublishBuildArtifacts task is publishing the correct file

First, let’s verify the dacpac actually exists in the path you’re publishing from. Add a quick script task right before your PublishBuildArtifacts step to list all files in that directory:

- script: dir $(Build.Repository.LocalPath)/AzureSQL/bin/Release/
  displayName: 'Check if Dacpac exists in release folder'

If the output doesn’t show AzureSQL.dacpac, your PathtoPublish path might be wrong—your project could be building to a subfolder (like net6.0 or a project-specific directory) under the Release folder.

Also, check the actual artifacts in Azure DevOps: after the build runs, go to the Artifacts tab of your pipeline run, open the drop artifact, and confirm if AzureSQL.dacpac is in the root. If it’s nested inside a subfolder, update your deployment task’s path to match (e.g., $(Pipeline.Workspace)/drop/MySubfolder/AzureSQL.dacpac).

2. Add an Artifact download step (if using separate stages/jobs)

If your publish step is in a Build stage and deployment is in a separate Release stage (or even a different job in the same pipeline), you need to explicitly download the artifact to $(Pipeline.Workspace) first. Add this task right before SqlAzureDacpacDeployment:

- task: DownloadPipelineArtifact@2
  inputs:
    buildType: 'current' # Use a specific build ID if referencing a different pipeline
    artifactName: 'drop'
    targetPath: '$(Pipeline.Workspace)/drop'

Without this step, $(Pipeline.Workspace)/drop will be empty, which is exactly why you’re seeing the "file not found" error.

3. Use the staging directory directly (for same-job deployment)

If both publish and deployment are in the same job, you don’t need to rely on $(Pipeline.Workspace) at all. The PublishBuildArtifacts task copies files to $(Build.ArtifactStagingDirectory) before publishing them. You can point your deployment task directly to this path instead:

- task: SqlAzureDacpacDeployment@1
  inputs:
    # ... keep your existing settings ...
    DacpacFile: '$(Build.ArtifactStagingDirectory)/AzureSQL.dacpac'

This skips any potential issues with artifact downloading and path mismatches entirely.

4. Double-check filename case and typos

Windows is case-insensitive, but Azure DevOps agents (especially Linux-based ones) might enforce case sensitivity. Make sure the filename in your deployment task exactly matches the actual file (e.g., AzureSQL.dacpac vs azureSQL.dacpac).

To confirm the exact structure of your drop folder, add this script right before the deployment task:

- script: dir $(Pipeline.Workspace)/drop /s
  displayName: 'List all files in downloaded drop folder'

This will show you every file and its full path, so you can adjust DacpacFile to match exactly.

内容的提问来源于stack exchange,提问作者Kenny_I

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.08 18:12:30