设置自定义Chocolatey包时出现空键错误

时间:2017-11-22 15:55:26

标签: null chocolatey

我正在尝试创建一个自定义的Chocolatey软件包,该软件包将使用文件共享中的msi文件,并且我收到以下错误。我可以在此过程中排除大部分错误,但我无法解决这个问题。

有谁知道如何解决这个问题或知道如何调试问题?

错误

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'.

下面是我的nuspec文件和我的chocolateyinstall.ps1文件的副本。

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

1 个答案:

答案 0 :(得分:2)

我怀疑您看到的错误是由于未定义的变量$file。因此,您在哈希文字中获得了一个没有任何价值的密钥。

将其更改为以下内容:

$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