UPDATED THE NUGET INSTALL PROCESS
This commit is contained in:
@@ -1658,52 +1658,44 @@ function Install-DattoRMM {
|
|||||||
}
|
}
|
||||||
#endregion EntryPoint: Define Invoke-ScriptMonkey
|
#endregion EntryPoint: Define Invoke-ScriptMonkey
|
||||||
|
|
||||||
#region — guarantee NuGet provider is present without prompting
|
#region — guarantee NuGet provider is present without prompting
|
||||||
|
# ─── NuGet + PSGallery bootstrap (safe & silent) ───
|
||||||
|
|
||||||
# ─── Top of script ───
|
# 1) Enforce TLS 1.2 and disable progress UI
|
||||||
Import-Module PackageManagement -Force -ErrorAction SilentlyContinue | Out-Null
|
|
||||||
Import-Module PowerShellGet -Force -ErrorAction SilentlyContinue | Out-Null
|
|
||||||
|
|
||||||
# ─── ensure TLS 1.2 + no prompts ───
|
|
||||||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
||||||
$ProgressPreference = 'SilentlyContinue'
|
$ProgressPreference = 'SilentlyContinue'
|
||||||
$ConfirmPreference = 'None'
|
$ConfirmPreference = 'None'
|
||||||
|
|
||||||
# check if NuGet exists (no output—assigned to $nuget)
|
# 2) Import core modules (no warnings)
|
||||||
$nuget = Get-PackageProvider -Name NuGet -ListAvailable -ErrorAction SilentlyContinue
|
Import-Module PackageManagement -Force -ErrorAction SilentlyContinue | Out-Null
|
||||||
|
Import-Module PowerShellGet -Force -ErrorAction SilentlyContinue | Out-Null
|
||||||
|
|
||||||
if (-not $nuget) {
|
# 3) Trust PSGallery if not already
|
||||||
# install it (again, assignment suppresses the table)
|
|
||||||
Install-PackageProvider `
|
|
||||||
-Name NuGet `
|
|
||||||
-MinimumVersion 2.8.5.201 `
|
|
||||||
-Force `
|
|
||||||
-Confirm:$false
|
|
||||||
|
|
||||||
|
|
||||||
# re-query just for version info
|
|
||||||
$found = Get-PackageProvider -Name NuGet -ListAvailable
|
|
||||||
Write-LogHybrid "Installed NuGet provider v$($found.Version)" Info Bootstrap -LogToEvent
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
Write-LogHybrid "NuGet provider already present (v$($found.Version))" Info Bootstrap -LogToEvent
|
|
||||||
}
|
|
||||||
|
|
||||||
# now import it silently
|
|
||||||
Import-PackageProvider -Name NuGet -Force -ErrorAction SilentlyContinue | Out-Null
|
|
||||||
|
|
||||||
# ensure trust PSGallery without its own output (so you don't get “untrusted repository” prompt
|
|
||||||
$gallery = Get-PSRepository -Name PSGallery -ErrorAction SilentlyContinue
|
$gallery = Get-PSRepository -Name PSGallery -ErrorAction SilentlyContinue
|
||||||
if ($gallery.InstallationPolicy -ne 'Trusted') {
|
if ($gallery -and $gallery.InstallationPolicy -ne 'Trusted') {
|
||||||
Set-PSRepository `
|
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted -ErrorAction SilentlyContinue
|
||||||
-Name PSGallery `
|
|
||||||
-InstallationPolicy Trusted `
|
|
||||||
-ErrorAction SilentlyContinue | Out-Null
|
|
||||||
|
|
||||||
Write-LogHybrid "PSGallery marked as Trusted" Info Bootstrap -LogToEvent
|
Write-LogHybrid "PSGallery marked as Trusted" Info Bootstrap -LogToEvent
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
# 4) Ensure NuGet provider is available and installed without prompt
|
||||||
|
$nuget = Get-PackageProvider -Name NuGet -ListAvailable -ErrorAction SilentlyContinue
|
||||||
|
if (-not $nuget) {
|
||||||
|
try {
|
||||||
|
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force -Confirm:$false -ErrorAction Stop
|
||||||
|
$found = Get-PackageProvider -Name NuGet -ListAvailable -ErrorAction SilentlyContinue
|
||||||
|
Write-LogHybrid "Installed NuGet provider v$($found.Version)" Info Bootstrap -LogToEvent
|
||||||
|
} catch {
|
||||||
|
Write-LogHybrid "NuGet install failed: $($_.Exception.Message)" Error Bootstrap -LogToEvent
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Write-LogHybrid "NuGet provider already present (v$($nuget.Version))" Info Bootstrap -LogToEvent
|
||||||
|
}
|
||||||
|
|
||||||
|
# 5) Import it silently (optional but safe)
|
||||||
|
Import-PackageProvider -Name NuGet -Force -ErrorAction SilentlyContinue | Out-Null
|
||||||
|
|
||||||
|
#endregion guarantee NuGet provider is present without prompting
|
||||||
|
|
||||||
|
|
||||||
#region HTTP Listener & Routing
|
#region HTTP Listener & Routing
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user