如何将安装日志路径传递给 chocolatey 中的 MSI?
How do I pass the install log path to an MSI in chocolatey?
在 chocolateyInstall.ps1 脚本中可以运行并安装包:
Install-ChocolateyPackage 'GoogleChrome' msi /qn /L*V $toolsDir\GoogleChrome.msi
这给了我一个错误:
Install-ChocolateyPackage 'GoogleChrome' msi /qn /L*V C:\Windows\temp\GoogleChrome_install.log $toolsDir\GoogleChrome.msi
Attempt to use original download file name failed for 'C:\Windows\temp\GoogleChrome_install.log'.
Copying GoogleChrome
from 'C:\Windows\temp\GoogleChrome_install.log'
Cannot find path 'C:\Windows\temp\GoogleChrome_install.log' because it does not exist.
ERROR: Chocolatey expected a file to be downloaded to 'C:\Users\Administrator\AppData\Local\Temp\chocolatey\GoogleChro
me.0.2840.71\GoogleChromeInstall.msi' but nothing exists at that location.
The install of googlechrome was NOT successful.
Error while running 'C:\ProgramData\chocolatey\lib\GoogleChrome\tools\chocolateyInstall.ps1'.
See log for details.
Chocolatey installed 0/1 packages. 1 packages failed.
See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).
我建议 运行 choco new
(来自最新版本的 Chocolatey)。您调用的方法和调用方式有点过时了。
您需要将所有静默参数作为一个参数传递,现在它根据空格将参数拆分:
$silentArgs = "/qn /norestart /l*v `"$env:Temp\GoogleChrome_install.log`""
Install-ChocolateyPackage 'GoogleChrome' msi $silentArgs $toolsDir\GoogleChrome.msi
这是更新的 chocolateyInstall.ps1 文件的样子:
$ErrorActionPreference = 'Stop'
$packageName = 'Google-Chrome'
$toolsDir = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)"
$fileLocation = Join-Path $toolsDir 'GoogleChrome.msi'
$fileLocation64 = Join-Path $toolsDir 'GoogleChrome64.msi'
if (Get-ProcessorBits 64) {
$forceX86 = $env:chocolateyForceX86
if ($forceX86 -eq 'true') {
Write-Debug "User specified '-x86' so forcing 32-bit"
} else {
$fileLocation = $fileLocation64
}
}
$packageArgs = @{
packageName = $packageName
softwareName = 'Google Chrome*'
file = $fileLocation
fileType = 'msi'
silentArgs = "/qn /norestart /l*v `"$env:Temp\GoogleChrome_install.log`""
validExitCodes= @(0,1641,3010)
}
Install-ChocolateyInstallPackage @packageArgs
在 chocolateyInstall.ps1 脚本中可以运行并安装包:
Install-ChocolateyPackage 'GoogleChrome' msi /qn /L*V $toolsDir\GoogleChrome.msi
这给了我一个错误:
Install-ChocolateyPackage 'GoogleChrome' msi /qn /L*V C:\Windows\temp\GoogleChrome_install.log $toolsDir\GoogleChrome.msi
Attempt to use original download file name failed for 'C:\Windows\temp\GoogleChrome_install.log'.
Copying GoogleChrome
from 'C:\Windows\temp\GoogleChrome_install.log'
Cannot find path 'C:\Windows\temp\GoogleChrome_install.log' because it does not exist.
ERROR: Chocolatey expected a file to be downloaded to 'C:\Users\Administrator\AppData\Local\Temp\chocolatey\GoogleChro
me.0.2840.71\GoogleChromeInstall.msi' but nothing exists at that location.
The install of googlechrome was NOT successful.
Error while running 'C:\ProgramData\chocolatey\lib\GoogleChrome\tools\chocolateyInstall.ps1'.
See log for details.
Chocolatey installed 0/1 packages. 1 packages failed.
See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).
我建议 运行 choco new
(来自最新版本的 Chocolatey)。您调用的方法和调用方式有点过时了。
您需要将所有静默参数作为一个参数传递,现在它根据空格将参数拆分:
$silentArgs = "/qn /norestart /l*v `"$env:Temp\GoogleChrome_install.log`""
Install-ChocolateyPackage 'GoogleChrome' msi $silentArgs $toolsDir\GoogleChrome.msi
这是更新的 chocolateyInstall.ps1 文件的样子:
$ErrorActionPreference = 'Stop'
$packageName = 'Google-Chrome'
$toolsDir = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)"
$fileLocation = Join-Path $toolsDir 'GoogleChrome.msi'
$fileLocation64 = Join-Path $toolsDir 'GoogleChrome64.msi'
if (Get-ProcessorBits 64) {
$forceX86 = $env:chocolateyForceX86
if ($forceX86 -eq 'true') {
Write-Debug "User specified '-x86' so forcing 32-bit"
} else {
$fileLocation = $fileLocation64
}
}
$packageArgs = @{
packageName = $packageName
softwareName = 'Google Chrome*'
file = $fileLocation
fileType = 'msi'
silentArgs = "/qn /norestart /l*v `"$env:Temp\GoogleChrome_install.log`""
validExitCodes= @(0,1641,3010)
}
Install-ChocolateyInstallPackage @packageArgs