Build Azure DevOps Pipelines for Dynamics 365 CRM/Power Platform- Part 3
Release pipeline: Deploy to a production/test environment
In this pipeline we are going to repack the solution from the repository and deploy it to SIT/Production environment as a managed solution, so that Azure DevOps will be the source of truth and you don’t have to do it manually and also we can maintain solution history .
Follow below link to export solution from development environment.
Create a new pipeline
To create a new pipeline, follow the same steps we have used earlier.
PowerApps Tools Installer
Add a task to Install PowerApps Tools Installer.
Power Platform Pack Solution
Here you need to configure some additional settings.
Source folder of solution to pack
This is the path where your solution files are stored in the repository.
Solution Output File
For managed solution:
$(Build.ArtifactStagingDirectory)\$(SolutionName)_managed.zip

For unmanged solution:
$(Build.ArtifactStagingDirectory)\$(SolutionName).zip
Variable
Specify your solution name under variables tab.
Type of Solution
It can be Unmanaged or Managed.
For managed solution:
Power Platform Import Solution
Now we need to import it to our destination environment.
Add the Power Platform Import Solution step to the pipeline.
Service Connection
As we already have our service connection configured, so we can re-use that.
Solution Input File
In this case Input file location is the temporary folder where we have stored our packed solution.
Managed:
$(Build.ArtifactStagingDirectory)\$(SolutionName)_managed.zip

Power Platform Publish Customizations
For unmanaged solution only, you just need to add one more task for Power Platform Publish Customizations.
Run the Pipeline
We going to follow the same steps that we have used earlier to run the pipeline.
View pipeline reports
A summary of the pass rate and duration can be viewed in the Analytics tab of a pipeline. To drill into the trend and insights, click on the card to view the full report.

Release pipeline: Import solution from Dev to Production
In case you want to export solution from dev and import it to testing or production environment directly, please follow below steps.
Add a task to Install PowerApps Tools Installer.
Add the PowerApps Export Solution task to the pipeline, now we need to configure specific properties here.
As we already have our source environment service connection configured, so we can re-use that for environment URL and we will again specify our solution name under variables tab.
Solution Output File
$(Build.ArtifactStagingDirectory)\$(SolutionName)_managed.zip
Select Export as managed solution.
Power Platform Import Solution
Now we need to import it to our destination environment, add the Power Platform Import Solution step to the pipeline and add destination environment service connection configured.
Solution Input File
In this case Input file location is the temporary folder where we have stored our solution after exporting it from source environment.
$(Build.ArtifactStagingDirectory)\$(SolutionName)_managed.zip
Run the Pipeline
Now we going to follow the same steps that we have used earlier to run the pipeline.
Schedule Pipelines
Select the days and times when you want to run the build.
If your repository is Azure Repos Git, GitHub, or Other Git, then you can also specify branches to include and exclude.
Here you can also choose to run a pipeline if the code has changed since the last successful scheduled run, for master and all releases/* branches, for that simply select ‘Only schedule builds if the source or pipeline has changed’ option.
