tasks/Update_Wiki_Home.build.ps1
|
<# .SYNOPSIS This is a build task that updates the Wiki Home page (Home.md) from the project's README.md and generates a _Footer.md with version and date. .PARAMETER ProjectPath The root path to the project. Defaults to $BuildRoot. .PARAMETER OutputDirectory The base directory of all output. Defaults to folder 'output' relative to the $BuildRoot. .PARAMETER BuildInfo The build info object from ModuleBuilder. Defaults to an empty hashtable. .NOTES This is a build task that is primarily meant to be run by Invoke-Build but wrapped by the Sampler project's build.ps1 (https://github.com/gaelcolas/Sampler). #> param ( [Parameter()] [System.String] $ProjectPath = (property ProjectPath $BuildRoot), [Parameter()] [System.String] $OutputDirectory = (property OutputDirectory (Join-Path $BuildRoot 'output')), [Parameter()] [System.Collections.Hashtable] $BuildInfo = (property BuildInfo @{ }) ) # Synopsis: Update Wiki Home.md from README.md and generate a versioned footer. task Update_Wiki_Home { $error.Clear() Write-Output "TS: Update_Wiki_Home" $readmePath = Join-Path -Path $ProjectPath -ChildPath 'README.md' $homePath = Join-Path -Path $OutputDirectory -ChildPath 'WikiContent/Home.md' $footerPath = Join-Path -Path $OutputDirectory -ChildPath 'WikiContent/_Footer.md' $version = & dotnet-gitversion /showvariable SemVer $date = Get-Date -Format "yyyy-MM-ddTHH:mm:ssZ" if (Test-Path $readmePath) { # Ensure the output directory exists $wikiDir = Split-Path $homePath if (-not (Test-Path $wikiDir)) { New-Item -ItemType Directory -Force -Path $wikiDir | Out-Null } Get-Content $readmePath | Out-File $homePath -Encoding UTF8 $footerLines = @( "**Last updated:** $date", "**Version:** $version", "" ) $footerLines | Out-File $footerPath -Encoding UTF8 Write-Output "Updated Home.md and _Footer.md with version $version and date $date" } else { Write-Warning "README.md not found at $readmePath" } Get-Error | Out-String | Write-Host -ForegroundColor Yellow } |