[CmdletBinding()] Param( [Parameter(Mandatory = $True)] [string]$dscWxsFile, [Parameter(Mandatory = $True)] [string]$Platform, [Parameter(Mandatory = $True)] [string]$Configuration ) $ErrorActionPreference = 'Stop' $scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path # Find build output directory $buildOutputDir = Join-Path $scriptDir "..\..\$Platform\$Configuration" if (-not (Test-Path $buildOutputDir)) { Write-Error "Build output directory not found: '$buildOutputDir'" exit 1 } # Find all DSC manifest JSON files $dscFiles = Get-ChildItem -Path $buildOutputDir -Filter "microsoft.powertoys.*.settings.dsc.resource.json" -File if (-not $dscFiles) { Write-Warning "No DSC manifest files found in '$buildOutputDir'" # Create empty component group $wxsContent = @" "@ Set-Content -Path $dscWxsFile -Value $wxsContent exit 0 } Write-Host "Found $($dscFiles.Count) DSC manifest file(s)" # Generate WiX fragment $wxsContent = @" "@ $componentRefs = @() foreach ($file in $dscFiles) { $componentId = "DscResource_" + ($file.BaseName -replace '[^A-Za-z0-9_]', '_') $fileId = $componentId + "_File" $guid = [System.Guid]::NewGuid().ToString().ToUpper() $componentRefs += $componentId $wxsContent += @" "@ } $wxsContent += @" "@ foreach ($componentId in $componentRefs) { $wxsContent += @" "@ } $wxsContent += @" "@ # Write the WiX file Set-Content -Path $dscWxsFile -Value $wxsContent Write-Host "Generated DSC resources WiX fragment: '$dscWxsFile'"