Menu
metio
website
  • home
  • contact

Wednesday, 15 June 2022

Azure DevOps: PowerPlatform: Export Solutions (and commit to source control)

In this blog post we will cover exporting the solutions so that we can commit them to source control and also ensure that we will have the right solution to deploy to our upstream environments later.  I always configure both the managed and unmanaged solution export (it takes a little longer up front) as it provides the cleanest way (in my experience) to deploy a valid managed solution to the upstream environments. 

Creating the pipeline

Again we're going to focus on the pipeline itself rather than installing the extension to manage this, so once you log in to Azure DevOps: 

  • In the left navigation of DevOps, click on Pipelines
  • Then click on the New pipeline button in the top right
  • Select Use the classic editor
  • Select the Repository
    • Select the Team Project (the current project)
    • Select the repository (PP_Solutions)
    • Select the main branch
    • click Continue
  •  Select a template
    • select the Empty job option link at the top of the list of types.

Configuring the pipeline

First, configure the properties for the pipeline itself, including its Name, Agent Pool and Agent Specification.  
  • Name: I usually name them in a manner that lets me follow the order easily such as: 02 - Export Solutions, or PP-02 - Export Solutions
  • Agent Pool can be left as default for now
  • Agent Specification: leave as default or select Windows-Latest so you don't have to keep updating it.
  • Next, click on the item called Agent job 1, change the name to Export Solutions (you can update the name if you want, I would recommend setting a name if you are going to have additional jobs in a single pipeline).
  • Then in the additional options, check the Allow scripts to access the OAuth Token checkbox.

Adding the build pipeline tasks

To the right of the agent job (named Set Solution Version) you will see a + (plus icon). Click the plus to add the pipeline steps:
  • Click the + icon
  • In the search box type Power Platform Tool Installer
  • Click Add next to the task that's displayed under the search box
  • again in the search box type Power Platform Export Solution
  • Click Add next to the task twice (once for the unmanaged and once for the managed solution) that's displayed under the search box.
  • Next in the search box type Power Platform Unpack Solution
  • Click Add next to the task
  • Next in the search box type Command Line Script
  • Click Add next to the task
  • Finally, in the search box type Publish Pipeline Artifact
  • Click Add next to the task
  • Your agent job should now look like this:


    Agent job after adding tasks


Configuring the pipeline tasks

 As usual, we can skip configuring the Power Platform Tool Installer task, it just needs to be present. 

  • Click on the first Power Platform Export Solution task and rename it to Power Platform Export Unmanaged Solution
    • On the details tab of the task set the following
      • Service Connection - use the service connection set up in the previous blog post
      • Solution Name - use the internal name of the solution
      • Solution Output File - $(Build.ArtifactStagingDirectory)\{SolutionName}_unmanaged.zip where {SolutionName} is the name from the previous step.
      • Leave all the other settings as default
  • Next, click on the first Power Platform Export Solution task and rename it to Power Platform Export Managed Solution
    • On the details tab of the task set the following
      • Service Connection - use the service connection set up in the previous blog post
      • Solution Name - use the internal name of the solution
      • Solution Output File - $(Build.ArtifactStagingDirectory)\{SolutionName}_managed.zip where {SolutionName} is the name from the previous step.
      • Check the Export as Managed Solution checkbox.
      • Leave all the other settings as default
  • Unpack the solution so that we can commit the source to the Git repository
    • Select the Power Platform Unpack Solution task
      • Set the Solution Input File value to the same as Solution Output File in the Power Platform Export Unmanaged Solution task
      • Set the target folder   $(Build.SourcesDirectory)\{SolutionName} where {SolutionName} is the name used in the previous steps
      • Set the Type of Solution to Unmanaged
  • Commit the extracted solution to Git
    • Select the Command Line Script task
    • In the Script text box enter the following script
echo commit all changes
git config user.email "your.email@domain.com"
git config user.name "Automatic Build"
git checkout main
git add --all 
git commit -m "solution init"
 
echo push code to new repo
git -c http.extraheader="AUTHORIZATION: bearer $(System.AccessToken)" push -f origin main
  • Publish the artifact.

Posted by Mauro Masucci at June 15, 2022 No comments:
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Labels: Azure DevOps, Power Platform Build Tools, PowerPlatform

Azure DevOps: PowerPlatform: Set solution version

