forked from fullstackproltd/AspNetCoreSpa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.azure.ps1
65 lines (54 loc) · 2.07 KB
/
deploy.azure.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
$webdeploy = "C:\Program Files (x86)\IIS\Microsoft Web Deploy V3\msdeploy.exe"
$location = Get-Location | Select-Object $_.Path
$packOutput = Join-Path $location "bin\Release\netcoreapp2.0\publish"
$app_offline = Join-Path $location "extra\app_offline.htm"
$iisApp = "aspnetcorespa"
$computerName = "https://aspnetcorespa.scm.azurewebsites.net/msdeploy.axd"
$username = "\`$aspnetcorespa"
$password = "your password here"
function DeletePublishFolder()
{
if (Test-Path $packOutput)
{
WriteInfo "Removing publish folder..."
Remove-Item -Force -Recurse $packOutput
}
}
function Publish()
{
dotnet publish -c Release
WriteSuccess "Published!"
}
function Deploy()
{
# Deploy app_offline file
& $webdeploy -verb:sync -source:contentPath=$app_offline -dest:contentPath=$iisApp/app_offline.htm,ComputerName=$computerName,UserName=$username,Password=$password,IncludeAcls="False",AuthType="Basic" -retryAttempts:5 -allowUntrusted
# Delete wwwroot folder
& $webdeploy -verb:delete -dest:contentPath=$iisApp/wwwroot,ComputerName=$computerName,UserName=$username,Password=$password,IncludeAcls="False",AuthType="Basic" -retryAttempts:5 -allowUntrusted
# Deploy published folder
& $webdeploy -verb:sync -source:IisApp=$packOutput -dest:IisApp=$iisApp,ComputerName=$computerName,UserName=$username,Password=$password,IncludeAcls="False",AuthType="Basic" -enableRule:DoNotDeleteRule -disablerule:BackupRule -enableLink:contentLibExtension -retryAttempts:5 -allowUntrusted
# Delete app_offline file
& $webdeploy -verb:delete -dest:contentPath=$iisApp/app_offline.htm,ComputerName=$computerName,UserName=$username,Password=$password,IncludeAcls="False",AuthType="Basic" -retryAttempts:5 -allowUntrusted
if ($LASTEXITCODE -ne 0)
{
WriteFailed "Failed with code $LASTEXITCODE. Exiting..."
Exit
}
WriteSuccess "Deployment succeeded!"
}
function WriteFailed($text)
{
Write-Host $text -ForegroundColor Red
}
function WriteInfo($text)
{
Write-Host $text -ForegroundColor Cyan
}
function WriteSuccess($text)
{
Write-Host $text -ForegroundColor Green
}
# -----------
DeletePublishFolder
Publish
Deploy