Azure Devops Unable to find the location of Dac Framework (SqlPackage.exe) from registry on machine
Asked Answered
B

3

9

I am using azure devops to deploy a database to a virtual machine via deployment groups. I have verified that the system variable path is correct and also that it works when I log into the virtual machine and try to run it with powershell. I'm not sure why it's not finding it. Any thoughts? Thanks

Beasley answered 28/4, 2020 at 19:44 Comment(1)
Which agent and task you are using? And have you tried to specify the path of SqlPackage.exe in the agent? github.com/Microsoft/azure-pipelines-tasks/issues/4362Mobile
Z
25

If someone is looking to resolve this on Azure Release Pipelines and on-prem servers, installing the SSDT from Visual Studio Installer did not help. Had to install the DAC Framework.msi that is mentioned on this link: https://learn.microsoft.com/en-us/sql/tools/sqlpackage-download?view=sql-server-ver15&viewFallbackFrom=sql-server-ver17

enter image description here

After installing it from here, the Microsoft SQL Server DAC item showed up in Registry (on Win 2019 server) and then the release pipeline was able to find the SQLPackage.exe file otherwise even though the sqlpackage.exe file was available and SSDT tools from Visual Studio build tools 2017 and 2019 were there but still there was no registry entry (weirdly). Installing this msi fixed that. Hope it saves someone time.

Zsigmondy answered 3/12, 2020 at 19:46 Comment(1)
If you are trying to use the C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\Extensions\Microsoft\SQLDB\DAC\SqlPackage.exe try to download the package as @Shiva Naru says and point to folder that the installations creates "C:\Program Files\Microsoft SQL Server\160\DAC\bin\SqlPackage.exe" instead. That solved my problemWashin
P
0

you can use this PowerShell script to locate the path of SqlPackage.exe

https://www.powershellgallery.com/packages/PublishDacPac/1.0.2.2902/Content/public%5CGet-SqlPackagePath.ps1

Philipson answered 28/4, 2020 at 23:54 Comment(0)
C
0

I was able to resolve this problem, by adding a Powershell task to my pipeline

 - task: PowerShell@2
    displayName: 'Install SqlPackage.exe'
    inputs:
      targetType: 'inline'
      script: |
      $installerUrl = 'https://download.microsoft.com/download/b/3/0/b30aa612-be4e-46d5-9974-f50cc5e79da7/x64/DacFramework.msi'
      $installerPath = Join-Path -Path $env:Agent_TempDirectory -ChildPath 'DacFramework.msi'
      Invoke-WebRequest -Uri $installerUrl -OutFile $installerPath
      Start-Process -FilePath 'msiexec.exe' -ArgumentList "/i `"$installerPath`" /quiet /qn /norestart" -Wait
      if (Get-Command 'SqlPackage.exe' -ErrorAction SilentlyContinue) {
      Write-Host "DacFx installed successfully."
      } else {
      Write-Error "DacFx installation failed."
      exit 1
      }

This way of installing the SqlPackage.exe not only makes sure, that the package is there, but also updates all the required registry references. Thanks to that, the next steps of your pipeline will know where the package is.

Coppery answered 13/9, 2024 at 11:37 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.