In order to fully utilise managed solutions in your build and release pipelines you need to make sure the solutions are always incrementing their version (the platform will usually block you trying to install the same version of a solution.  This post will help guide you through the process in Azure DevOps using the Microsoft provided Power Platform Build Tools available from the MarketPlace. 

Prerequisites

You will need an Azure Git Repository set up in your Azure DevOps project. In this example we will call it PP_Solutions (short for PowerPlatform Solutions).  I would recommend you keep your PowerPlatform solutions in their own repository - it makes later steps much easier.  You can read more about how to create a new Git repo in your project.

Create connection to Power Platform

In your Azure DevOps projects:

  • Click the Project Settings link at the bottom of the left navigation
  • Select Service Connections
  • Click the New service connection button in the top right
  •  Select Generic, scroll to the bottom of the page, then click Next
  • Enter the following details for your Power Platform dev environment
    • The Url
    • The username (requires System Customizer privileges as a minimum)
    • The password/token for the above user account
    • The name for the connection - I usually use something like <Env>-Dev, where <env> is the name of the environment/project you are working with.
    • Check the Grant access permission to all pipelines checkbox
    • click Save

Creating the pipeline

This blog post won't take you through installing the extension set itself (that may come in the future if needed) but will focus on setting up the pipeline itself.

  • In the left navigation of DevOps, click on Pipelines
  • Then click on the New pipeline button in the top right
  • Select Use the classic editor
  • Select the Repository
    • Select the Team Project (the current project)
    • Select the repository (PP_Solutions)
    • Select the main branch
    • click Continue
  •  Select a template
    • select the Empty job option link at the top of the list of types.

Configuring the pipeline

First, configure the properties for the pipeline itself, including its Name, Agent Pool and Agent Specification.  
  • Name: I usually name them in a manner that lets me follow the order easily such as: 01 - Set Solution Version, or PP-01 - Set Solution Version
  • Agent Pool can be left as default for now
  • Agent Specification: leave as default or select Windows-Latest so you don't have to keep updating it.
  • Next, click on the item called Agent job 1, change the name to Set Solution version (you can update the name if you want, I would recommend setting a name if you are going to have additional jobs in a single pipeline).
  • Then in the additional options, check the Allow scripts to access the OAuth Token checkbox.

Adding the build pipeline tasks

To the right of the agent job (named Set Solution Version) you will see a + (plus icon). Click the plus to add the pipeline steps:
  • Click the + icon
  • In the search box type Power Platform Tool Installer
  • Click Add next to the task that's displayed under the search box
  • Again, in the search box type Power Platform Set Solution Version
  • Click Add next to the task that is now displayed under the search box.

Configuring the pipeline tasks

In this case, you only need to worry about configuring the Power Platform Set Solution Version task

  • Select the task from the list of tasks under the Agent Job Set Solution Version
  • Select the connection you created to your dev environment in the prerequisites step
  • Enter the solution name (in this case its SS2022)
  • For the Solution Version Number I like to add the build ID to get an automatically incrementing number, in this case enter 1.0.0.$(Build.BuildId).  
You should be ready to run the pipeline now, so click Save & queue at the top of the pipeline screen.  Your pipeline will be queued and should run successfully.


 


Posted by Mauro Masucci at June 15, 2022 No comments:
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Labels: Azure DevOps, Power Platform Build Tools, PowerPlatform

Tuesday, 7 June 2022

Automated PowerPlatform deployments using Azure DevOps Series

 A series of blog posts on using classic build and release pipelines in Azure DevOps to (as covered at ScottishSummit2022):

  1. Set the solution version
  2. Export solutions
  3. Export reference data
  4. Build the solution to a clean environment (optional)
  5. Release the packages
Additionally, I'll cover the use of 
  1. Task groups
  2. Libraries
  3. Setting environment variables

Posted by Mauro Masucci at June 07, 2022 No comments:
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Labels: Azure DevOps, Power Platform Build Tools, PowerPlatform
Newer Posts Older Posts Home
Subscribe to: Posts (Atom)

Metio

Powered by Blogger.

Report Abuse

Popular Posts

  • Azure DevOps: PowerPlatform: Export Solutions (and commit to source control)
    In this blog post we will cover exporting the solutions so that we can commit them to source control and also ensure that we will have the r...
  • Automated PowerPlatform deployments using Azure DevOps Series
     A series of blog posts on using classic build and release pipelines in Azure DevOps to (as covered at ScottishSummit2022): Set the solution...
  • Testing the template
    this is testing the new template...
  • Home

About Me

Mauro Masucci
View my complete profile

Search

Labels

Azure DevOps Power Platform Build Tools PowerPlatform

Blog Archive

  • ▼  2022 (3)
    • ▼  June (3)
      • Azure DevOps: PowerPlatform: Export Solutions (and...
      • Azure DevOps: PowerPlatform: Set solution version
      • Automated PowerPlatform deployments using Azure De...
  • ►  2019 (1)
    • ►  April (1)

Get In Touch

  • +44 (0) 7855 278958
  • hello@metio.co.uk
  • Motherwell, ML1 2PT
© Untitled. Design TEMPLATED. Images Unsplash. Background vector created by starline - www.freepik.com