“How can we automate merging our CRM Solutions?” is one of the most asked questions whenever we talk about CRM solutions and DevOps Implementations. Merging and Automation are critical concepts of DevOps culture, but there is not a single utility that we can use directly to merge MS Dynamics Solutions. This 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.Â
The other 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 command to extract the solution is the following:
C:ToolsCoreToolsSolutionPackager.exe  / action:Extract  /zipfile:Solution1.zip  /folder:”C: SolutionsExtract”.Â
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 will be merged. If Solution.xml is not in the root directory, then it can be found in the /Other folder.Â
4. Pack all these solutions back to zip files using the Microsoft Solution Packager tool with the following command:
C:ToolsCoreToolsSolutionPackager.exe  / action:Pack  /zipfile:Solution1.zip  /folder:”C: SolutionsExtract”.Â
5. Now import all these solutions to an organization. All these solutions should 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:
Build Pipeline:Â
- Power DevOps Tool Installer: This will install the tools required.Â
- Export Solution: Solution1: Through this, you can export the solution and 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 our exported Microsoft Dynamics CRM solution to a folder. Provide it with the solution path in the Unpacked Files Folder tab that would be like $(Build.Repository.LocalPath)Solution1 and the folder where to extract.
4. PowerShell Script For Editing Solution.xml: The 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)SolutionOtherSolution.xml -Raw) -Replace ‘Solution1’, ‘NewSolutionName’ | Set-Content -Path $(Build.Repository.LocalPath)SolutionOtherSolution.xml Â
It would edit the Solution.xml file from our extracted solution and will update the UniqueName from Solution1 to NewSolutionName.Â
5. Pack Solution: This task would pack the solution back to a zip file. Provide it the path to the extracted folder where we have changed the Unique Name in Solution.xml file that would be 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 had 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. So, we must rename the solution as all the solutions would have the same name at the end. There is a PowerShell script that 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 would be
$(build.binariesdirectory)Solution1.zip as this the path where we have saved our solution after editing the Solution.xml file and renaming. Â
All these tasks would 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.Â
- 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 to use for importing Solutions to CRM organizations. You can use any of your choice. Here is CRM 2016 Solution task that will 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 would be merged as a single solution named as mentioned in the UniqueName tab. Â
Conclusion:Â
Till now, you must merge 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 do not want to use the Azure DevOps pipelines, you can manually perform all the steps mentioned above. But from onwards, merging CRM Solutions would be a lot easy for you. Â