July 20, 2018 at 2:15 am
Hi there,
I would like to automate deployment of my Visual Studio SQL Project to some environments.
I suppose I need to generate a dacpac file from the project... but how do I do that?
I know I can generate it interactively in Visual Studio, but I don't want it interactive.
SQLPackage.exe can generate a dacpac file from a database... but not from a project... 🙁
So, how do I generate that dacpac file from a project (which is held in source control, of course)
Thanks
Eric
July 20, 2018 at 2:29 am
Hi,
There is a class called DacServices (in Microsoft.SqlServer.Dac namespace). It has a Publish method. Does it serve your purpose?
Do you want both Publish and deploy functionality to be handled?
July 20, 2018 at 3:12 am
Now, I think I understand the Publish side.
Once I have a dacpac file, I can publish it through SQLPackage.exe or Powershell.
I think that aspect is fine.
What I am after is to produce a dacpac file from the source code without using Visual Studio interactively.
I know "building" the project will generate a dacpac file (in bin or debug folder...)
I know I could "snapshot" the project and produce a dacpac file that way.
But the scenario I have in mind is that a service will monitor my source control.
On some trigger, it will create a copy of the project (from Source Control) and then build a dacpac from that.
We are thinking of using Jenkins to orchestrate all this but right now I am wondering how can I generate the dacpac file from the source code using some sort of scripting.
Kind of performing a project build from the command line I suppose
Hope I make sense...
PS: we are NOT using Visual Studio Team Services...
PPS: Is this a job for MSBuild?
July 20, 2018 at 5:19 am
Eric Mamet - Friday, July 20, 2018 3:12 AMNow, I think I understand the Publish side.
Once I have a dacpac file, I can publish it through SQLPackage.exe or Powershell.
I think that aspect is fine.What I am after is to produce a dacpac file from the source code without using Visual Studio interactively.
I know "building" the project will generate a dacpac file (in bin or debug folder...)
I know I could "snapshot" the project and produce a dacpac file that way.But the scenario I have in mind is that a service will monitor my source control.
On some trigger, it will create a copy of the project (from Source Control) and then build a dacpac from that.We are thinking of using Jenkins to orchestrate all this but right now I am wondering how can I generate the dacpac file from the source code using some sort of scripting.
Kind of performing a project build from the command line I supposeHope I make sense...
PS: we are NOT using Visual Studio Team Services...
PPS: Is this a job for MSBuild?
Yes, it's a job for MSBuild:
"%MSBuildExePath%" [filename].sln /t:rebuild /p:Configuration=Debug
Will rebuild all projects in your solution, using the Debug config. Modify to suit your requirements. Post back if you want the syntax for building just a single project in a solution.
The absence of evidence is not evidence of absence.
Martin Rees
You can lead a horse to water, but a pencil must be lead.
Stan Laurel
July 20, 2018 at 5:24 am
Brilliant.
If you have this off hand, could I ask the syntax for a single project, please?
July 20, 2018 at 5:36 am
Eric Mamet - Friday, July 20, 2018 5:24 AMBrilliant.If you have this off hand, could I ask the syntax for a single project, please?
This should do it:
"%MSBuildExePath%" [filename].sln /t:[projectname]:rebuild /p:Configuration=Debug
The absence of evidence is not evidence of absence.
Martin Rees
You can lead a horse to water, but a pencil must be lead.
Stan Laurel
July 20, 2018 at 5:38 am
Many thanks.
VERY helpful (as usual!)
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply