Scripts/SolutionExport.ps1

#
# SolutionExport.ps1
#

function Invoke-ExportSolution {
    Param(
        [string] [Parameter(Mandatory = $true)] $StartPath,
        [string] [Parameter(Mandatory = $true)] $SelectedSolution
    )

    try {

        Get-ExportDataValid

        $ProgressPreference = 'SilentlyContinue'

        $message = @"
 
____ _ _ _ _____ _
/ ___| ___ | |_ _| |_(_) ___ _ __ | ____|_ ___ __ ___ _ __| |_
\___ \ / _ \| | | | | __| |/ _ \| '_ \ | _| \ \/ / '_ \ / _ \| '__| __|
 ___) | (_) | | |_| | |_| | (_) | | | | | |___ > <| |_) | (_) | | | |_
|____/ \___/|_|\__,_|\__|_|\___/|_| |_| |_____/_/\_\ .__/ \___/|_| \__|
                                                   |_|
 
v2
"@

        Write-Host $message
        Write-Host ""    

        Write-Host "Running for path : " $StartPath
        Get-ConfigJSON($StartPath)

        $message = "Installing Solution Management Tools..."
        Write-Host $message

        #Install-XrmModule
        Install-PAC

        $message = "Establishing connection to $global:devops_ServerUrl"
        Write-Host $message

        $conn = Get-DataverseConnection($global:devops_ServerUrl)

        if ($conn.IsReady) {

            Set-DataverseSolutionVersion  
            Get-DataverseSolution "$StartPath\$SelectedSolution" $SelectedSolution
        }
    }
    catch {
        Write-Host $_
        pause
    }
    finally {
        ######################### CLEANING UP #########################
        $message = "Cleaning Up..."
        Write-Host $message
    
        Remove-Item (Join-Path $StartPath "nuget.exe") -ErrorAction Ignore -Force
        Remove-Item (Join-Path $StartPath "Tools") -Force -Recurse -ErrorAction Ignore
        Remove-Item (Join-Path $StartPath "*.zip") -Force -ErrorAction Ignore -Exclude "Publisher.zip"
        
        $message = "Complete ... Enjoy !!!"
        Write-Host $message
        
        pause
    }
}