I have a D365 App that I need to deploy via AppSource.
I have an AppSource Visual Studio Project.
I am currently at the step “Create an App Source Package for your software” as detailed here: https://docs.microsoft.com/en-us/powerapps/developer/data-platform/create-package-app-appsource
I have the package and it deploys without error using the Package Deployment Tool.
My issue is that I need a little help changing how it deploys to make it more intelligent.
Specifically, the first 12 solutions listed in the ImportConfig.xml file are 3rd party pre-requisite components that I need to make sure are installed if they are not.
However, if the current or a newer version of each one is installed in the destination system, I need to make sure I don’t overwrite them or attempt to install them.
Therefore, I need a way to check the destination D365 instance to see if each component is installed and obtain the current version number if it is.
Then, if the solution does not exist in the destination system or if it does and version number is older than what I am providing, I need to have the deployer install or update the solution in the destination system.
Otherwise, if the version is the same or newer, I need to ensure the deployer simply moves on and checks the destination system for existence of the next pre-requisite solution, repeating the process above but with different version numbers.
A copy of my ImportConfig.xml file is provided in Exhibit 1A below.
My question is what exactly must I do, and where do I need to do it to perform this check and intelligent install process?
- Can this all be done in the ImportConfig.xml file?
- If yes, what specifically must I change in the ImportConfig.xml file in Exhibit 1A below to make it check and install as described above?
- If I need to do something in the PackageTemplate.cs file, what exactly must I do and where must I do it?
It would be great if someone could provide some code to help get me started.
I have provided a copy of my PackageTemplate.cs file in Exhibit 2A below.
EXHIBIT 1A
EXHIBIT 2A
using Microsoft.Uii.Common.Entities;
using Microsoft.Xrm.Tooling.PackageDeployment;
using Microsoft.Xrm.Tooling.PackageDeployment.CrmPackageExtentionBase;
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ACEServiceTechAppSource
{
///
/// Import package starter frame.
///
[Export(typeof(IImportExtensions))]
public class PackageTemplate : ImportExtension
{
///
/// Called When the package is initialized.
///
public override void InitializeCustomExtension()
{
// Do nothing.
// Validate the state of the runtime settings object.
if (RuntimeSettings != null)
{
PackageLog.Log(string.Format("Runtime Settings populated. Count = {0}", RuntimeSettings.Count));
foreach (var setting in RuntimeSettings)
{
PackageLog.Log(string.Format("Key={0} | Value={1}", setting.Key, setting.Value.ToString()));
}
// Check to see if skip checks is present.
if (RuntimeSettings.ContainsKey("SkipChecks"))
{
bool bSkipChecks = false;
if (bool.TryParse((string)RuntimeSettings["SkipChecks"], out bSkipChecks))
OverrideDataImportSafetyChecks = bSkipChecks;
}
}
else
PackageLog.Log("Runtime Settings not populated");
}
///
/// Called Before Import Completes.
///
///
public override bool BeforeImportStage()
{
return true; // do nothing here.
}
///
/// Called for each UII record imported into the system
/// This is UII Specific and is not generally used by Package Developers
///
/// App Record
///
public override ApplicationRecord BeforeApplicationRecordImport(ApplicationRecord app)
{
return app; // do nothing here.
}
///
/// Called during a solution upgrade while both solutions are present in the target CRM instance.
/// This function can be used to provide a means to do data transformation or upgrade while a solution update is occurring.
///
/// Name of the solution
/// version number of the old solution
/// Version number of the new solution
/// Solution ID of the old solution
/// Solution ID of the new solution
public override void RunSolutionUpgradeMigrationStep(string solutionName, string oldVersion, string newVersion, Guid oldSolutionId, Guid newSolutionId)
{
base.RunSolutionUpgradeMigrationStep(solutionName, oldVersion, newVersion, oldSolutionId, newSolutionId);
}
///
/// Called after Import completes.
///
///
public override bool AfterPrimaryImport()
{
return true; // Do nothing here/
}
#region Properties
///
/// Name of the Import Package to Use
///
/// if true, return plural version
///
public override string GetNameOfImport(bool plural)
{
return "ACE Service Tech App";
}
///
/// Folder Name for the Package data.
///
public override string GetImportPackageDataFolderName
{
get
{
// WARNING this value directly correlates to the folder name in the Solution Explorer where the ImportConfig.xml and sub content is located.
// Changing this name requires that you also change the correlating name in the Solution Explorer
return "ACEServiceTechApp";
}
}
///
/// Description of the package, used in the package selection UI
///
public override string GetImportPackageDescriptionText
{
get { return "Aloye Computer Enterprises - ACE Service Tech App for D365"; }
}
///
/// Long name of the Import Package.
///
public override string GetLongNameOfImport
{
get { return "Aloye Computer Enterprises - ACE Service Tech App for D365"; }
}
#endregion
}
}
Any help, including some code to get me started would be greatly appreciated as I am diving into brand new territory here.