In my recent escapades into the murky world of deploying dacpac files into a SQL DB, it occurred to me that the location of the SQLPackage file has largely been a cut-and-paste from the web. Apparently, the registry key that holds this information is: HKLM\SOFTWARE\Microsoft\Microsoft SQL Server\Data-Tier Application Framework\InstallLocation. Here’s some code to retrieve it using C#:
private static void GetSQLDacTools()
{
using (RegistryKey hklm = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, \_registryView))
{
RegistryKey rk = hklm.OpenSubKey(
@"SOFTWARE\\Microsoft\\Microsoft SQL Server\\Data-Tier Application Framework\\InstallLocation");
if (rk == null)
{
Console.WriteLine("Sql Data Tools Not Installed");
return;
}
string path = rk.GetValue(string.Empty).ToString();
Console.WriteLine(path);
}
}