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
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Labels: Azure DevOps, Power Platform Build Tools, PowerPlatform

No comments:

Post a Comment

Older Post Home
Subscribe to: Post Comments (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