Skip to content

Commit 2db90e4

Browse files
committed
websites/site/site.ps1: Use Set-Location to ensure dotnet tool commands are run in the repo root in CI
1 parent 721f792 commit 2db90e4

1 file changed

Lines changed: 20 additions & 11 deletions

File tree

websites/site/site.ps1

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,11 @@ if ($Clean) {
4646
# install docfx tool
4747
$PreviousLocation = Get-Location
4848
Set-Location $RepoRoot
49-
dotnet tool restore
50-
Set-Location $PreviousLocation
49+
try {
50+
dotnet tool restore
51+
} finally {
52+
Set-Location $PreviousLocation
53+
}
5154

5255
# delete anything that already exists
5356
if ($Clean) {
@@ -62,14 +65,20 @@ $DocFxJson = Join-Path -Path $SiteFolder "docfx.json"
6265
$DocFxLog = Join-Path -Path $SiteFolder "obj\docfx.log"
6366

6467
if($?) {
65-
if ($ServeDocs -eq $false) {
66-
# build the output
67-
Write-Host "Building docs..."
68-
& dotnet tool run docfx build $DocFxJson -l "$DocFxLog" --logLevel $LogLevel
69-
}
70-
else {
71-
# build + serve (for testing)
72-
Write-Host "starting website..."
73-
& dotnet tool run docfx $DocFxJson --serve --port $StagingPort
68+
$PreviousLocation = Get-Location
69+
Set-Location $RepoRoot
70+
try {
71+
if ($ServeDocs -eq $false) {
72+
# build the output
73+
Write-Host "Building docs..."
74+
& dotnet tool run docfx build $DocFxJson -l "$DocFxLog" --logLevel $LogLevel
75+
}
76+
else {
77+
# build + serve (for testing)
78+
Write-Host "starting website..."
79+
& dotnet tool run docfx $DocFxJson --serve --port $StagingPort
80+
}
81+
} finally {
82+
Set-Location $PreviousLocation
7483
}
7584
}

0 commit comments

Comments
 (0)