Automate Microsoft CRM Solutions Merge Using Azure CI/CD Pipelines

“How can we automate merging our CRM Solutions?” is one of the most asked questions we get whenever we talk about CRM solutions and DevOps implementations. Merging and Automation are both key concepts of DevOps culture, but there is not a single utility that we can use directly for merging MS Dynamics solutionsThis blog post will discuss methods to merge CRM solutions manually and automatically using Microsoft Azure Build and Release Pipelines. 

Merging Manually: 

A solution may consist of many components like Entities, Web Resources, Assemblies etc. The traditional way of merging is to manually import all the solutions on a single environment and then add all the components from each solution to a master one.  

Another way is quite simple and less time-consuming. You can merge these solutions by editing their unique names in the Solution.xml file to a master name, as shown in the steps below: 

  1. Export the MS Dynamics CRM solutions locally.  
  2. Extract these by using the Microsoft Solution Packager tool. The Packager tool can be downloaded from:  https://xrm.tools/SDK. The directory of the downloaded tool will look like this: 

image001

The following is the command to extract the solution:

C:\Tools\CoreTools\SolutionPackager.exe  / action:Extract  /zipfile:Solution1.zip  /folder:”C:\ Solutions\Extract”. 

You can now see all the components of the extracted CRM Solutions.

image002

3. Open the Solution.xml file with a text editor and edit the UniqueName with the same name across all the CRM solutions that you want to mergedIf the Solution.xml is not in the root directory, then it will be in the /the /Another folder. 

image003

4. Pack  all these solutions back to zip files using the Microsoft Solution Packager tool with the following command:
C:\Tools\CoreTools\SolutionPackager.exe  / action:Pack  /zipfile:Solution1.zip  /folder:”C:\ Solutions\Extract”. 

5. Now import all these solutions to an organizationAll these solutions will be merged in a single solution with the name you specified in the UniqueName tab.    

Automate CRM Solutions Merge Using Azure DevOps Pipelines: 

All the steps that we have mentioned above can be automated using Azure DevOps Continuous Integration and Continuous Deployment pipelinesFirst, let us have a look at the steps to add to the build pipeline. 

Build Pipeline: 

A build pipeline is created of tasksA task is the building block for defining automation in a pipeline. It is a packages script/procedure that is abstracted with input sets. 

image004

  1. Power DevOps Tool Installer Task that will install the tools required.
  2. Export Solution: Solution1:  Task to export the solution. You will need to provide the connection string to the source org and the name. The connection string will look like this:

AuthType=Office365;[email protected]; Password=Password123!;Url=https://dev.alphabold.com/dev/ 

image005

3. Extract Solution: The task will extract your exported Microsoft Dynamics CRM solution to a folder. You will need to provide it with the path of the solution in theUnpacked Files Foldertabwill be the following: $(Build.Repository.LocalPath)\Solution1. You will also need to provide it with thefolder where to extract. 

image006

4. PowerShell Script For Editing Solution.xml: This task will be used to edit the UniqueName tab in the Solution.xml file. The PowerShell will look like this: 

(Get-Content $(Build.Repository.LocalPath)\Solution\Other\Solution.xml -Raw) -Replace ‘Solution1’, ‘NewSolutionName’ | Set-Content -Path $(Build.Repository.LocalPath)\Solution\Other\Solution.xml  

It will edit the Solution.xml file from our extracted solution and will update the UniqueName from Solution1 to NewSolutionName. 

5. Pack Solution: This task will pack the solution back to a zip file. Next, you will need to provide it with the path to the extracted folder where we have changed the Unique Name in Solution.xml file that will look like $(Build.Repository.LocalPath)\Solution1 and the path where the .zip file should be stored.  

image 07

6. PowerShell Script For Renaming solution1: In the previous steps, we changed the UniqueName in the CRM solution and packed the solution. So, when a CRM solution is packed, it gets its name from the UniqueName tab. For that reason, we must rename the solution as all the solutions will have the same name at the end. The following PowerShell script can be used for this: 

Rename-Item -Path “$(build.binariesdirectory)\NewSolutionName.zip” -NewName “Solution1.zip” -Force -PassThru 

7. Publish Artifact: Now publish the MS Dynamics CRM solution as an artifact to use that in our release pipelines to import to any organization. The path to publish will be $(build.binariesdirectory)\Solution1.zip as this is the path where we have saved our solution after editing the Solution.xml file and renaming.  

image008

 

All these tasks will be cloned for every CRM solution. The main thing to remember is that we need to provide the same name in the UniqueName tab for all the solutions.  

Release Pipeline: 

The Release Pipeline is quite simple. You only need to add tasks to import CRM solutions to an organization where the CRM Solutions Merge should be done. 

  1. Link the release pipeline to the build pipeline that we have used to publish our solution as an artifact. 

image009

2.  CRM Solution Import: There are many tasks available on the Azure DevOps Marketplace that can be used for importing solutions to CRM organizations. In our example, we have used the CRM 2016 solution task to get the CRM solutions from the linked pipeline and import them to the configured organization.  

Import all the CRM solutions to the same organization, and all the solutions will be merged as a single solution named as mentioned in the UniqueName tab.  

image010

Conclusion: 

Up until now, you must have merged the MS CRM Dynamics solutions manually by adding all the components of all the solutions to a master solution. After reading this blog, you can Automate Your Microsoft CRM Solutions Merge Using Azure CI/CD Pipelines. If you prefer not to use the Azure DevOps pipelines, you can manually perform all the steps mentioned above. After reading this blog, merging CRM Solutions will be a lot easier for you! 

PS:  Stay tuned for the next blog in this series to learn more about Azure CI! 

 

Posted in: CRM

Leave a Reply

Your email address will not be published.