Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to validate a dynamic365 solution file before import using powershell or shell script

How to validate a dynamic365 solution file before import using powershell or shell script. The requirement is to validate it before import through a azure devops pipeline.

I have tried multiple Azure devops tasks but couldn’t get success. The power app solution file only gives errors during import but we need it before import.
Also tried installing powerApps CLI but it’s not giving the desired reults.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You should be able to do it using a powershell script.

param(
    [Parameter(Mandatory=$true)]
    [string]$SolutionFilePath
)

# Define the Common Data Service (CDS) environment URL
$environmentUrl = "https://<your-environment-name>.crm.dynamics.com"

# Import the required PowerShell modules
Import-Module Microsoft.PowerApps.Administration.PowerShell -DisableNameChecking
Import-Module Microsoft.Xrm.Data.Powershell -DisableNameChecking

try {
    # Connect to the Common Data Service environment
    Connect-PowerAppsEnvironment -EnvironmentUrl $environmentUrl

    # Validate the PowerApp solution file
    $validationResult = Test-AppSolution -Path $SolutionFilePath

    # Check the validation result
    if ($validationResult.IsValid) {
        Write-Host "PowerApp solution file is valid."
    }
    else {
        Write-Host "PowerApp solution file is not valid."
        Write-Host "Validation errors:"
        $validationResult.ValidationFailures | ForEach-Object {
            Write-Host "- $($_.Message)"
        }
    }
}
catch {
    Write-Host "An error occurred while validating the PowerApp solution file:"
    Write-Host $_.Exception.Message
}
finally {
    # Disconnect from the Common Data Service environment
    Disconnect-PowerAppsEnvironment
}

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading