-
-
Notifications
You must be signed in to change notification settings - Fork 163
Expand file tree
/
Copy pathbuild-dev.ps1
More file actions
63 lines (47 loc) · 1.63 KB
/
build-dev.ps1
File metadata and controls
63 lines (47 loc) · 1.63 KB
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
#Requires -Version 7.3
# This script builds the documentation website, starts a web server and opens the site in your browser. Intended for local development.
param(
# Specify -NoBuild to skip code build and examples generation. This runs faster, so handy when only editing Markdown files.
[switch] $NoBuild=$False
)
function VerifySuccessExitCode {
if ($LastExitCode -ne 0) {
throw "Command failed with exit code $LastExitCode."
}
}
function EnsureHttpServerIsInstalled {
if ((Get-Command "npm" -ErrorAction SilentlyContinue) -eq $null) {
throw "Unable to find npm in your PATH. please install Node.js first."
}
npm list --depth 1 --global httpserver >$null
if ($LastExitCode -eq 1) {
npm install -g httpserver
}
}
EnsureHttpServerIsInstalled
VerifySuccessExitCode
if (-Not $NoBuild -Or -Not (Test-Path -Path _site)) {
Remove-Item _site\* -Recurse -ErrorAction Ignore
dotnet build .. --configuration Release
VerifySuccessExitCode
Invoke-Expression ./generate-examples.ps1
} else {
Remove-Item _site\* -Recurse -ErrorAction Ignore
}
dotnet tool restore
VerifySuccessExitCode
dotnet docfx ./docfx.json --warningsAsErrors true
VerifySuccessExitCode
Copy-Item -Force home/*.html _site/
Copy-Item -Force home/*.ico _site/
New-Item -Force _site/styles -ItemType Directory | Out-Null
Copy-Item -Force -Recurse home/assets/* _site/styles/
cd _site
$webServerJob = httpserver &
Start-Process "http://localhost:8080/"
cd ..
Write-Host ""
Write-Host "Web server started. Press Enter to close."
$key = [Console]::ReadKey()
Stop-Job -Id $webServerJob.Id
Get-job | Remove-Job -Force