Skip to content

Commit

Permalink
deployment scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
asadsahi committed Nov 15, 2017
1 parent e7575f9 commit 42688ee
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
"compodoc.jpg": true,
"Properties": true,
".awcache": true,
"extra": true,
"deploy.azure.ps1": true,
"*.PublishSettings": true,
"logs": true,
"npm-debug.log.*": true,
Expand Down
2 changes: 0 additions & 2 deletions AspNetCoreSpa.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,6 @@
</Target>

<Target Name="PublishRunWebpack" AfterTargets="ComputeFilesToPublish">
<!-- As part of publishing, ensure the JS resources are freshly built in production mode -->
<Exec Command="npm install" />
<Exec Command="node node_modules/webpack/bin/webpack.js --config webpack.config.vendor.js --env.prod" />
<Exec Command="node node_modules/webpack/bin/webpack.js --env.prod" />

Expand Down
65 changes: 65 additions & 0 deletions deploy.azure.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,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
11 changes: 11 additions & 0 deletions extra/app_offline.htm
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE>
<html>

<head>
<title>Under Construction</title>
</head>
<bodyd>
<p>This page is under construction. Please come back soon!</p>
</body>

</html>

0 comments on commit 42688ee

Please sign in to comment.