简体   繁体   中英

Dynamics CRM/Dynamics 365 Apply solution upgrade programmatically

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM