# It is required to implement this function for the providers that support install-package.
function Install-Package {
    param (

    Write-Debug -Message ($LocalizedData.ProviderDebugMessage -f ('Install-Package'))
    Write-Debug -Message ($LocalizedData.FastPackageReference -f $FastPackageReference)

    # If the fast package preference doesnt match the pattern we expect, throw an exception
    if ((-not ($FastPackageReference -match $script:FastReferenceRegex)) -or (-not ($ -and $Matches.version))) {
        ThrowError -ExceptionName "System.ArgumentException" `
            -ExceptionMessage ($LocalizedData.FailToInstall -f $FastPackageReference) `
            -ErrorId 'FailToInstall' `
            -ErrorCategory InvalidArgument

    $shouldContinueQueryMessage = ($LocalizedData.InstallPackageQuery -f "Installing", $
    $shouldContinueCaption = $LocalizedData.InstallPackageCaption

    # If the user opts not to install the package, exit from the script
    if (-not (((Get-ForceProperty) -or (Get-AcceptLicenseProperty)) -or $request.ShouldContinue($shouldContinueQueryMessage, $shouldContinueCaption))) {
        Write-Warning ($LocalizedData.NotInstalled -f $FastPackageReference)

    $swid = Invoke-Choco -Install -Package $ -Version $Matches.version -SourceName $Matches.source | 
        Where-Object {Test-PackageVersion -Package $_ -RequiredVersion $Matches.version}

    if (-not $swid) {
        # Invoke-Choco didn't throw an exception but we also couldn't pull a Software Identity from the output.
        # The output format Choco.exe may have changed from what our regex pattern was expecting.
        Write-Warning ($LocalizedData.UnexpectedChocoResponse -f $FastPackageReference)