From 7d744644b3afb86030b8eacd3e0a2888cf822ba6 Mon Sep 17 00:00:00 2001 From: Paul Irwin Date: Wed, 9 Oct 2024 20:40:34 -0600 Subject: [PATCH] Use dotnet local tool for docfx in site.ps1 --- websites/site/site.ps1 | 30 ++++++------------------------ 1 file changed, 6 insertions(+), 24 deletions(-) diff --git a/websites/site/site.ps1 b/websites/site/site.ps1 index 1e18cb6325..749d5c53c8 100644 --- a/websites/site/site.ps1 +++ b/websites/site/site.ps1 @@ -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 @@ -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) { @@ -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 } }