OneGet / NanoServerPackage

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

"Unexpected end when deserializing object" during Install-NanoServerPackage -Name Microsoft-NanoServer-IIS-Package

mikebridge opened this issue · comments

I'm trying to set up a Docker image from microsoft/nanoserver with this Dockerfile

FROM microsoft/nanoserver
SHELL ["powershell"]
RUN [System.Environment]::OSVersion 
RUN Install-PackageProvider NuGet -Force -RequiredVersion 2.8.5.205
RUN Install-PackageProvider -Force NanoServerPackage
RUN Import-PackageProvider NanoServerPackage
    
RUN Install-NanoServerPackage -Name Microsoft-NanoServer-IIS-Package
# ...
CMD ["ping", "-t", "localhost"]  

The line installing Microsoft-NanoServer-IIS-Package gives me this error:

Step 7/12 : RUN Install-NanoServerPackage -Name Microsoft-NanoServer-IIS-Package
 ---> Running in 81eac4a5af3e
ConvertFrom-Json : Unexpected end when deserializing object. Path '', line 1, position 5.
At C:\Program Files\WindowsPowerShell\Modules\NanoServerPackage\1.0.1.0\NanoServerPackage.psm1:833 char:44
+         $searchData = $searchFileContent | ConvertFrom-Json
+                                            ~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [ConvertFrom-Json], JsonSerializationException
    + FullyQualifiedErrorId : Newtonsoft.Json.JsonSerializationException,Microsoft.PowerShell.Commands.ConvertFromJsonCommand

The command 'powershell Install-NanoServerPackage -Name Microsoft-NanoServer-IIS-Package' returned a non-zero code: 1

So I commented out the one line, built the image, started a container, and opened a shell:

> docker build -t iis_test . 
> docker run -it iis_test powershell

Then on the container I get a similar error:

PS C:\> find-nanoserverPackage -name *
WARNING: Unexpected end when deserializing object. Path '', line 1, position 5.
PS C:\>

I'm not sure what these two errors mean---it looks like they're not downloading JSON. Any idea what to do from there?

Looks like I must be using an unsupported version of nanoserver. In this line it's checking for a $systemSKU value. On my system (10.0.14393.693) it's 149.

> Get-CimInstance -ClassName win32_operatingsystem | select OperatingSystemSKU

OperatingSystemSKU
------------------
               149

When I hack the script to allow version 149 it tells me that Install-NanoServerPackage : Microsoft-NanoServer-IIS-Package cannot be installed on this edition of NanoServer---so I suspect maybe this isn't going to work....

Hey @mikebridge, I came across this exact issue myself. I found in the readme (https://github.com/OneGet/NanoServerPackage) that the NanoServerPackage provider fails in Windows containers and I successfully worked around the problem with their recommended method of using DISM. It's just worth noting that the first 2 attempts to install the cab file using DISM fail, but re-running DISM straight after for each cab file then install successfully.

@cvandal Thanks, I'll give that a shot. I went back to linux container for the time being but would like to get this working.

I was able to work around this on a nanoserver container by using the -Raw parameter of Get-Content:

Get-Content 'foo.json' -Raw | ConvertFrom-Json

@stevencohn can you give some more details?