Welcome to the Inedo Forums! Check out the Forums Guide for help getting started.

If you are experiencing any issues with the forum software, please visit the Contact Form on our website and let us know!

Silent installation of ProGet



  • I'm attempting to generate a Chocolatey package, which I can host on the Chocolatey Community Repository to install ProGet. I've found the OfflineInstaller downloads at https://my.inedo.com/downloads/installers?Product=ProGet and the documentation for silent installation at https://docs.inedo.com/docs/installation-windows-silent however this is all very confusing/conflicting with https://docs.inedo.com/docs/desktophub-offline, specifically this:
    a411d54a-c21d-4218-bc44-a27b724be75f-image.png

    I can't find the clear path to be able to silently control the installation of ProGet through the use of Chocolatey. I am just....thoroughly confused at the minute :D


  • inedo-engineer

    Hi @steviecoaster,

    If you want to use the offline installer in a script (which I think is best for a Chocolatey script), then just unzip it after downloading. I know it's an .exe file, but you can just unzip it like any other zip file (e.g. with Expand-Archive or something in PowerShell).

    Once you've done that, you can just run the hub.exe per the silent installation instructions.

    Alternatively, you can write a script like this, which will instruct hub.exe to download a version:

    # create working directories
    mkdir C:\InedoHub
    cd C:\InedoHub
    
    # download and extract file to working directory
    Invoke-WebRequest "https://proget.inedo.com/upack/Products/download/InedoReleases/DesktopHub?contentOnly=zip&latest" -OutFile C:\InedoHub\InedoHub.zip
    Expand-Archive -Path InedoHub.zip -DestinationPath C:\InedoHub
    
    # perform silent installation
    hub.exe install ProGet:5.2.3 --ConnectionString="Data Source=localhost; Integrated Security=True;"
    

    The only downside to this approach is that it's not really version controlled (i.e. it's always using latest Inedo Hub) and the package can't be realizably internalized, since hub.exe will download files from the internet.

    -- Dean



  • And that is the part that wasn't clicking for me. I missed it was a self-extracting .exe Awesome, I can use Install-ChocolateyZipPackage as a base, and then go from there. Perfect!



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


  • inedo-engineer

    Hi @steviecoaster ,

    Sorry about giving the bad advice there -- I did not realize that the offline installer does not include the hub.exe program. It looks like the Offline Installer Creation Process must strip that from the offline installer we provide.

    As you discovered, the advice from before wouldn't really work. Without doing a deep dive in the code, I don't know how to make it work. This isn't a use case we designed for, and I'd hate to send you down a wild goose chase.

    How about just using our standard silent installation approach, which I shared before:

    # create working directories
    mkdir C:\InedoHub
    cd C:\InedoHub
    
    # download and extract file to working directory
    Invoke-WebRequest "https://proget.inedo.com/upack/Products/download/InedoReleases/DesktopHub?contentOnly=zip&latest" -OutFile C:\InedoHub\InedoHub.zip
    Expand-Archive -Path InedoHub.zip -DestinationPath C:\InedoHub
    
    # perform silent installation
    hub.exe install ProGet:5.2.3 --ConnectionString="Data Source=localhost; Integrated Security=True;"
    

    This will basically install the desired version and it's likely "good enough" for the time being.

    -- Dean


Log in to reply
 

Inedo Website HomeSupport HomeCode of ConductForums GuideDocumentation