Files
winutil/Compile.ps1
T
Gabi 8ffd15c9f3 simplify Compile.ps1 by alot (#4484)
* Update Compile.ps1

* Delete tools/Invoke-Preprocessing.ps1

* Update .gitignore

* Update Compile.ps1

* Update Compile.ps1

* Update Compile.ps1

* Update Compile.ps1

* Update Compile.ps1

* Update .gitignore

* Update Compile.ps1

* Update Compile.ps1

* Update Compile.ps1

* Merge branch 'main' into patch-5
2026-05-19 12:40:02 -05:00

51 lines
1.4 KiB
PowerShell

param (
[switch]$Run
)
$OFS = "`r`n" # Makes it so we dont need to add -Raw to every Get-Content command
# Variable to sync between runspaces
$sync = [Hashtable]::Synchronized(@{})
$sync.configs = @{}
# Create the script in memory.
$script = [System.Collections.Generic.List[string]]::new()
$script.Add(
((Get-Content -Path scripts\start.ps1) -replace '#{replaceme}', (Get-Date -Format 'yy.MM.dd'))
)
$script.Add((Get-ChildItem -Path functions -Recurse -File | Get-Content))
Get-ChildItem config | ForEach-Object {
$obj = Get-Content -Path $_.FullName | ConvertFrom-Json
if ($_.Name -eq "applications.json") {
$fixed = [ordered]@{}
foreach ($p in $obj.PSObject.Properties) {
$fixed["WPFInstall$($p.Name)"] = $p.Value
}
$obj = [pscustomobject]$fixed
}
$json = $obj | ConvertTo-Json -Depth 10
$sync.configs[$_.BaseName] = $obj
$script.Add("`$sync.configs.$($_.BaseName) = @'`r`n$json`r`n'@ | ConvertFrom-Json")
}
# Read the entire XAML file as a single string, preserving line breaks
$xaml = Get-Content -Path xaml\inputXML.xaml
$script.Add('$inputXML = @''' + "`n" + $xaml + "`n" + '''@')
$autounattendXml = Get-Content -Path tools\autounattend.xml
$script.Add("`$WinUtilAutounattendXml = @'`r`n$autounattendXml`r`n'@")
$script.Add((Get-Content -Path scripts\main.ps1))
Set-Content -Path winutil.ps1 -Value $script
if ($Run) {
.\Winutil.ps1
}