Why would you use “Stage for Upgrade” with managed solutions?

By | May 29, 2019

 

In case you were wondering what that “stage for upgrade” option means and why is it there in the first place:

image

It’s all about deleting components from the managed solutions. The ALM whitepaper actually does a good job describing this feature, though there is a lot of other content in that document, so “stage for upgrade” may seem less important at the first glance:

https://www.microsoft.com/en-us/download/details.aspx?id=57777

Anyway, here is an example of the managed solution I have installed in the production instance:

image

What if I did not need that workflow anymore, and, also, what if I did not need the Test Field:

image

I could go to the development environment, delete the workflow and the field, update the version number, and import new version of the same managed solution. While importing that updated solution, I’d have to choose whether I wanted to “Stage for Upgrade”. What if I did not?

image

The solution would be imported, but the workflow would still be there:

image

How come?

Problem is, solution components can’t be deleted just like that. It all comes down to the reference count – the solution that’s there in the instance is still referencing the component, so the system can’t remove that component while there is a reference. And it can’t remove the reference without removing the component first.

Historically, this is where we’d be using holding solutions, and this is what we are actually doing when choosing “stage for upgrade” option.

Let’s make a note of the solution ID. When not using stage for upgrade, it stays the same:

image

Now let’s export another version of the same solution (it’ll be 1.2.0.0) and try importing it with the “stage for upgrade” option. This time, there will be two solutions in the target instance:

image

That “_Upgrade” solution is, actually, what used to be called a “holding” solution – there is no workflow in that solution, but the entity is still there:

image

If I now applied solution upgrade to the original solution:

image

The workflow would be removed since the system would do three things:

  • It would remove my original solution
  • It would remove any components that have no references anymore (the workflow)
  • It would rename that “_upgrade” solution so the name matches original solution name

As a side-effect, solution ID would, actually, change (since it would be the ID of the former “_upgrade” solution):

image

PS. Through this same process, my Test Field finally got deleted as well:

image

Leave a Reply

Your email address will not be published. Required fields are marked *