Deploying dacpac files via SQL Database Projects (.sqlproj)

lee5i3lee5i3 Posts: 48
This is in a "Deploy.ps1" in the root of my Database project
$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

Note:
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..
http://msdn.microsoft.com/en-us/library ... 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

Comments

  • Thanks for sharing Lee, very useful!
    Justin Caldicott
    Developer
    Redgate Software Ltd
  • Np,

    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!
Sign In or Register to comment.