WaelHamze / xrm-ci-framework

xRM CI Framework provides you with the tools automate the build and deployment of your CRM Solution. Using the framework to implement a fully automated DevOps pipeline will allow you to deploy more frequently with added consistency and quality.
MIT License
186 stars 117 forks source link

How to disable Solution Holding - Stage for Upgrade using CRM Package Deployer #224

Closed missdynamicscrm closed 5 years ago

missdynamicscrm commented 5 years ago

When importing Solution using Package Deployer (non-GUI), by default it seems always applying “Apply Solution Upgrade” and Importing as Holding Solution. Do you have any idea how to disable this feature by default when deploying CRM Package using Package Deployer? So, the "Stage for Upgrade" will not be checked by default .

I have used this config:

  <solutions>    
    <configsolutionfile solutionpackagefilename="TestCore_managed.zip"
                        overwriteunmanagedcustomizations="true"
                        publishworkflowsandactivateplugins="true"
                        holdingsolution="false" />    
  </solutions>

But it does not work. What is the correct parameter or setting, I have put the holdingsolution in the first config by sequence, but I don't think it has effect too.

I mean in the Import Solution Task, your task has option to enable/disable "Holding Solution", any idea for CRM Package Deployer? Or the correct way is always Import solution first with all the setting then run the Package Deployer task after that?

Thank you!

WaelHamze commented 5 years ago

@missdynamicscrm I normally import solutions before running package deployer, you will still need a dummy solution in the package deployer if you do this.

@mgcrmltd managed to do this using package deployer, I believe you have to override some of the methods in the c# code

mgcrmltd commented 5 years ago

This should enforce it for every import. You can add more logic to make exceptions.

public override UserRequestedImportAction OverrideSolutionImportDecision(string solutionUniqueName, Version organizationVersion, Version packageSolutionVersion, Version inboundSolutionVersion, Version deployedSolutionVersion, ImportAction systemSelectedImportAction)
{
    return systemSelectedImportAction == ImportAction.Import
        ? UserRequestedImportAction.ForceUpdate
        : base.OverrideSolutionImportDecision(solutionUniqueName, organizationVersion, packageSolutionVersion,
            inboundSolutionVersion, deployedSolutionVersion, systemSelectedImportAction);

}