Store installation context in a separate parameter
This commit is contained in:
parent
42322c7428
commit
9d24859ecf
4 changed files with 26 additions and 22 deletions
|
@ -15,7 +15,8 @@ $null = New-Module {
|
|||
[scriptblock] $UserBackup = $null,
|
||||
[scriptblock] $UserConfigurator = $null,
|
||||
[Nullable[InstallerAction]] $Action,
|
||||
[hashtable] $Arguments
|
||||
[hashtable] $Arguments,
|
||||
[hashtable] $Context
|
||||
)
|
||||
|
||||
[InstallerAction] $Action = & {
|
||||
|
@ -35,7 +36,8 @@ $null = New-Module {
|
|||
param(
|
||||
[string] $Name,
|
||||
[InstallerAction] $Action,
|
||||
[hashtable] $Arguments
|
||||
[hashtable] $Arguments,
|
||||
[hashtable] $Context
|
||||
)
|
||||
|
||||
[string] $DisplayName = $null;
|
||||
|
@ -47,11 +49,13 @@ $null = New-Module {
|
|||
}
|
||||
|
||||
$Arguments ??= @{ };
|
||||
$Context ??= @{ };
|
||||
|
||||
$argumentList = @{
|
||||
name = $Name;
|
||||
installer = $installHandler;
|
||||
arguments = $Arguments;
|
||||
context = $Context;
|
||||
};
|
||||
|
||||
switch ($Action) {
|
||||
|
@ -105,7 +109,7 @@ $null = New-Module {
|
|||
}
|
||||
};
|
||||
|
||||
& $installHandler -Name $Name -Action $Action -Arguments $Arguments;
|
||||
& $installHandler -Name $Name -Action $Action -Arguments $Arguments -Context $Context;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,16 +24,16 @@ $null = New-Module {
|
|||
)
|
||||
|
||||
@{
|
||||
arguments = @{
|
||||
context = @{
|
||||
name = $Name;
|
||||
nativeOnly = $NativeOnly;
|
||||
};
|
||||
installer = {
|
||||
param(
|
||||
[hashtable] $Arguments
|
||||
[hashtable] $Context
|
||||
)
|
||||
|
||||
$env:PENDING_MODULE_NAME = $Arguments.Name;
|
||||
$env:PENDING_MODULE_NAME = $Context.Name;
|
||||
|
||||
$installAction = {
|
||||
$module = $env:PENDING_MODULE_NAME;
|
||||
|
@ -43,7 +43,7 @@ $null = New-Module {
|
|||
}
|
||||
};
|
||||
|
||||
if (-not $Arguments.NativeOnly) {
|
||||
if (-not $Context.NativeOnly) {
|
||||
& $installAction -AcceptLicense;
|
||||
}
|
||||
|
||||
|
@ -56,10 +56,10 @@ $null = New-Module {
|
|||
|
||||
configurator = ($NoProfile.IsPresent) ? { } : {
|
||||
param(
|
||||
[hashtable] $Arguments
|
||||
[hashtable] $Context
|
||||
)
|
||||
|
||||
$name = $Arguments.Name;
|
||||
$name = $Context.Name;
|
||||
|
||||
Add-PowerShellProfileStatement `
|
||||
-System `
|
||||
|
|
|
@ -12,22 +12,22 @@ foreach ($key in $PSBoundParameters.Keys) {
|
|||
$parameters.Add($key, $PSBoundParameters.TryGetValue($key));
|
||||
}
|
||||
|
||||
$arguments = $parameters.arguments;
|
||||
$arguments.Add("Installer", $parameters.installer);
|
||||
$context = $parameters.context;
|
||||
$context.Add("Installer", $parameters.installer);
|
||||
|
||||
Start-SoftwareInstaller @parameters -Installer {
|
||||
param(
|
||||
[hashtable] $Arguments
|
||||
[hashtable] $Context
|
||||
)
|
||||
|
||||
$providerName = "NuGet";
|
||||
$module = $Arguments.Name;
|
||||
$module = $Context.Name;
|
||||
|
||||
if ({ $null = powershell -c "Get-PackageProvider -ListAvailable $providerName"; $? }) {
|
||||
$null = powershell -c "Install-PackageProvider -Force $providerName";
|
||||
}
|
||||
|
||||
& $Arguments.Installer @PSBoundParameters;
|
||||
& $Context.Installer @PSBoundParameters;
|
||||
|
||||
if (-not (& { powershell -NoProfile -Command "Import-Module $module; exit ([bool]`$Error)" 2> $null; $?; })) {
|
||||
$feature = "NetFx3";
|
||||
|
|
|
@ -19,14 +19,14 @@ function Get-TMForeverInstallerComponents {
|
|||
)
|
||||
|
||||
@{
|
||||
arguments = @{
|
||||
context = @{
|
||||
iconName = $IconName;
|
||||
userDirectory = $UserDirectory;
|
||||
installer = $Installer;
|
||||
};
|
||||
installer = {
|
||||
param([hashtable] $Arguments)
|
||||
$iconName = $Arguments.IconName;
|
||||
param([hashtable] $Context)
|
||||
$iconName = $Context.IconName;
|
||||
|
||||
foreach ($feature in @("DirectPlay", "NetFx3")) {
|
||||
if ((Get-WindowsOptionalFeature -Online -FeatureName $feature).State -ne "Enabled") {
|
||||
|
@ -35,16 +35,16 @@ function Get-TMForeverInstallerComponents {
|
|||
}
|
||||
}
|
||||
|
||||
& $Arguments.Installer;
|
||||
& $Context.Installer;
|
||||
Remove-DesktopIcon "*$iconName*";
|
||||
};
|
||||
userBackup = {
|
||||
param(
|
||||
[string] $Name,
|
||||
[hashtable] $Arguments
|
||||
[hashtable] $Context
|
||||
)
|
||||
|
||||
Add-BackupArtifacts -User $Arguments.Name -Source $Arguments.UserDirectory -Path "$Name" `
|
||||
Add-BackupArtifacts -User $Context.Name -Source $Context.UserDirectory -Path "$Name" `
|
||||
-Include @(
|
||||
"ChallengeMusics",
|
||||
"MediaTracker",
|
||||
|
@ -58,10 +58,10 @@ function Get-TMForeverInstallerComponents {
|
|||
userConfigurator = {
|
||||
param(
|
||||
[string] $Name,
|
||||
[hashtable] $Arguments
|
||||
[hashtable] $Context
|
||||
)
|
||||
|
||||
$user = $Arguments.Name;
|
||||
$user = $Context.Name;
|
||||
Expand-BackupArtifacts -User $user -Path "$Name" -Target $path;
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue