Skip to content

Commit

Permalink
docs.ps1: Install and run docfx with explicit tool path
Browse files Browse the repository at this point in the history
  • Loading branch information
NightOwl888 committed Oct 24, 2024
1 parent 0e7c8c8 commit 2459695
Showing 1 changed file with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions websites/apidocs/docs.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -64,33 +64,26 @@ $BreadcrumbPath = Join-Path -Path $ApiDocsFolder -ChildPath "docfx.global.subsit

# The default local tools directory
$InstallDir = "$RepoRoot/.dotnet/tools"
$DocFxVersion = "2.77.0"
$VersionedInstallDir = "$InstallDir/docfx/$DocFxVersion"

# install docfx tool
$PreviousLocation = Get-Location
Set-Location $RepoRoot


# Ensure docfx is installed
if (-not (Test-Path "$InstallDir/docfx")) {
Write-Host "docfx is not installed. Installing as a local tool..."
if (-not (Test-Path "$VersionedInstallDir")) {
Write-Host "docfx $DocFxVersion is not installed. Installing as a local tool..."

# Install docfx as a local tool if it isn't listed in dotnet-tools.json
dotnet tool install --local docfx
} else {
Write-Host "docfx is already installed. Restoring tools..."

# Restore local tools listed in dotnet-tools.json
dotnet tool restore
dotnet tool install --local docfx --tool-path "$VersionedInstallDir"
}

# Verify that docfx is accessible
docfx --version

Set-Location $PreviousLocation

&dotnet tool list --local
dotnet tool list --global

& dotnet tool list --local
# Verify that docfx is accessible
& "$VersionedInstallDir/docfx" --version

# delete anything that already exists
if ($Clean) {
Expand Down

0 comments on commit 2459695

Please sign in to comment.