mirror of
https://github.com/ChrisTitusTech/winutil
synced 2026-06-04 14:17:27 +00:00
Made Compile.ps1 not load the script into memory and use -Raw (#4536)
* Made Compile.ps1 not load the script into memory * Update Compile.ps1 * Update Compile.ps1 * Update Compile.ps1
This commit is contained in:
+10
-16
@@ -2,23 +2,18 @@ param (
|
|||||||
[switch]$Run
|
[switch]$Run
|
||||||
)
|
)
|
||||||
|
|
||||||
$OFS = "`r`n" # Makes it so we dont need to add -Raw to every Get-Content command
|
$OFS = "`r`n"
|
||||||
|
|
||||||
# Variable to sync between runspaces
|
# Variable to sync between runspaces
|
||||||
$sync = [Hashtable]::Synchronized(@{})
|
$sync = [Hashtable]::Synchronized(@{})
|
||||||
$sync.configs = @{}
|
$sync.configs = @{}
|
||||||
|
|
||||||
# Create the script in memory.
|
$script = (Get-Content -Path scripts\start.ps1) -replace '#{replaceme}', (Get-Date -Format 'yy.MM.dd')
|
||||||
$script = [System.Collections.Generic.List[string]]::new()
|
|
||||||
|
|
||||||
$script.Add(
|
$script += Get-ChildItem -Path functions -Recurse -File | Get-Content -Raw
|
||||||
((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 {
|
Get-ChildItem config | ForEach-Object {
|
||||||
$obj = Get-Content -Path $_.FullName | ConvertFrom-Json
|
$obj = Get-Content -Path $_.FullName -Raw | ConvertFrom-Json
|
||||||
|
|
||||||
if ($_.Name -eq "applications.json") {
|
if ($_.Name -eq "applications.json") {
|
||||||
$fixed = [ordered]@{}
|
$fixed = [ordered]@{}
|
||||||
@@ -31,17 +26,16 @@ Get-ChildItem config | ForEach-Object {
|
|||||||
$json = $obj | ConvertTo-Json -Depth 10
|
$json = $obj | ConvertTo-Json -Depth 10
|
||||||
|
|
||||||
$sync.configs[$_.BaseName] = $obj
|
$sync.configs[$_.BaseName] = $obj
|
||||||
$script.Add("`$sync.configs.$($_.BaseName) = @'`r`n$json`r`n'@ | ConvertFrom-Json")
|
$script += "`$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 -Raw
|
||||||
$xaml = Get-Content -Path xaml\inputXML.xaml
|
$script += "`$inputXML = @'`r`n$xaml`r`n'@"
|
||||||
$script.Add('$inputXML = @''' + "`n" + $xaml + "`n" + '''@')
|
|
||||||
|
|
||||||
$autounattendXml = Get-Content -Path tools\autounattend.xml
|
$autounattendXml = Get-Content -Path tools\autounattend.xml -Raw
|
||||||
$script.Add("`$WinUtilAutounattendXml = @'`r`n$autounattendXml`r`n'@")
|
$script += "`$WinUtilAutounattendXml = @'`r`n$autounattendXml`r`n'@"
|
||||||
|
|
||||||
$script.Add((Get-Content -Path scripts\main.ps1))
|
$script += Get-Content -Path scripts\main.ps1 -Raw
|
||||||
|
|
||||||
Set-Content -Path winutil.ps1 -Value $script
|
Set-Content -Path winutil.ps1 -Value $script
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user