Fix installer script structure

This commit is contained in:
Manuel Thalmann 2024-08-01 23:34:35 +02:00
parent 72fd72f5bd
commit a9ae8c9a98
2 changed files with 52 additions and 43 deletions

View file

@ -1,15 +1,11 @@
. "$PSScriptRoot/Config.ps1"; . "$PSScriptRoot/Config.ps1";
. "$PSScriptRoot/../Types/InstallerAction.ps1"; . "$PSScriptRoot/../Types/InstallerAction.ps1";
$null = New-Module { <#
. "$PSScriptRoot/../Types/InstallerAction.ps1";
$userArgument = "name";
<#
.SYNOPSIS .SYNOPSIS
Gets the name of the software. Gets the name of the software.
#> #>
function Get-SoftwareName { function Get-SoftwareName {
$path = ${Function:Install-Software}.File; $path = ${Function:Install-Software}.File;
if ($path -ne "$PSCommandPath") { if ($path -ne "$PSCommandPath") {
@ -17,33 +13,37 @@ $null = New-Module {
} else { } else {
$null; $null;
} }
} }
<# <#
.SYNOPSIS .SYNOPSIS
Installs the software. Installs the software.
#> #>
function Install-Software { } function Install-Software { }
<# <#
.SYNOPSIS .SYNOPSIS
Configures the system for the software. Configures the system for the software.
#> #>
function Set-SoftwareConfiguration { } function Set-SoftwareConfiguration { }
<# <#
.SYNOPSIS .SYNOPSIS
Configures a user for the software. Configures a user for the software.
.PARAMETER Name .PARAMETER Name
The name of the user to configure. The name of the user to configure.
#> #>
function Set-SoftwareUserConfiguration { function Set-SoftwareUserConfiguration {
param( param(
[Parameter(Mandatory = $true)] [Parameter(Mandatory = $true)]
[string] $Name [string] $Name
) )
} }
$null = New-Module {
. "$PSScriptRoot/../Types/InstallerAction.ps1";
$userArgument = "name";
function Start-SoftwareInstaller { function Start-SoftwareInstaller {
param( param(
@ -68,7 +68,6 @@ $null = New-Module {
foreach ($user in Get-Users) { foreach ($user in Get-Users) {
$Arguments.Add($userArgument, $user); $Arguments.Add($userArgument, $user);
Start-SoftwareInstaller -Action ([InstallerAction]::ConfigureUser) @Arguments; Start-SoftwareInstaller -Action ([InstallerAction]::ConfigureUser) @Arguments;
} }
} elseif ($action -eq ([InstallerAction]::ConfigureUser)) { } elseif ($action -eq ([InstallerAction]::ConfigureUser)) {

View file

@ -1,9 +1,19 @@
param( param(
[string] $Action = ([InstallerAction]::Install), $Action,
[hashtable] $Arguments [hashtable] $Arguments
) )
. "$PSScriptRoot/../../Scripts/Software.ps1"; . "$PSScriptRoot/../../Scripts/Software.ps1";
. "$PSScriptRoot/../../Types/InstallerAction.ps1";
function Install-Winget {
param(
[InstallerAction] $Action = [InstallerAction]::Install,
[hashtable] $Arguments
)
Start-SoftwareInstaller -Action $Action -Arguments $Arguments;
}
function Install-Software { function Install-Software {
$xamlDownloadLink = "https://github.com/microsoft/microsoft-ui-xaml/releases/download/v2.8.6/Microsoft.UI.Xaml.2.8.x64.appx"; $xamlDownloadLink = "https://github.com/microsoft/microsoft-ui-xaml/releases/download/v2.8.6/Microsoft.UI.Xaml.2.8.x64.appx";
@ -17,4 +27,4 @@ function Install-Software {
Remove-Item $file; Remove-Item $file;
} }
Start-SoftwareInstaller -Action $Action -Arguments $Arguments; Install-Winget @PSBoundParameters;