Dynamics CRM/Dynamics 365 Apply solution upgrade programmatically

1.6k views Asked by At

There is a set of rules that should be applied while moving solutions from one instance to another, so there is an idea to use a custom tool that will make all changes, export and import solutions to another instance. The question is next:

How could "solution upgrade applying" be implemented with C#?

Importing "as holding" easily could be done by setting (CRM 2016 SDK)

 var import = new ImportSolutionRequest();
 import.HoldingSolution = true;

this allows to have a holding solution in a target environment, but after some tests we still can't "Apply" this upgrade for the previously installed solution.

Thank you in advance.

1

There are 1 answers

0
Henk van Boeijen On BEST ANSWER

After you have imported the holding solution you can upgrade it using a DeleteAndPromoteRequest.

A basic example:

public Guid UpgradeSolution(string solutionUniqueName, IOrganizationService service)
{
    var request = new DeleteAndPromoteRequest
    {
        UniqueName = solutionUniqueName
    };

    var response = (DeleteAndPromoteResponse)service.Execute(request);
    return response.SolutionId;
}

In the DeleteAndPromoteResponse the SolutionId property holds the Guid of the promoted solution.