Hi, me again. So, I'm a bit "stuck", and I'm sure it's silly but I can't find a good answer. I've got a Chocolatey Package that is downloading the latest offline ProGet installer, extracting it and attempting to install it silently.
I've had to do a bit of "magic" as the offline installer appears to not include hub.exe, so I've monkey-patched that in and I'm getting the following when actually invoking an install:
A fatal error was encountered. The library 'hostpolicy.dll' required to execute the application was not found in 'C:\Program Files\dotnet\'.
Failed to run as a self-contained app.
- The application was run as a self-contained app because 'C:\ProgramData\chocolatey\lib\proget\tools\InedoTemp\hub.runtimeconfig.json' did not specify a framework.
- If this should be a framework-dependent app, specify the appropriate framework in 'C:\ProgramData\chocolatey\lib\proget\tools\InedoTemp\hub.runtimeconfig.json'.
ERROR:
Running ['C:\ProgramData\chocolatey\lib\proget\tools\InedoTemp\hub.exe' install Proget:2024.9.0 --ConnectionString='Data Source=localhost\SQLEXPRESS; Integrated Security=True;' --TargetDirectory='C:\Program Files\ProGet' --UseIIS=true UseIntegratedWebServer=false] was not successful.
Exit code was '-2147450749' See log for possible error messages..
The install of proget was NOT successful.
Error while running 'C:\ProgramData\chocolatey\lib\proget\tools\chocolateyInstall.ps1'.
See log for details.
For completeness here is the chocolateyInstall.ps1 file I'm using. I appreciate there's some helper functions from Choco and one I wrote for getting the latest installer bits, but should be self-explanatory:
$ErrorActionPreference = 'Stop'
$toolsDir = Split-Path -Parent $MyInvocation.MyCommand.Definition
$helpers = Join-Path $toolsDir -ChildPath 'helpers.ps1'
$unzipPath = New-Item (Join-Path $toolsDir -ChildPath 'InedoTemp') -ItemType Directory
$hub = Join-Path $toolsDir -ChildPath 'hub.zip'
$pp = Get-PackageParameters
#Load helpers
. $helpers
# Download Offline Installer
$ProGet = Get-ProGetInstaller
$ProGetInstaller = Join-Path $toolsDir -ChildPath (Split-Path -Leaf $ProGet.Downloads)
$webFileArgs = @{
Packagename = $env:ChocolateyPackageName
FileFullPath = $ProGetInstaller
Url = $ProGet.Downloads
Checksum = '03CD312905CF735DE36B303FF28C63880B1B7AFD4A458D69280EAB88F546BD29'
checksumType = 'SHA256'
}
Get-ChocolateyWebFile @webFileArgs
# Extract Offline Installer
$unzipArgs = @{
Packagename = $env:ChocolateyPackageName
FileFullPath = $ProGetInstaller
Destination = $unzipPath
}
Get-ChocolateyUnzip @unzipArgs
#Copy Hub.exe to extracted directory
$unzipArgs = @{
Packagename = $env:ChocolateyPackageName
FileFullPath = $hub
Destination = $unzipPath
}
Get-ChocolateyUnzip @unzipArgs
#Install the sumbitch
#Set the connectionString
$ConnectionString = if ($pp['ConnectionString']) {
$pp['ConnectionString']
}
else {
'Data Source=localhost\SQLEXPRESS; Integrated Security=True;'
}
#Set the TargetDir
$ProGetDestination = if ($pp['InstallDir']) {
$pp['InstallDir']
}
else {
if (-not (Test-Path (Join-path $env:ProgramFiles -ChildPath 'ProGet'))) {
$null = New-Item (Join-path $env:ProgramFiles -ChildPath 'ProGet') -ItemType Directory
} else {
Join-Path $env:ProgramFiles -ChildPath 'ProGet'
}
}
$hubExe = Join-Path $unzipPath -ChildPath 'hub.exe'
$installArgs = @{
Statements = @('install', "Proget:$($env:ChocolateyPackageVersion)", "--ConnectionString='$ConnectionString'", "--TargetDirectory='$ProgetDestination'",'--UseIIS=true','UseIntegratedWebServer=false')
ExeToRun = $hubExe
validExitCodes = @(0)
}
Start-ChocolateyProcessAsAdmin @installArgs
#Secure with SSL?
Any pointers here would be superbly appreciated.