-
-
Notifications
You must be signed in to change notification settings - Fork 171
/
SQLWATCH-Deploy.ps1
35 lines (31 loc) · 1.35 KB
/
SQLWATCH-Deploy.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#PS script to deploy SQLWATCH during appveyor builds
param(
[string]$SqlInstance,
[string]$Database,
[string]$Dacpac,
[switch]$RunAsJob
)
$DACPACPath = Get-ChildItem -Recurse -Filter $Dacpac | Sort-Object LastWriteTime -Descending | Select-Object -First 1
if ($RunAsJob) {
<# Appveyor would often return:
Receive-Job : There is an error processing data from the background process.
Error reported: Cannot process an element with node type "Text". Only Element and EndElement node types are supported.
https://stackoverflow.com/questions/24689505/start-process-nonewwindow-within-a-start-job
#>
$JobName = "Deploying " + $SqlInstance
Start-Job -Name $JobName -ScriptBlock {
#param([string]$arguments)
param (
[string]$SqlInstance,
[string]$Database,
[string]$Dacpac
)
sqlpackage.exe /a:Publish /sf:"$($Dacpac)" /tdn:$($Database) /tsn:$($SqlInstance)
#Start-Process sqlpackage.exe -ArgumentList $arguments -WindowStyle Hidden -PassThru -Wait
} -ArgumentList $SqlInstance, $Database, $($DACPACPath.FullName) | Format-Table
#} -ArgumentList "/a:Publish /sf:`"$($DACPACPath.FullName)`" /tdn:$Database /tsn:$SqlInstance"
}
else {
sqlpackage.exe /a:Publish /sf:"$($DACPACPath.FullName)" /tdn:$Database /tsn:$SqlInstance
exit $LASTEXITCODE
}