Deploying dacpac files via SQL Database Projects (.sqlproj)

Share your PowerShell scripts for Deployment Manager

Deploying dacpac files via SQL Database Projects (.sqlproj)

Postby lee5i3 » Wed Jul 10, 2013 10:02 pm

This is in a "Deploy.ps1" in the root of my Database project

Code: Select all
$path = Split-Path -Parent $MyInvocation.MyCommand.Path

& "C:\\Program Files (x86)\\Microsoft SQL Server\\110\\DAC\\bin\\SqlPackage.exe" /sf:$path"\\bin\\Release\\MyProject.Database.dacpac" /a:publish /TargetConnectionString:$DBConnectionString /p:VerifyDeployment=true /p:CreateNewDatabase=$CreateNewDatabase | Out-Default

You will need to add a CreateNewDatabase variable so database can be recreated depending on the environment.. eg. Development re-creates DB but not production

There is a lot more options available as well.. ... 03%29.aspx

This is definitely not perfect, as I want to make it a bit more flexible on the paths, but it works great on my environment
Posts: 38
Joined: Fri Jul 16, 2010 8:26 pm

Postby justin.caldicott » Thu Jul 11, 2013 9:49 am

Thanks for sharing Lee, very useful!
Justin Caldicott
Redgate Software Ltd
Posts: 57
Joined: Wed Apr 20, 2011 4:42 pm

Postby lee5i3 » Thu Jul 11, 2013 5:12 pm


This made Deployment Manager extremely useful,
I am able to have this setup with TeamCity and TFS.

So ZERO user interaction is required to deploy to our development server, which is hosted in a Windows Azure VM, all we need to do is check-in code, and it automatically deploys not only our code, as well as any database changes (which is a SQL Project within VS)

And when we want our sprints released, all we do is redeploy the last development release to next environment.

I'm totally sold on this!
Posts: 38
Joined: Fri Jul 16, 2010 8:26 pm

Return to Deployment Manager PowerShell Scripts

Who is online

Users browsing this forum: No registered users and 0 guests