PowerToys/installer/PowerToysSetup/generateFileComponents.ps1
Stefan Markovic 870f8e3571
[installer] Support per-user installation ()
* Add per user installer

* Separate upgrade codes for per machine and per user installation
Move per machine check to bootstrapper
Move all defines to common.wxs
Fix CI

* Update installer/PowerToysSetup/generateFileList.ps1

Co-authored-by: Jeremy Sinclair <4016293+snickler@users.noreply.github.com>

* Update installer/PowerToysSetup/generateAllFileComponents.ps1

Co-authored-by: Jeremy Sinclair <4016293+snickler@users.noreply.github.com>

* Update installer/PowerToysSetup/generateFileList.ps1

Co-authored-by: Jeremy Sinclair <4016293+snickler@users.noreply.github.com>

* expect.txt

* Revert "Update installer/PowerToysSetup/generateFileList.ps1"

This reverts commit 34545dab9c.

* Update release CI to build both installers

* Revert bundle name change

It messes up app ID for per-user installation which ends up breaking winget update
of the per-user PT

* spellcheck

* Fix bad merge

* Add RegistryPreview

* Include backup_restore_settings.json

* Revert testing endpoint change

---------

Co-authored-by: Jeremy Sinclair <4016293+snickler@users.noreply.github.com>
2023-03-31 12:23:57 +02:00

56 lines
1.5 KiB
PowerShell

[CmdletBinding()]
Param(
[Parameter(Mandatory = $True, Position = 1)]
[string]$fileListName,
[Parameter(Mandatory = $True, Position = 2)]
[string]$wxsFilePath,
[Parameter(Mandatory = $True, Position = 3)]
[string]$regroot
)
$wxsFile = Get-Content $wxsFilePath;
$wxsFile | ForEach-Object {
if ($_ -match "(<?define $fileListName=)(.*)\?>") {
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', 'fileList',
Justification = 'variable is used in another scope')]
$fileList = $matches[2] -split ';'
return
}
}
$componentId = "$($fileListName)_Component"
$componentDefs = "`r`n"
$componentDefs +=
@"
<Component Id="$($componentId)" Win64="yes" Guid="$((New-Guid).ToString().ToUpper())">
<RegistryKey Root="$($regroot)" Key="Software\Classes\powertoys\components">
<RegistryValue Type="string" Name="$($componentId)" Value="" KeyPath="yes"/>
</RegistryKey>`r`n
"@
foreach ($file in $fileList) {
$fileTmp = $file -replace "-", "_"
$componentDefs +=
@"
<File Id="$($fileListName)_File_$($fileTmp)" Source="`$(var.$($fileListName)Path)\$($file)" />`r`n
"@
}
$componentDefs +=
@"
</Component>`r`n
"@
$wxsFile = $wxsFile -replace "\s+(<!--$($fileListName)_Component_Def-->)", $componentDefs
$componentRef =
@"
<ComponentRef Id="$($componentId)" />
"@
$wxsFile = $wxsFile -replace "\s+(</ComponentGroup>)", "$componentRef`r`n </ComponentGroup>"
Set-Content -Path $wxsFilePath -Value $wxsFile