|
1 | | -#requires -version 5 |
2 | | -param( |
3 | | - [switch]$Serve, |
4 | | - [switch]$Install, |
5 | | - [switch]$NoBuild |
6 | | -) |
7 | | -$ErrorActionPreference = 'Stop' |
8 | | -Set-StrictMode -Version 2 |
9 | | - |
10 | | -Import-Module -Force -Scope Local "$PSScriptRoot/../src/common.psm1" |
11 | | - |
12 | | -Push-Location "$PSScriptRoot/../" |
13 | | - |
14 | | -try { |
15 | | - |
16 | | - if (-not $NoBuild) { |
17 | | - exec dotnet build "$PSScriptRoot/samples/samples.sln" |
18 | | - } |
19 | | - |
20 | | - $buildRoot = "$PSScriptRoot/../.build/docs" |
21 | | - $targetDir = "$buildRoot/gh-pages" |
22 | | - mkdir -p $buildRoot -ErrorAction Ignore | Out-Null |
23 | | - |
24 | | - exec git worktree prune 2>&1 | out-null |
25 | | - if (-not (git worktree list --porcelain | Select-String 'gh-pages')) { |
26 | | - exec git fetch --quiet -u origin gh-pages:gh-pages |
27 | | - exec git worktree add $targetDir gh-pages 2>&1 | out-null |
28 | | - } |
29 | | - |
30 | | - $docfxVersion = '2.51.0' |
31 | | - $docfxRoot = "$buildRoot/packages/docfx.console/$docfxVersion" |
32 | | - $docfx = "$docfxRoot/tools/docfx.exe" |
33 | | - if (-not (Test-Path $docfx)) { |
34 | | - mkdir -p $docfxRoot -ErrorAction Ignore | Out-Null |
35 | | - $temp = (New-TemporaryFile).FullName + ".zip" |
36 | | - Invoke-WebRequest "https://www.nuget.org/api/v2/package/docfx.console/$docfxVersion" -O $temp |
37 | | - Expand-Archive $temp -DestinationPath $docfxRoot |
38 | | - Remove-Item $temp |
39 | | - if ($Install) { |
40 | | - exit 1 |
41 | | - } |
42 | | - } |
43 | | - |
44 | | - Push-Location $targetDir |
45 | | - exec git rm --quiet --force -r . |
46 | | - Pop-Location |
47 | | - |
48 | | - if (-not $NoBuild) { |
49 | | - exec dotnet build -c Release |
50 | | - } |
51 | | - |
52 | | - [string[]] $arguments = @() |
53 | | - try { |
54 | | - if ($Serve) { |
55 | | - $arguments += '--serve' |
56 | | - } |
57 | | - exec $docfx docs/docfx.json @arguments |
58 | | - } |
59 | | - finally { |
60 | | - Push-Location $targetDir |
61 | | - exec git config core.safecrlf false # suppress warning about CRLF |
62 | | - exec git add ./ 2>&1 | Out-Null |
63 | | - Pop-Location |
64 | | - } |
65 | | -} |
66 | | -finally { |
67 | | - Pop-Location |
68 | | -} |
| 1 | +#!/usr/bin/env pwsh |
| 2 | +param( |
| 3 | + [switch]$Serve, |
| 4 | + [switch]$Install, |
| 5 | + [switch]$NoBuild |
| 6 | +) |
| 7 | +$ErrorActionPreference = 'Stop' |
| 8 | +Set-StrictMode -Version 2 |
| 9 | + |
| 10 | +if (-not (Test-Path variable:\IsCoreCLR)) { |
| 11 | + $IsWindows = $true |
| 12 | +} |
| 13 | + |
| 14 | +Import-Module -Force -Scope Local "$PSScriptRoot/../src/common.psm1" |
| 15 | + |
| 16 | +Push-Location "$PSScriptRoot/../" |
| 17 | + |
| 18 | +try { |
| 19 | + |
| 20 | + if (-not $NoBuild) { |
| 21 | + exec dotnet build "$PSScriptRoot/samples/samples.sln" |
| 22 | + } |
| 23 | + |
| 24 | + $buildRoot = "$PSScriptRoot/../.build/docs" |
| 25 | + $targetDir = "$buildRoot/gh-pages" |
| 26 | + mkdir -p $buildRoot -ErrorAction Ignore | Out-Null |
| 27 | + |
| 28 | + exec git worktree prune 2>&1 | out-null |
| 29 | + if (-not (git worktree list --porcelain | Select-String 'gh-pages')) { |
| 30 | + exec git fetch --quiet -u origin gh-pages:gh-pages |
| 31 | + exec git worktree add $targetDir gh-pages 2>&1 | out-null |
| 32 | + } |
| 33 | + |
| 34 | + $docfxVersion = '2.56.6' |
| 35 | + $docfxRoot = "$buildRoot/packages/docfx.console/$docfxVersion" |
| 36 | + $docfx = "$docfxRoot/tools/docfx.exe" |
| 37 | + if (-not (Test-Path $docfx)) { |
| 38 | + mkdir -p $docfxRoot -ErrorAction Ignore | Out-Null |
| 39 | + $temp = (New-TemporaryFile).FullName + ".zip" |
| 40 | + Invoke-WebRequest "https://www.nuget.org/api/v2/package/docfx.console/$docfxVersion" -O $temp |
| 41 | + Expand-Archive $temp -DestinationPath $docfxRoot |
| 42 | + Remove-Item $temp |
| 43 | + if ($Install) { |
| 44 | + exit 1 |
| 45 | + } |
| 46 | + } |
| 47 | + |
| 48 | + Push-Location $targetDir |
| 49 | + exec git reset --hard |
| 50 | + exec git rm --quiet --force -r . |
| 51 | + Pop-Location |
| 52 | + |
| 53 | + if (-not $NoBuild) { |
| 54 | + exec dotnet build -c Release |
| 55 | + } |
| 56 | + |
| 57 | + [string[]] $arguments = @() |
| 58 | + try { |
| 59 | + if ($Serve) { |
| 60 | + $arguments += '--serve' |
| 61 | + } |
| 62 | + |
| 63 | + if ($IsWindows) { |
| 64 | + exec $docfx docs/docfx.json @arguments |
| 65 | + } |
| 66 | + else { |
| 67 | + exec mono $docfx docs/docfx.json @arguments |
| 68 | + } |
| 69 | + } |
| 70 | + finally { |
| 71 | + Push-Location $targetDir |
| 72 | + exec git config core.safecrlf false # suppress warning about CRLF |
| 73 | + exec git add ./ 2>&1 | Out-Null |
| 74 | + Pop-Location |
| 75 | + } |
| 76 | +} |
| 77 | +finally { |
| 78 | + Pop-Location |
| 79 | +} |
0 commit comments