Chocolatey 找不到 windows 功能
Chocolatey can't find windows feature
我正在使用 Octopus 部署到 运行 目标计算机上的 PowerShell 脚本,尝试安装 IIS
。我正在使用下面的脚本并传递必要的参数。记录的内容让人相信调用是正确的,但它只是响应:
正在从 Chocolatey
软件包存储库安装软件包 IIS-WebServerRole
...
17:11:48Info
Installing the following packages:
17:11:48Info
IIS-WebServerRole
17:11:48Info
By installing you accept licenses for the packages.
17:11:48Info
IIS-WebServerRole not installed. The package was not found with the source(s) listed.
17:11:48Info
If you specified a particular version and are receiving this message, it is possible that the package name exists but the version does not.
17:11:48Info
Version: ""
17:11:48Info
Source(s): "windowsFeatures"
代码:
$chocolateyBin = [Environment]::GetEnvironmentVariable("ChocolateyInstall", "Machine") + "\bin"
if(-not (Test-Path $chocolateyBin)) {
Write-Output "Environment variable 'ChocolateyInstall' was not found in the system variables. Attempting to find it in the user variables..."
$chocolateyBin = [Environment]::GetEnvironmentVariable("ChocolateyInstall", "User") + "\bin"
}
$cinst = "$chocolateyBin\cinst.exe"
$choco = "$chocolateyBin\choco.exe"
if (-not (Test-Path $cinst) -or -not (Test-Path $choco)) {
throw "Chocolatey was not found at $chocolateyBin."
}
if (-not $ChocolateyPackageId) {
throw "Please specify the ID of an application package to install."
}
$chocoVersion = & $choco --version
Write-Output "Running Chocolatey version $chocoVersion"
$chocoArgs = @()
if([System.Version]::Parse($chocoVersion) -ge [System.Version]::Parse("0.9.8.33")) {
Write-Output "Adding --confirm to arguments passed to Chocolatey"
$chocoArgs += @("-y", "")
}
if($ChocolateyPackageSource) {
Write-Output "Adding --source to arguments passed to Chocolatey"
$chocoArgs += @("-source", $ChocolateyPackageSource)
}
if (-not $ChocolateyPackageVersion) {
Write-Output "Installing package $ChocolateyPackageId from the Chocolatey package repository..."
& $cinst $ChocolateyPackageId $($chocoArgs)
} else {
Write-Output "Installing package $ChocolateyPackageId version $ChocolateyPackageVersion from the Chocolatey package repository..."
& $cinst $ChocolateyPackageId -version $ChocolateyPackageVersion $($chocoArgs)
}
根据我能找到的最新 Chocolatey 文档,这应该可行。任何想法为什么不会?我应该提到这是在 Azure Windows 2012 R2 VM 上。
我可以通过碰碰巧克力的预发布版本来实现这一点。 9.10.x-测试版...
我应该注意,仅执行 -pre 不足以让它安装包...出于某种原因,我还必须 -force 包让 chocolatey 自行更新。不确定这是否是设计使然。
我正在使用 Octopus 部署到 运行 目标计算机上的 PowerShell 脚本,尝试安装 IIS
。我正在使用下面的脚本并传递必要的参数。记录的内容让人相信调用是正确的,但它只是响应:
正在从 Chocolatey
软件包存储库安装软件包 IIS-WebServerRole
...
17:11:48Info
Installing the following packages:
17:11:48Info
IIS-WebServerRole
17:11:48Info
By installing you accept licenses for the packages.
17:11:48Info
IIS-WebServerRole not installed. The package was not found with the source(s) listed.
17:11:48Info
If you specified a particular version and are receiving this message, it is possible that the package name exists but the version does not.
17:11:48Info
Version: ""
17:11:48Info
Source(s): "windowsFeatures"
代码:
$chocolateyBin = [Environment]::GetEnvironmentVariable("ChocolateyInstall", "Machine") + "\bin"
if(-not (Test-Path $chocolateyBin)) {
Write-Output "Environment variable 'ChocolateyInstall' was not found in the system variables. Attempting to find it in the user variables..."
$chocolateyBin = [Environment]::GetEnvironmentVariable("ChocolateyInstall", "User") + "\bin"
}
$cinst = "$chocolateyBin\cinst.exe"
$choco = "$chocolateyBin\choco.exe"
if (-not (Test-Path $cinst) -or -not (Test-Path $choco)) {
throw "Chocolatey was not found at $chocolateyBin."
}
if (-not $ChocolateyPackageId) {
throw "Please specify the ID of an application package to install."
}
$chocoVersion = & $choco --version
Write-Output "Running Chocolatey version $chocoVersion"
$chocoArgs = @()
if([System.Version]::Parse($chocoVersion) -ge [System.Version]::Parse("0.9.8.33")) {
Write-Output "Adding --confirm to arguments passed to Chocolatey"
$chocoArgs += @("-y", "")
}
if($ChocolateyPackageSource) {
Write-Output "Adding --source to arguments passed to Chocolatey"
$chocoArgs += @("-source", $ChocolateyPackageSource)
}
if (-not $ChocolateyPackageVersion) {
Write-Output "Installing package $ChocolateyPackageId from the Chocolatey package repository..."
& $cinst $ChocolateyPackageId $($chocoArgs)
} else {
Write-Output "Installing package $ChocolateyPackageId version $ChocolateyPackageVersion from the Chocolatey package repository..."
& $cinst $ChocolateyPackageId -version $ChocolateyPackageVersion $($chocoArgs)
}
根据我能找到的最新 Chocolatey 文档,这应该可行。任何想法为什么不会?我应该提到这是在 Azure Windows 2012 R2 VM 上。
我可以通过碰碰巧克力的预发布版本来实现这一点。 9.10.x-测试版...
我应该注意,仅执行 -pre 不足以让它安装包...出于某种原因,我还必须 -force 包让 chocolatey 自行更新。不确定这是否是设计使然。