Skip to content

Commit

Permalink
(GH-347) Unpack choco files prior to nuget pack
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ferventcoder committed Sep 18, 2015
1 parent bb270cb commit 4459b88
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
12 changes: 10 additions & 2 deletions .build.custom/nugetPrepare.post.step
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<property name="build.step.path" value="${project::get-buildfile-path()}" />
<!-- build step customizations below this -->

<target name="go" depends="prep_nuget" />
<target name="go" depends="prep_nuget, unpack_files" />

<target name="prep_nuget">
<echo level="Warning" message="Moving ${dirs.drop.nuget}${path.separator}lib${path.separator}console to ${dirs.drop.nuget}${path.separator}chocolatey${path.separator}tools${path.separator}chocolateyInstall." />
Expand All @@ -30,7 +30,15 @@
</fileset>
</move>
<delete dir="${dirs.drop.nuget}${path.separator}lib${path.separator}lib" />

</target>

<target name="unpack_files">
<echo level="Warning" message="Unpacking Choco files." />
<property name="app.choco" value="${dirs.drop.nuget}${path.separator}chocolatey${path.separator}tools${path.separator}chocolateyInstall${path.separator}choco.exe" />
<property name="args.choco" value="unpackself -f" />
<exec program="${app.choco}"
workingdir="${dirs.drop.nuget}${path.separator}chocolatey${path.separator}tools${path.separator}chocolateyInstall"
commandline="${args.choco}" if="${platform::is-windows()}" />
</target>

</project>
16 changes: 4 additions & 12 deletions nuget/chocolatey/tools/chocolateysetup.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ $chocInstallVariableName = "ChocolateyInstall"
$sysDrive = $env:SystemDrive
$tempDir = $env:TEMP
$defaultChocolateyPathOld = "$sysDrive\Chocolatey"
#$ErrorActionPreference = 'Stop'
$debugModeParams = $null

function Initialize-Chocolatey {
<#
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 4459b88

Please sign in to comment.