Skip to content

Commit

Permalink
Use dotnet local tool for docfx in site.ps1
Browse files Browse the repository at this point in the history
  • Loading branch information
paulirwin committed Oct 10, 2024
1 parent c98281a commit 7d74464
Showing 1 changed file with 6 additions and 24 deletions.
30 changes: 6 additions & 24 deletions websites/site/site.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ param (
$StagingPort = 8081
)

$DocFxVersion = "2.77.0" # Required DocFx version

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

$PSScriptFilePath = (Get-Item $MyInvocation.MyCommand.Path).FullName
Expand All @@ -46,26 +44,10 @@ if ($Clean) {
}

# install docfx tool
$InstallDocFx = $false
try {
$InstalledDocFxVersion = (& docfx --version).Trim().Split('+')[0]

if ([version]$InstalledDocFxVersion -lt [version]$DocFxVersion) {
Write-Host "DocFx is installed, but the version is less than $DocFxVersion, will install it."
$InstallDocFx = $true
}
else {
Write-Host "DocFx is installed and the version is $InstalledDocFxVersion."
}
} catch {
Write-Host "DocFx is not installed or not in the PATH, will install it."
$InstallDocFx = $true
}

if ($InstallDocFx -eq $true) {
Write-Host "Installing docfx global tool..."
dotnet tool install -g docfx --version $DocFxVersion
}
$PreviousLocation = Get-Location
Set-Location $RepoRoot
dotnet tool restore
Set-Location $PreviousLocation

# delete anything that already exists
if ($Clean) {
Expand All @@ -83,11 +65,11 @@ if($?) {
if ($ServeDocs -eq $false) {
# build the output
Write-Host "Building docs..."
& docfx build $DocFxJson -l "$DocFxLog" --logLevel $LogLevel
& dotnet tool run docfx build $DocFxJson -l "$DocFxLog" --logLevel $LogLevel
}
else {
# build + serve (for testing)
Write-Host "starting website..."
& docfx $DocFxJson --serve --port $StagingPort
& dotnet tool run docfx $DocFxJson --serve --port $StagingPort
}
}

0 comments on commit 7d74464

Please sign in to comment.