简体   繁体   中英

Package Deployer to sequence Solutions and Data File

Working on Package Deployer Project to deploy Managed Solutions and Data Files in Sequence.

I have added 3 solutions and 1 Data file(Data file created using the Configuration Migration tool which comes with CRM SDK) in PkgFolder. I have added 3 solutions and a Data file in ImportConfig.xml

My Challenge is I want to import the solutions and Data files in sequence like:

  1. Import Solution 1, Solution 2
  2. Import Data File
  3. Import Solution 3

How to configure such a sequence?

Due to a lack of Documentation and resources could not proceed with achieving this challenge.

Please help!

Below is my ImportConfig.xml

<?xml version="1.0" encoding="utf-16"?>

<!--
  More information about ImportConfig.xml file
  https://docs.microsoft.com/en-us/power-platform/alm/package-deployer-tool
-->
<configdatastorage xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                   installsampledata="false"
                   waitforsampledatatoinstall="true"
                   agentdesktopzipfile=""
                   agentdesktopexename=""
                   crmmigdataimportfile="BookingStatusData.zip">
    <!-- solutions to import -->
    <solutions>
        <configsolutionfile solutionpackagefilename="Solution1.zip" />
        <configsolutionfile solutionpackagefilename="Solution2.zip" />
        <configsolutionfile solutionpackagefilename="Solution3.zip" />
    </solutions>
    <filesmapstoimport>
        <configimportmapfile filename="BookingStatusSchema.xml" />
    </filesmapstoimport>
    <filestoimport>
        <configimportfile filename="BookingStatusData.zip"
        filetype="ZIP"
        associatedmap="BookingStatusSchema"
        importtoentity="bookingstatus"
        datadelimiter=""
        fielddelimiter="comma"
        enableduplicatedetection="true"
        isfirstrowheader="true"
        isrecordownerateam="false"
        owneruser=""
        waitforimporttocomplete="false" />
    </filestoimport>
</configdatastorage>

The standard package deployment is designed as a somewhat straightforward process and unfortunately data import can only occur after all solutions have been processed.

However, when you need extra flexibility you could consider adding a custom ImportExtension class to your project. In this class you can skip the import of Solution3.zip as part of the regular process and import it separately after the primary import has been completed.

[Export(typeof(IImportExtensions))]
public sealed class DeploymentExtension : ImportExtension
{
    /// <summary>
    /// Called when a single solution is queued for import. Implementation can decide what is to be done.
    /// </summary>
    public override UserRequestedImportAction OverrideSolutionImportDecision(string solutionUniqueName, Version organizationVersion, Version packageSolutionVersion, Version inboundSolutionVersion, Version deployedSolutionVersion, ImportAction systemSelectedImportAction)
    {
        return solutionUniqueName == "<Solution3UniqueName>"
            ? UserRequestedImportAction.Skip
            : UserRequestedImportAction.Default;
    }

    /// <summary>
    /// Called after all solution and data imports have been completed. 
    /// </summary>
    /// <returns></returns>
    public override bool AfterPrimaryImport()
    {
        string solutionFilePath = Path.Combine(CurrentPackageLocation, "PkgFolder", "Solution3.zip");
        CrmSvc.ImportSolutionToCrm(solutionFilePath, out Guid _);
        return true;
    }
}

Alternatively you could just import Solution3.zip entirely separated from the other components using Azure DevOps task microsoft-IsvExpTools.PowerPlatform-BuildTools.import-solution.PowerPlatformImportSolution@2 .

Is there a reason its important to import data between solutions? the process that PD uses is as follows:

  1. Validate Depoloyment based on configuration
  2. Run package Init code
  3. Run solutions in deployment order (as specified in the ImportConfig.Xml file)
  4. Run Pre/Post/Upgrade code around each solution
  5. Run Post Solutions code
  6. Check to see if Data import is allowed
  7. Run flat file imports (xml / csv's / maps / etc..)
  8. Run CMT import data (which has its own schema / config checks and so on)
  9. Run Post Deployment Code

The reason Data is after solutions is data is always dependent on schema, which is deployed by solutions.

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