I'm trying to create a custom Chocolatey package that will use an msi file from a file share and I'm receiving the error below. I've be able to troubleshoot most of the error during this process, but I can't figure this one out.
Does anyone know how to solve this issue or know what I could do to debug the issue?
Error
ERROR: A null key is not allowed in a hash literal.
The install of ciscojabbertest2 was NOT successful.
Error while running 'C:\ProgramData\chocolatey\lib\ciscojabbertest2\tools\chocolateyinstall.ps1'.
Below is a copy of my nuspec file and my chocolateyinstall.ps1 file.
ciscojabbertest2.nuspec
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2015/06/nuspec.xsd">
<metadata>
<id>ciscojabbertest2</id>
<version>11.9.1.55716</version>
<title>ciscojabbertest2</title>
<authors>Cisco Systems, Inc</authors>
<tags>Installer_MSI_Database</tags>
<summary>Cisco Jabber</summary>
<description>Cisco Jabber</description>
</metadata>
<files>
<file src="tools\**" target="tools" />
</files>
</package>
chocolateyinstall.ps1
$ErrorActionPreference = 'Stop';
$toolsDir = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)"
$fileLocation = '\\WIN-5LEH3K6JCM3\Software_Test\CiscoJabberSetup.msi'
$packageArgs = @{
packageName = $env:ChocolateyPackageName
unzipLocation = $toolsDir
fileType = 'MSI'
$file = $fileLocation
softwareName = 'Cisco Jabber*'
checksum = 'A027601E0975339286EEECF593D83FF71FA64902B46A8F10F93B5E63663A215F'
checksumType = 'sha256'
silentArgs = "/quiet CLEAR=1"
validExitCodes= @(0, 3010, 1641)
}
Install-ChocolateyInstallPackage @packageArgs
I suspect that the error that you are seeing is due to the undefined variable $file
. As a result, you are getting a key in the hash literal that doesn't have any value.
Change it to the following:
$ErrorActionPreference = 'Stop';
$toolsDir = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)"
$fileLocation = '\\WIN-5LEH3K6JCM3\Software_Test\CiscoJabberSetup.msi'
$packageArgs = @{
packageName = $env:ChocolateyPackageName
unzipLocation = $toolsDir
fileType = 'MSI'
file = $fileLocation
softwareName = 'Cisco Jabber*'
checksum = 'A027601E0975339286EEECF593D83FF71FA64902B46A8F10F93B5E63663A215F'
checksumType = 'sha256'
silentArgs = "/quiet CLEAR=1"
validExitCodes = @(0, 3010, 1641)
}
Install-ChocolateyInstallPackage @packageArgs