mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-14 18:57:55 +01:00
<!-- Enter a brief description/summary of your PR here. What does it fix/what does it change/how was it tested (even manually, if necessary)? --> ## Summary of the Pull Request - Use DSCModules subfolder for JSON manifest files - Use relative path "..\PowerToys.DSC.exe" in JSON manifests - Configure PATH environment variable to point to DSCModules subfolder <!-- Please review the items on the PR checklist before submitting--> ## PR Checklist - [ ] Closes: #xxx - [ ] **Communication:** I've discussed this with core contributors already. If the work hasn't been agreed, this work might be rejected - [ ] **Tests:** Added/updated and all pass - [ ] **Localization:** All end-user-facing strings can be localized - [ ] **Dev docs:** Added/updated - [ ] **New binaries:** Added on the required places - [ ] [JSON for signing](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json) for new binaries - [ ] [WXS for installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs) for new binaries and localization folder - [ ] [YML for CI pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml) for new test projects - [ ] [YML for signed pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml) - [ ] **Documentation updated:** If checked, please file a pull request on [our docs repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys) and link it here: #xxx <!-- Provide a more detailed description of the PR, other things fixed, or any additional comments/features here --> ## Detailed Description of the Pull Request / Additional comments <!-- Describe how you validated the behavior. Add automated tests wherever possible, but list manual validation steps taken as well --> ## Validation Steps Performed
96 lines
3.3 KiB
PowerShell
96 lines
3.3 KiB
PowerShell
[CmdletBinding()]
|
|
param(
|
|
[Parameter(Mandatory = $true)]
|
|
[string]$BuildPlatform,
|
|
|
|
[Parameter(Mandatory = $true)]
|
|
[string]$BuildConfiguration,
|
|
|
|
[Parameter()]
|
|
[string]$RepoRoot = (Get-Location).Path
|
|
)
|
|
|
|
$ErrorActionPreference = 'Stop'
|
|
|
|
function Resolve-PlatformDirectory {
|
|
param(
|
|
[string]$Root,
|
|
[string]$Platform
|
|
)
|
|
|
|
$normalized = $Platform.Trim()
|
|
$candidates = @()
|
|
$candidates += Join-Path $Root $normalized
|
|
$candidates += Join-Path $Root ($normalized.ToUpperInvariant())
|
|
$candidates += Join-Path $Root ($normalized.ToLowerInvariant())
|
|
$candidates = $candidates | Where-Object { -not [string]::IsNullOrWhiteSpace($_) } | Select-Object -Unique
|
|
|
|
foreach ($candidate in $candidates) {
|
|
if (Test-Path $candidate) {
|
|
return $candidate
|
|
}
|
|
}
|
|
|
|
return $candidates[0]
|
|
}
|
|
|
|
Write-Host "Repo root: $RepoRoot"
|
|
Write-Host "Requested build platform: $BuildPlatform"
|
|
Write-Host "Requested configuration: $BuildConfiguration"
|
|
|
|
# Always use x64 PowerToys.DSC.exe since CI/CD machines are x64
|
|
$exePlatform = 'x64'
|
|
$exeRoot = Resolve-PlatformDirectory -Root $RepoRoot -Platform $exePlatform
|
|
$exeOutputDir = Join-Path $exeRoot $BuildConfiguration
|
|
$exePath = Join-Path $exeOutputDir 'PowerToys.DSC.exe'
|
|
|
|
Write-Host "Using x64 PowerToys.DSC.exe to generate DSC manifests for $BuildPlatform build"
|
|
|
|
if (-not (Test-Path $exePath)) {
|
|
throw "PowerToys.DSC.exe not found at '$exePath'. Make sure it has been built first."
|
|
}
|
|
|
|
Write-Host "Using PowerToys.DSC.exe at '$exePath'."
|
|
|
|
# Output DSC manifests to the target build platform directory (x64, ARM64, etc.)
|
|
$outputRoot = Resolve-PlatformDirectory -Root $RepoRoot -Platform $BuildPlatform
|
|
if (-not (Test-Path $outputRoot)) {
|
|
Write-Host "Creating missing platform output root at '$outputRoot'."
|
|
New-Item -Path $outputRoot -ItemType Directory -Force | Out-Null
|
|
}
|
|
|
|
$outputDir = Join-Path $outputRoot $BuildConfiguration
|
|
if (-not (Test-Path $outputDir)) {
|
|
Write-Host "Creating missing configuration output directory at '$outputDir'."
|
|
New-Item -Path $outputDir -ItemType Directory -Force | Out-Null
|
|
}
|
|
|
|
# DSC v3 manifests go to DSCModules subfolder
|
|
$dscOutputDir = Join-Path $outputDir 'DSCModules'
|
|
if (-not (Test-Path $dscOutputDir)) {
|
|
Write-Host "Creating DSCModules subfolder at '$dscOutputDir'."
|
|
New-Item -Path $dscOutputDir -ItemType Directory -Force | Out-Null
|
|
}
|
|
|
|
Write-Host "DSC manifests will be generated to: '$dscOutputDir'"
|
|
|
|
Write-Host "Cleaning previously generated DSC manifest files from '$dscOutputDir'."
|
|
Get-ChildItem -Path $dscOutputDir -Filter 'microsoft.powertoys.*.settings.dsc.resource.json' -ErrorAction SilentlyContinue | Remove-Item -Force
|
|
|
|
$arguments = @('manifest', '--resource', 'settings', '--outputDir', $dscOutputDir)
|
|
Write-Host "Invoking DSC manifest generator: '$exePath' $($arguments -join ' ')"
|
|
& $exePath @arguments
|
|
if ($LASTEXITCODE -ne 0) {
|
|
throw "PowerToys.DSC.exe exited with code $LASTEXITCODE"
|
|
}
|
|
|
|
$generatedFiles = Get-ChildItem -Path $dscOutputDir -Filter 'microsoft.powertoys.*.settings.dsc.resource.json' -ErrorAction Stop
|
|
if ($generatedFiles.Count -eq 0) {
|
|
throw "No DSC manifest files were generated in '$dscOutputDir'."
|
|
}
|
|
|
|
Write-Host "Generated $($generatedFiles.Count) DSC manifest file(s):"
|
|
foreach ($file in $generatedFiles) {
|
|
Write-Host " - $($file.FullName)"
|
|
}
|