Private/Install-PreRequisites.ps1

function Install-PreReqs {
    $message = "Checking Pre-requisites"
    Write-Host $message

    try {
        Invoke-InstallPreRequisites
        $global:devops_configFile.PreReqsComplete = "True"
    }
    catch {
        Write-Host $_
        $global:devops_configFile.PreReqsComplete = "Error"
        pause
    }
    $global:devops_configFile | ConvertTo-Json | Set-Content ("$env:APPDATA\Microsoft.PowerPlatform.DevOps\devopsConfig.json")
   
}

function Invoke-InstallPreRequisites {

    [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
    $ProgressPreference = 'SilentlyContinue'
    if (!$env:ChocolateyInstall -or !(Test-Path $env:ChocolateyInstall\choco.exe)) {
        Write-Warning "The ChocolateyInstall environment variable was not found. `n Chocolatey is not detected as installed. Installing..."
        $message = "Installing Chocolatey ...."
        Write-Host $message
        
        Set-ExecutionPolicy Bypass -Scope Process -Force; Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
    }

    choco upgrade chocolatey -y
 
    $message = "Installing Git ...."
    Write-Host $message

    choco upgrade git.install -y

    $message = "Installing NodeJS ...."
    Write-Host $message

    choco upgrade nodejs-lts -y

    $message = "Installing Azure CLI ...."
    Write-Host $message
    choco upgrade azure-cli -y 

    $message = "Installing dotnet CLI ...."
    Write-Host $message

    choco upgrade dotnetcore -y

    $message = "Installing nano ...."
    Write-Host $message

    set-alias nano 'C:\Program Files\Git\usr\bin\nano.exe'
    
    Restart-PowerShell

    ## Install Azure DevOps Extension
    $message = "Installing azure-devops extenstion"
    Write-Host $message

    az extension add --name azure-devops
    az extension update --name azure-devops

    if (!(Test-Path "$env:APPDATA\Microsoft.PowerPlatform.DevOps")) {
        New-Item -Path "$env:APPDATA\Microsoft.PowerPlatform.Devops" -ItemType Directory
    }
    if (!(Test-Path "$env:APPDATA\Microsoft.PowerPlatform.DevOps\devopsConfig.json")) {
        Copy-Item (Join-Path $PSScriptRoot "..\devopsConfig.json") -Destination "$env:APPDATA\Microsoft.PowerPlatform.DevOps\devopsConfig.json"
    }

    $global:devops_configFile = Get-Content ("$env:APPDATA\Microsoft.PowerPlatform.DevOps\devopsConfig.json") | ConvertFrom-Json
    $global:devops_configFile.PreReqsComplete = "True"
    $global:devops_configFile | ConvertTo-Json | Set-Content ("$env:APPDATA\Microsoft.PowerPlatform.DevOps\devopsConfig.json")


}

function Restart-PowerShell {
    Start-Sleep -Seconds 5
    refreshenv
    $env:Path = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path", "User") 
    if (!$VerbosePreference -eq "Continue") {
    Clear-Host    
}
}