Get the executable location of SQLPackage

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");

                string path = rk.GetValue(string.Empty).ToString();


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.