Skip to content

Instantly share code, notes, and snippets.

@wurmr
Created March 28, 2014 21:14
Show Gist options
  • Save wurmr/9843120 to your computer and use it in GitHub Desktop.
Save wurmr/9843120 to your computer and use it in GitHub Desktop.
function Get-MSWebDeployInstallPath()
{
return (get-childitem "HKLM:\SOFTWARE\Microsoft\IIS Extensions\MSDeploy" | Select -last 1).GetValue("InstallPath")
}
function Load-Configuration
{
$webDeploy = Get-MSWebDeployInstallPath
$env:Path += (";" + $webDeploy)
}
try
{
Load-Configuration
$Depacs = (Get-ChildItem *.dacpac | Select BaseName, FullName)
foreach ($depac in $Depacs)
{
$destinationDatabase = $OctopusParameters["DbServer"];
$depacFile = ($depac | Select -ExpandProperty FullName)
$databaseName = ($depac | Select -ExpandProperty BaseName)
$Args = @('-Verb:Sync',
"-Source:dbDacFx='$depacFile'",
"-Dest:dbDacFx='Server=$destinationDatabase;Database=$databaseName;Trusted_Connection=True'")
Write-Host $Args;
& 'msdeploy.exe' $Args
}
}
catch
{
Write-Host $_.Exception
throw $_.Exception
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment