Core/ThirdPartyDependencies-Module.psm1
$ErrorActionPreference = "Stop" function ConfigureChoco { $initChoco = $true try { choco | Out-Null choco upgrade chocolatey --limitoutput --confirm | Out-Null } catch { try { Invoke-WebRequest https://chocolatey.org/install.ps1 -UseBasicParsing | Invoke-Expression | Out-Null } catch { $initChoco = $false Write-Warning "SAF was not able to configure Chocolatey. You may need to install manually some third party dependencies." Start-Sleep 5 } } if ($initChoco) { choco feature enable -n allowGlobalConfirmation | Out-Null RefreshEnvironment } } function ConfigurePSGallery { $latestNuget = Find-PackageProvider -Name "NuGet" -Force $installedNuget = Get-PackageProvider -Name "Nuget" -ListAvailable | Select-Object -First 1 if ($latestNuget.version -gt $installedNuget.version) { Install-PackageProvider -Name "NuGet" -Source "PSGallery" -RequiredVersion $latestNuget.version -Force | Out-Null } Import-PackageProvider -Name "Nuget" -RequiredVersion $latestNuget.version -Force | Out-Null # Ensure Trusted, so that users are not prompted before installing modules from that source. Set-PSRepository -Name PSGallery -InstallationPolicy Trusted $latestPSGet = Find-PackageProvider -Name "PowerShellGet" $installedPSGet = Get-PackageProvider -Name "PowerShellGet" -ListAvailable | Select-Object -First 1 if ($latestPSGet.version -gt $installedPSGet.version) { Install-PackageProvider -Name "PowerShellGet" -Source "PSGallery" -RequiredVersion $latestPSGet.version -Force | Out-Null } Import-PackageProvider -Name "PowerShellGet" -RequiredVersion $latestPSGet.version -Force | Out-Null } function GetRequiredSIFVersion { if ($null -ne $SAFConfiguration.sitecore.version) { if ($SAFConfiguration.sitecore.version.Contains("9.0")) { return $SAFSitecore90SIFVersion } if ($SAFConfiguration.sitecore.version.Contains("9.1")) { return $SAFSitecore91SIFVersion } } return $SAFSitecore90SIFVersion } function ImportSIF { EnableIISAdministration $repositoryURL = "https://sitecore.myget.org/F/sc-powershell/api/v2" $repositoryName = "SitecoreGallery" $requiredSIFVersion = GetRequiredSIFVersion try { $existing = Get-PSRepository -Name $repositoryName -ErrorAction Ignore if ($null -eq $existing) { Register-PSRepository -Name $repositoryName -SourceLocation $repositoryURL -InstallationPolicy Trusted } $sifModules = Get-Module -Name SitecoreInstallFramework -ListAvailable $installRequiredSIFVersion = $true if ($null -ne $sifModules) { foreach ($module in $sifModules) { if ($module.Version -eq $requiredSIFVersion) { $installRequiredSIFVersion = $false } } } if ($installRequiredSIFVersion) { Install-Module -Name SitecoreInstallFramework -RequiredVersion $requiredSIFVersion -Repository $repositoryName -AllowClobber -Force } Get-Module -Name SitecoreInstallFramework | Remove-Module -Force Import-Module -Name SitecoreInstallFramework -RequiredVersion $requiredSIFVersion -Force -Global } catch { Write-Warning "SAF was not able to install the required SIF version $requiredSIFVersion. Please, install it manually if you don't have it..." Start-Sleep 5 Get-Module -Name SitecoreInstallFramework | Remove-Module -Force } } Export-ModuleMember -Function "ConfigureChoco" Export-ModuleMember -Function "ConfigurePSGallery" Export-ModuleMember -Function "ImportSIF" |