11

I'm developing a .Net-application that would deploy a dacpac on a client machine. For that purpose I would require SqlPackage.exe to deploy the dacpac. I need a absolute path of SqlPackage.exe to make my application work irrespective of client's machine configuration.

Can you please help me to achieve this.

Thanks, Yogesh

3
  • 2
    An alternative to sqlpackage is the Microsoft.SqlServer.Dac package, which allows you to programmatically deploy DACPACs. May 17, 2017 at 8:50
  • This is the option I guess I would require to consider. Thanks Jeroen May 17, 2017 at 9:09
  • 1
    I realize that this question is a little old now, but just to point out that the suggested NuGet package doesn't look like it is (or ever really was) maintained. There are only two versions and the latest is over five years old.
    – jamesmus
    Oct 30, 2019 at 14:51

3 Answers 3

15

You can install sqlpackage.exe in two ways:

  • SSDT (SQL Server Data Tools): the location will be VS Install Directory\Common7\IDE\Extensions\Microsoft\SQLDB\DAC\{SqlVersion}, VS install directory: C:\Program Files (x86)\Microsoft Visual Studio {VsVersion}.0
  • SQL Server Management Studio (SSMS) and the Dac Framework MSI: C:\Program Files (x86)\Microsoft SQL Server\{SqlVersion}\Dac\bin

SqlVersion is 140 for the SQL Server 2017, 130 for the SQL Server 2016 etc.

VsVersion is 14 for Visual Studio 2017

More details in this question.

11
  • Thanks David. Actually we are executing sqlpackage.exe from batch file, so we need a exact location of sqlpackage.exe in client machine. Client may have installed it in C: or D: or any drive. We cant keep the path static. May 17, 2017 at 8:32
  • 1
    Actually, I would just copy the sqlpackage.exe file and all of it's dependencies and deploy it with my batch file. So my clients do not have to install anything, I do not have to find the correct path and everyone is happy :) May 17, 2017 at 8:42
  • but I guess we are not allowed to redistribute Microsoft assemblies and ship as a part of our product to client. May 17, 2017 at 9:00
  • 2
    This does not work. I have installed SSDT with all the options enabled and the Extensions folder is not there. edit: The VS2017 install directory has changed, which is not documented anywhere that I can find - it is now at C:\Program Files (x86)\Microsoft Visual Studio\2017
    – Tom W
    Dec 7, 2017 at 13:28
  • 1
    Use vswhere.exe to help find Visual Studio instances. This could help you find sqlpackage.exe. https://github.com/Microsoft/vswhere
    – DaleyKD
    Dec 27, 2017 at 19:05
3

To find sqlpackage programmatically you can make use of the TaskModuleSqlUtility powershell library. Either run the Invoke-DacpacDeployment from the powershell script (sorry not C#) or make use of Get-SqlPackageOnTargetMachine function for sqlpackage.exe path.

Search for tests in github for samples.

1

you also can download from microsoft doc site

https://learn.microsoft.com/en-us/sql/tools/sqlpackage-download?view=sql-server-ver15&viewFallbackFrom=sql-server-ver17

and check your version of sql and get correct instructions

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.