From 4459b881ae944023698ccff627ab2da6e6fa7d69 Mon Sep 17 00:00:00 2001 From: Rob Reynolds Date: Thu, 17 Sep 2015 23:55:47 -0500 Subject: [PATCH] (GH-347) Unpack choco files prior to nuget pack Right now choco requires a functioning .NET 4+ framework install to even install itself on a machine. During install It will attempt twice to install .NET 4.0 if there isn't a version present, but it may run into errors or require a reboot before it is ready to be used. Because of this folks run into what looks like a missing file `chocolateyInstaller.psm1` during install, when it's actually the former reason. Without .NET 4.0, the files can't be unpacked from choco. Unpacking those files in the nupkg will allow the errors to be more visible on a non-functioning .NET framework install versus something with a file missing. This allows choco to be installed without the framework installed properly, just not able to be used. --- .build.custom/nugetPrepare.post.step | 12 ++++++++++-- nuget/chocolatey/tools/chocolateysetup.psm1 | 16 ++++------------ 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/.build.custom/nugetPrepare.post.step b/.build.custom/nugetPrepare.post.step index 09ee205c2c..5a5a6ceb92 100644 --- a/.build.custom/nugetPrepare.post.step +++ b/.build.custom/nugetPrepare.post.step @@ -12,7 +12,7 @@ - + @@ -30,7 +30,15 @@ - + + + + + + + diff --git a/nuget/chocolatey/tools/chocolateysetup.psm1 b/nuget/chocolatey/tools/chocolateysetup.psm1 index e6520e5d1b..569e01b8a7 100644 --- a/nuget/chocolatey/tools/chocolateysetup.psm1 +++ b/nuget/chocolatey/tools/chocolateysetup.psm1 @@ -3,8 +3,6 @@ $chocInstallVariableName = "ChocolateyInstall" $sysDrive = $env:SystemDrive $tempDir = $env:TEMP $defaultChocolateyPathOld = "$sysDrive\Chocolatey" -#$ErrorActionPreference = 'Stop' -$debugModeParams = $null function Initialize-Chocolatey { <# @@ -33,15 +31,6 @@ param( ) Write-Debug "Initialize-Chocolatey" - if ($env:ChocolateyEnvironmentDebug -eq 'true') { - $debugModeParams = '-dv' - } - - Install-DotNet4IfMissing - - $chocoNew = Join-Path $thisScriptFolder 'chocolateyInstall\choco.exe' - & $chocoNew unpackself -fy $debugModeParams - $installModule = Join-Path $thisScriptFolder 'chocolateyInstall\helpers\chocolateyInstaller.psm1' Import-Module $installModule -Force @@ -110,6 +99,8 @@ Creating Chocolatey folders if they do not already exist. Install-ChocolateyBinFiles $chocolateyPath $chocolateyExePath } + Install-DotNet4IfMissing + @" Chocolatey (choco.exe) is now ready. You can call choco from anywhere, command line or powershell by typing choco. @@ -309,7 +300,8 @@ param( $chocoExeDest = Join-Path $chocolateyPath 'choco.exe' Copy-Item $chocoExe $chocoExeDest -force - & $chocoExeDest unpackself -fy $debugModeParams + Write-Debug "Copying the contents of `'$chocInstallFolder`' to `'$chocolateyPath`'." + Copy-Item $chocInstallFolder\* $chocolateyPath -recurse -force } function Ensure-ChocolateyLibFiles {