Search code examples
sql-server-data-toolsdacsqlpackage

Getting SqlServer Dac assembly file path on target machine when using DacServices to deploy


I'm invoking DacServices APIs to deploy DACPACs, which requires an assembly reference of Microsoft.SqlServer.Dac. The target machine on which i run my installer could have SSDT/SQL installed on D drive or maybe a higher version of SQLServer could be installed.

How do i dynamically get the Microsoft.SqlServer.Dac assembly file path on target machine when using DacServices to deploy (We'd have the same issue if we were to use SqlPackage.exe since I need to dynamically find out the 120/DAC/bin or 130/DAC/bin folder on the target where i run my installer)?

Or if anyone can suggest any other solution to this issue so that the same exe can work of different machines/environments, that would be great.


Solution

  • Modern versions of DacFramework.msi note the install location in the registry under HKLM\SOFTWARE\Microsoft\Microsoft SQL Server\Data-Tier Application Framework\InstallLocation.

    However, it would be better to include the DacFramework assemblies in your installer and call that code. The Data-Tier Application Framework is licensed by Microsoft as "redistributable" code.