Private/Select-Solution.ps1
function Invoke-ExportData { Param( [string] [Parameter(Mandatory = $true)] $StartPath, [string] [Parameter(Mandatory = $true)] $SelectedSolution ) try { $ProgressPreference = 'SilentlyContinue' $message = @" ____ _ _____ _ | _ \ __ _| |_ __ _ | ____|_ ___ __ ___ _ __| |_ | | | |/ _' | __/ _' | | _| \ \/ / '_ \ / _ \| '__| __| | |_| | (_| | || (_| | | |___ > <| |_) | (_) | | | |_ |____/ \__,_|\__\__,_| |_____/_/\_\ .__/ \___/|_| \__| |_| v2 "@ Write-Host $message Write-Host "" Write-Host "Running for path : " $StartPath Get-ConfigJSON($StartPath) $message = "Installing Data Management Tools..." Write-Host $message $message = "Establishing connection to $global:devops_ServerUrl" Write-Host $message $conn = Get-DataverseConnection($global:devops_ServerUrl) if ($conn.IsReady) { try { # PRE ACTION if (Test-Path -Path $global:devops_projectLocation\$SolutionName\Scripts\ExportPreAction.ps1) { Write-Host "Execute Pre Action from $global:devops_projectLocation\$SolutionName\Scripts" . $global:devops_projectLocation\$SolutionName\Scripts\ExportPreAction.ps1 -Conn $conn } else { Write-Host "Data Export PreAction not enabled, create a file called ExportPreAction.ps1 in the Scripts folder if you wish to use one" -ForegroundColor Yellow } Write-Host "Exporting Data to $global:devops_projectLocation\$SolutionName\ReferenceData\data.zip" Export-CrmDataFile -CrmConnection $conn -SchemaFile "$global:devops_projectLocation\$SolutionName\ReferenceData\schema.xml" -DataFile "$global:devops_projectLocation\$SolutionName\ReferenceData\data.zip" -EmitLogToConsole # POST ACTION if (Test-Path -Path $global:devops_projectLocation\$SolutionName\Scripts\ExportPostAction.ps1) { Write-Host "Execute Pre Action from $global:devops_projectLocation\$SolutionName\Scripts" . $global:devops_projectLocation\$SolutionName\Scripts\ExportPostAction.ps1 -Conn $conn } else { Write-Host "Data Export PostAction not enabled, create a file called ExportPostAction.ps1 in the Scripts folder if you wish to use one" -ForegroundColor Yellow } } catch { Write-Host $_ pause } finally { Write-Host "Data Export Complete!!" Start-Sleep -Seconds 3 } } } catch { Write-Host $_ Pause } finally { } } function Get-ExportDataValid { if (!(Test-Path "$global:devops_projectLocation\$SolutionName\ReferenceData\schema.xml")) { if ((Test-Path "$global:devops_projectLocation\$SolutionName\ReferenceData\data_schema.xml")) { Write-Host "Converting Legacy Data Export to Config Migration" Move-Item -Path "$global:devops_projectLocation\$SolutionName\ReferenceData\data_schema.xml" -Destination "$global:devops_projectLocation\$SolutionName\ReferenceData\schema.xml" Invoke-ExportData -StartPath $global:devops_projectLocation -SelectedSolution $selectedSolution } Write-Host "" Write-Host "Schema.xml file not found, if you want to include Configuration Data, please run 'Configuration Data Create / Edit' first" -ForegroundColor Yellow } else { Invoke-ExportData -StartPath $global:devops_projectLocation -SelectedSolution $selectedSolution } } function Show-SolutionMenu { param ( [string]$SolutionName = '' ) Get-SolutionMenu -SolutionName $SolutionName $solutionSelection = Read-Host "Selection" try { switch ($solutionSelection) { 'E' { try { Invoke-ExportSolution -StartPath $global:devops_projectLocation -SelectedSolution $selectedSolution } catch { Write-Error $_ pause } } 'C' { try { Install-ConfigMigration Write-Host "Launching Configuration Migration Utility..." Write-Host "Please make sure to save the Schema file in $global:devops_projectLocation\$SolutionName\ReferenceData\schema.xml" -ForegroundColor Yellow Write-Host "This path has been placed in your Clipboard to Paste in the Save File Dialog" Set-Clipboard -Value "$global:devops_projectLocation\$SolutionName\ReferenceData\schema.xml" . $env:APPDATA\Microsoft.PowerPlatform.DevOps\ConfigMigration\DataMigrationUtility.exe pause } catch { Write-Error $_ pause } } 'D' { try { Get-ExportDataValid } catch { Write-Error $_ pause } } 'G' { Get-EarlyTypes -StartPath $global:devops_projectLocation -SelectedSolution $selectedSolution } 'P' { try { $CurrentLocation = Get-Location Set-Location $global:devops_projectLocation\$selectedSolution\spkl\ . .\deploy-plugins.bat pause Set-Location $CurrentLocation } catch { Write-Host $_ pause } } 'W' { try { $CurrentLocation = Get-Location Set-Location $global:devops_projectLocation\$selectedSolution\spkl\ . .\deploy-webresources.bat Set-Location $CurrentLocation pause } catch { Write-Host $_ pause } }'Q' { } } } catch { Write-Host $_ pause } } function Select-Solution { if ($global:devops_projectFile.DataverseSolutions.Count -gt 0) { $options = $global:devops_projectFile.DataverseSolutions | ForEach-Object { $_.SolutionName } do { $sel = Invoke-Menu -MenuTitle "---- Please Select the Dataverse Solution to Manage ------" -MenuOptions $options $selectedSolution = $global:devops_projectFile.DataverseSolutions[$sel].SolutionName } until ($selectedSolution -ne "") Set-Location -Path $global:devops_projectLocation if ($global:devops_projectFile.ADOConfigured -eq "True") { try { git pull origin } catch { pause } } Show-SolutionMenu -SolutionName $selectedSolution } } |