Javascript required
Skip to content Skip to sidebar Skip to footer

Dynamics 365 9.0 Remove Managed Solution Components

Using managed solutions to deploy customizations from a source environment (usually Development) to other environments (Test, Production, etc.) is a best practice that has been pushed by Microsoft for a very long time now.

Matt Barbour, Principal PM on the Dynamics 365 Customer Engagement Platform, did an excellent job last year at Microsoft Ignite to explain why, and how Microsoft has improved solution management in the Common Data Service for Apps: Microsoft Dynamics 365 CE Platform Update for Developers (watch after 3m39 for the bit on solutions).

Jonas Rapp, Microsoft Business Applications MVP, also recently blogged about it: Case closed: Managed or Unmanaged solutions in Microsoft Dynamics 365 / CRM.

Solution management has indeed been improved, mainly since v8, in order to better manage common ALM requirements, such as the ability to only deploy a small subset of changes (for examples only
specific fields for an entity), or the ability to delete components (such as entities, views, fields, etc.) from environments where the solution had already been previously deployed with those customization. Of course it has always been possible to delete components from a target managed environment, but by playing around with the solution XML and by using the concept of "holding" solutions.

I will focus in this article on how to delete components from target environments with the use of the "Clone Solution" option.

Note: cloning the solution this is not a mandatory step, but this will result in all existing patches being merged into the main unmanaged solution, and this will also guide the user in incrementing the solution's major version numbers.

The scenario

Imagine you have deployed customizations from development to production in the version 1.0.0.0 of a managed solution. Later in the project, due to new or changing requirements, you need to delete some of these components (in my example an entity, a field, a security role and a workflow) from development and production environments.

This is how the solution looks in my target environment, with the components that I want to remove highlighted in yellow:

If you try to delete one the components manually in production, you will get this kind of error, because the components are in a managed state.

The solution

1. In your unmanaged source environment, clone your solution (optional)

Select your unmanaged solution from the list, and click "Clone Solution"

This will prompt you to increment the version number of your solution:

This will not create a new solution, but you will just notice that the version number has been incremented and that the description has been updated to "Upgrade of [name of your solution]":

2. Delete the components from your source environment

Start by deleting the unwanted components from your unmanaged source solution, in your development environment. In my case, I have deleted "Workflow C", "Security Role D", "Entity A", and the field "Value E" from "Entity B".

Now export your customizations in a new managed solution.

3. Deploy the clone managed solution to your target managed environment

Import the solution file in your target managed environment. During the process, you will be prompted with additional options if you want to stage the upgrade and if you want to overwrite customizations:

Staging the upgrade enables to choose when to apply changes that come with the upgrade (for example the actual deletion of components).

You will notice that a second solution is installed (with the incremented number and with "_Upgrade" in the solution name).

4. Apply the Solution Upgrade in your target managed environment

To apply the upgrade, select the original solution and click on "Apply Solution Upgrade":

Once it is done, the "_Upgrade" solution disappears and only the latest version of the original solution remains. If you open it, you will notice that all removed components are now deleted from your solution and environment:

Et voilĂ  !

What it doesn't do

Deploying an upgrade of a managed solution will not allow you to replace existing components that have identical system names. So for example if you want to switch the type of a field that has a system name "new_value" from decimal to currency, you will get an error when deploying the solution, as the attribute will still exist at the time you try to deploy the solution.

To achieve that, you first need to delete the component in the target environment before recreating it with the desired system name / type.

Dynamics 365 9.0 Remove Managed Solution Components

Source: https://www.henryjammes.com/2018/09/how-to-delete-components-from-managed-solution.html