Skip to content
This repository has been archived by the owner on Feb 19, 2019. It is now read-only.

[BUG] Can't install on Server Core 2008 R2 #59

Closed
Iristyle opened this issue Jan 28, 2012 · 8 comments
Closed

[BUG] Can't install on Server Core 2008 R2 #59

Iristyle opened this issue Jan 28, 2012 · 8 comments

Comments

@Iristyle
Copy link
Contributor

The COM Shell.Application instance apparently doesn't have the code necessary to unzip on Core. Unfortunately I don't think there's an easy way around this one, other than to download some sort of unzip application first like 7-zip, unzip, etc.

Here's a solution for this that I use, but... it's probably not something you'd want to do.

Import-Module BitsTransfer
$Is32Bit = (($Env:PROCESSOR_ARCHITECTURE -eq 'x86') -and ($Env:PROCESSOR_ARCHITEW6432 -eq $null))

7zip

$7zUri = if ($Is32Bit) { 'http://sourceforge.net/projects/sevenzip/files/7-Zip/9.22/7z922.msi/download' } `
else { 'http://sourceforge.net/projects/sevenzip/files/7-Zip/9.22/7z922-x64.msi/download' }

Start-BitsTransfer $7zUri 7z922.msi
Start-Process -FilePath "msiexec.exe" -ArgumentList '/i 7z922.msi /norestart /q INSTALLDIR="c:\program files\7-zip"' -Wait
SetX Path "${Env:Path};C:\Program Files\7-zip" /m
$Env:Path += ';C:\Program Files\7-Zip'
del 7z922.msi

Here's the error output during the install:

PS C:\Users\Administrator> Invoke-Expression ((new-object net.webclient).DownloadString('http://bit.ly/psChocInstall'))

Mode LastWriteTime Length Name


d---- 1/28/2012 1:17 AM chocInstall
Downloading http://chocolatey.org/api/v1/package/chocolatey to C:\Users\ADMINI1\AppData\Local\Temp\2\chocolatey\chocInstall\chocolatey.zip
Extracting C:\Users\ADMINI
1\AppData\Local\Temp\2\chocolatey\chocInstall\chocolatey.zip to ...
Exception calling "NameSpace" with "1" argument(s): "Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))"
At line:35 char:42

  • $zipPackage = $shellApplication.NameSpace <<<< ($file)
    • CategoryInfo : NotSpecified: (:) [], MethodInvocationException
    • FullyQualifiedErrorId : ComMethodTargetInvocation

You cannot call a method on a null-valued expression.
At line:37 char:46

  • $destinationFolder.CopyHere($zipPackage.Items <<<< (),0x10)
    • CategoryInfo : InvalidOperation: (Items:String) [], RuntimeException
    • FullyQualifiedErrorId : InvokeMethodOnNull

Installing chocolatey on this machine
The term 'C:\Users\ADMINI~1\AppData\Local\Temp\2\chocolatey\chocInstall\tools\chocolateyInstall.ps1' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:44 char:2

  • & <<<< $chocInstallPS1
    • CategoryInfo : ObjectNotFound: (C:\Users\ADMINI...ateyInstall.ps1:String) [], CommandNotFoundException
    • FullyQualifiedErrorId : CommandNotFoundException

Ensuring chocolatey commands are on the path
Updating chocolatey to the latest version
The term 'cup' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:60 char:4

  • cup <<<< chocolatey
    • CategoryInfo : ObjectNotFound: (cup:String) [], CommandNotFoundException
    • FullyQualifiedErrorId : CommandNotFoundException
@ferventcoder
Copy link
Contributor

interesting that you would use BITS...

@Iristyle
Copy link
Contributor Author

Iristyle commented Feb 6, 2012

BITS works surprisingly well... except when you're over WinRM -- access denied due to security reasons, in case you were wondering. You need to use WebClient in that case.

Of course, one of the first things I do in my EC2 image bootstrapper scripts is install curl, so that I don't have to bother with either BITS or WebClient. Much more friendly when dealing with redirects, custom headers, POST data, etc, etc.

@ferventcoder
Copy link
Contributor

Maybe choco should use Curl - how does it do with proxies?

@Iristyle
Copy link
Contributor Author

Iristyle commented Feb 6, 2012

http://curl.haxx.se/docs/manpage.html
Anything you could want to do, it can do... at least in my experience...

My example above was less about the download mechanism though, and more about grabbing 7z to use to unzip on Server Core though. Other alternatives that I can think of

  • Download and use a 3rd party asm like SharpZipLib
  • Install PsCx (potentially with PsGet) and get access to some zip cmdlets like Read-Archive
  • Stash some code in embedded C# and compile on the fly in PowerShell

Obviously it's up to you, but I would vote for the lightest / simplest / fastest / most side effect-free way to get zip support. 7z fits the bill for me, but I own my servers and maybe there's another better general purpose way that works for everyone.

@Iristyle
Copy link
Contributor Author

Also discussed in the forum here.

Another newer option (for the sake of completeness) is System.IO.Compression.ZipArchive, but that's .NET 4.5 only. Probably don't want that as a dependency.

My vote at this point is to ship the SharpZipLib ASM along with Chocolatey, as that will give the most bang for the buck in implementation cost. It's probably the most robust, as 7zip does require the C++ runtime which might not be installed on target systems. PsCx introduces a whole bunch of extra goop.

For reference -- here are the file sizes.

  • SharpZipLib 0.86.0.518 for .NET Fx 2.0+ is 196KB
  • DotNetZip (reduced.. whatever that is) 1.9 is 248KB

I think the ultimate best solution is to just embed the C# parts of SharpZipLib needed to unzip files, but someone will have to rip through that code and make it part of Chocolatey.

@Iristyle
Copy link
Contributor Author

A nice single file embed option looks to be ZipStorer. I don't know much about this one... but some of the comments seem to indicate that the goal is exactly the one we would have with Chocolatey -- swap out COM shell stuff with something simple and small in .NET.

@poehlert
Copy link

poehlert commented Jul 7, 2013

Though it's not ideal, Server core and in fact all windows for ages have included expand.exe to extract .cab files. This is part of windows setup so isn't like to change... well really ever. For early boot-strapping, it works well though I haven't found it particularly adept at compressing things.

@ghost ghost assigned ferventcoder Oct 11, 2013
@ferventcoder
Copy link
Contributor

This is in 97b94b2 and 5a9d396. This closes #297

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants