diff --git a/nuspec/chocolatey/chocolatey/tools/chocolateysetup.psm1 b/nuspec/chocolatey/chocolatey/tools/chocolateysetup.psm1 index 66c25928b5..54eb4a950f 100644 --- a/nuspec/chocolatey/chocolatey/tools/chocolateysetup.psm1 +++ b/nuspec/chocolatey/chocolatey/tools/chocolateysetup.psm1 @@ -126,7 +126,7 @@ function Initialize-Chocolatey { $installModule = Join-Path $thisScriptFolder 'chocolateyInstall\helpers\chocolateyInstaller.psm1' Import-Module $installModule -Force - Install-DotNet48IfMissing + Install-DotNet48IfMissing if ($chocolateyPath -eq '') { $programData = [Environment]::GetFolderPath("CommonApplicationData") @@ -204,13 +204,20 @@ Creating Chocolatey folders if they do not already exist. $env:ChocolateyExitCode = 0 } - @" + if ($script:DotNetInstallRequiredReboot) { + @" +Chocolatey (choco.exe) is nearly ready. +You need to restart this machine prior to using choco. +"@ | Write-Output + } else { + @" Chocolatey (choco.exe) is now ready. You can call choco from anywhere, command line or powershell by typing choco. Run choco /? for a list of functions. You may need to shut down and restart powershell and/or consoles first prior to using choco. "@ | Write-Output + } if (-not $allowInsecureRootInstall) { Remove-OldChocolateyInstall $defaultChocolateyPathOld @@ -812,7 +819,8 @@ function Install-DotNet48IfMissing { $s = [System.Diagnostics.Process]::Start($psi); $s.WaitForExit(); if ($s.ExitCode -eq 1641 -or $s.ExitCode -eq 3010) { - throw ".NET Framework 4.8 was installed, but a reboot is required. `n Please reboot the system and try to install/upgrade Chocolatey again." + Write-Warning ".NET Framework 4.8 was installed, but a reboot is required before using Chocolatey." + $script:DotNetInstallRequiredReboot = $true } if ($s.ExitCode -ne 0) { if ($netFx48InstallTries -ge 2) { @@ -832,11 +840,11 @@ function Invoke-Chocolatey-Initial { try { $chocoInstallationFolder = Get-ChocolateyInstallFolder $chocoExe = Join-Path -Path $chocoInstallationFolder -ChildPath "choco.exe" - & $chocoExe -v | Out-Null + $runResult = & $chocoExe -v Write-Debug "Chocolatey execution completed successfully." } catch { - Write-ChocolateyWarning "Unable to run Chocolatey at this time. It is likely that .Net Framework installation requires a system reboot" + Write-ChocolateyWarning "Unable to run Chocolatey at this time:`n$($runResult)" } }