“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 solutions. This blog post will discuss methods to merge CRM solutions manually and automatically using Microsoft Azure Build and Release Pipelines.
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:
- Export the MS Dynamics CRM solutions locally.
- 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:
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.
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 merged. If the Solution.xml is not in the root directory, then it will be in the /the /Another folder.
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 organization. All 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 pipelines. First, let us have a look at the steps to add to the build pipeline.
A build pipeline is created of tasks. A task is the building block for defining automation in a pipeline. It is a packages script/procedure that is abstracted with input sets.
- Power DevOps Tool Installer: Task that will install the tools required.
- 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/
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.
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.
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.
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.
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.
- Link the release pipeline to the build pipeline that we have used to publish our solution as an artifact.
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.
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!