-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun.ps1
74 lines (59 loc) · 2.1 KB
/
run.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
param(
[string] $Action
)
# Import utility functions to help find vswhere and sql package
. ".\SqlPackageOnTargetMachines.ps1"
function Get-MsBuildPath {
Write-Host -NoNewline "Locating MSBuild..."
$path = & (Find-VSWhere) -find MSBuild\**\Bin\MSBuild.exe | select-object -first 1
If (-not (Test-Path $path)) {
Write-Error "Unable not locate MSBuild. Is Visual Studio 2017 (15.2) or later installed?"
Exit
}
Write-Host " done."
return $path;
}
function Get-SqlPackagePath {
Write-Host -NoNewline "Locating SqlPackage..."
$path = Get-SqlPackageOnTargetMachine
If (-not (Test-Path $path)) {
Write-Error "Unable not locate SqlPackage. You can acquire SqlPackage from https://docs.microsoft.com/en-us/sql/tools/sqlpackage-download"
Exit
}
Write-Host " done."
return $path;
}
function Start-Environment {
Write-Host "Starting docker containers"
docker-compose --file .\docker\docker-compose.yml up --detach
Write-Host "Building DACPAC"
& (Get-MsBuildPath) .\src\Sql\Sql.sqlproj /p:configuration="Release"
Write-Host "Publishing Database"
& (Get-SqlPackagePath) /Action:Publish /SourceFile:".\src\Sql\bin\Release\Sql.dacpac" /TargetConnectionString:"Server=localhost,1436;Database=sample;User Id=sa;Password=mys@passw0rd;" /p:BlockOnPossibleDataLoss=False
}
function Start-Build {
Write-Host "Starting build"
dotnet build .\src\Sample.sln
}
function Stop-Environment {
Write-Host "Stopping and removing docker containers"
docker-compose --file .\docker\docker-compose.yml down
}
function Start-Integration-Tests {
Write-Host "Starting integration tests"
dotnet test --no-build .\src\IntegrationTests\IntegrationTests.csproj
}
switch ( $Action ) {
start { Start-Environment }
stop { Stop-Environment }
build { Start-Build }
integration-tests { Start-Integration-Tests }
default {
if($Action -eq '') {
Start-Environment
Start-Build
Start-Integration-Tests
} else {
Write-Error "'$($Action)' is an in valid action. Did you mean 'start', 'stop', 'seed', 'build', 'unit-tests', 'integration-tests' or 'performance-tests'?" }
}
}