azure-sdk-for-cpp/eng/scripts/New-VcpkgPortDefinition.ps1
Daniel Jurek 39e8dfd6e7
Vcpkg publish framework (#645)
* Add vcpkg artifact creation and port template copying
* Skip staging if vcpkg port directory doesn't exist
2020-09-17 15:45:43 -07:00

62 lines
1.5 KiB
PowerShell

<#
.SYNOPSIS
Replaces token content in each file of the SourceDirectory (assumes no subfolders)
.PARAMETER SourceDirectory
Location of vcpkg port files
(usually `<artifact-path>/packages/<package-name>/vcpkg/port`)
.PARAMETER Version
Replaces %VERSION% token in files with the value of this parameter
.PARAMETER Url
Replaces %URL% token in files with the value of this parameter
.PARAMETER Filename
Replaces %FILENAME% token in files with the value of this parameter
.PARAMETER Sha512
Replaces %SHA512% token in files with the value of this parameter
#>
param (
[Parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[string] $SourceDirectory,
[Parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[string] $Version,
[Parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[string] $Url,
[Parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[string] $Filename,
[Parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[string] $Sha512
)
$files = Get-ChildItem -Path $SourceDirectory -Include *.template -Recurse
Write-Host $files
foreach ($file in $files) {
Write-Host "Updating file contents: $file"
$content = Get-Content -Raw -Path $file
$newContent = $content `
-replace '%VERSION%', $Version `
-replace '%URL%', $Url `
-replace '%FILENAME%', $Filename `
-replace '%SHA512%', $Sha512
$newContent | Set-Content $file
$file | Rename-Item -NewName { $_.Name -replace '.template', '' }
}