|
1 |
| -# This script assumes that you have already installed docfx and httpserver. |
| 1 | +#Requires -Version 7.0 |
| 2 | + |
| 3 | +# This script builds the documentation website, starts a web server and opens the site in your browser. Intended for local development. |
| 4 | +# It is assumed that you have already installed docfx and httpserver. |
2 | 5 | # If that's not the case, run the next commands:
|
3 | 6 | # choco install docfx -y
|
4 | 7 | # npm install -g httpserver
|
5 | 8 |
|
6 |
| -Remove-Item _site -Recurse -ErrorAction Ignore |
| 9 | +param( |
| 10 | + # Specify -NoBuild to skip code build and examples generation. This runs faster, so handy when only editing Markdown files. |
| 11 | + [switch] $NoBuild=$False |
| 12 | +) |
| 13 | + |
| 14 | +function VerifySuccessExitCode { |
| 15 | + if ($LastExitCode -ne 0) { |
| 16 | + throw "Command failed with exit code $LastExitCode." |
| 17 | + } |
| 18 | +} |
| 19 | + |
| 20 | +if (-Not $NoBuild -Or -Not (Test-Path -Path _site)) { |
| 21 | + Remove-Item _site -Recurse -ErrorAction Ignore |
7 | 22 |
|
8 |
| -dotnet build .. --configuration Release |
9 |
| -Invoke-Expression ./generate-examples.ps1 |
| 23 | + dotnet build .. --configuration Release |
| 24 | + VerifySuccessExitCode |
| 25 | + |
| 26 | + Invoke-Expression ./generate-examples.ps1 |
| 27 | +} |
10 | 28 |
|
11 | 29 | docfx ./docfx.json
|
12 |
| -Copy-Item home/*.html _site/ |
13 |
| -Copy-Item home/*.ico _site/ |
14 |
| -Copy-Item -Recurse home/assets/* _site/styles/ |
| 30 | +VerifySuccessExitCode |
| 31 | + |
| 32 | +Copy-Item -Force home/*.html _site/ |
| 33 | +Copy-Item -Force home/*.ico _site/ |
| 34 | +Copy-Item -Force -Recurse home/assets/* _site/styles/ |
15 | 35 |
|
16 | 36 | cd _site
|
17 | 37 | $webServerJob = httpserver &
|
|
0 commit comments