【发布时间】:2022-10-13 09:28:50
【问题描述】:
我正在创建一个只解压缩文件的 Chocolatey 包。我想让用户选择解压缩的位置。 Others have tried to do the same thing, and the answer was to use an environment variable。
看起来像there's an environment variable just for this purpose:ChocolateyToolsLocation
这是我的chocolateyinstall.ps1:
$ErrorActionPreference = 'Stop'; # stop on all errors
$toolsDir = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)"
$installationDir = "$(Get-ToolsLocation)"
$fileLocation = Join-Path $toolsDir 'MyApp.zip'
$packageArgs = @{
packageName = $env:ChocolateyPackageName
unzipLocation = $installationDir
file = $fileLocation
softwareName = 'myapp*' #part or all of the Display Name as you see it in Programs and Features. It should be enough to be unique
}
Get-ChocolateyUnzip $fileLocation $installationDir
所以这里有两个概念:
- “工具目录”-
C:\ProgramData\chocolatey\lib\myapp - “工具位置”-
$env:ChocolateyToolsLocation
我有这个权利吗?如果用户希望更改安装目录,则应更改“工具位置”,但“工具目录”始终是 Chcolatey 在其 lib 目录中解压缩包的位置?
【问题讨论】:
标签: chocolatey