Understanding D365 CE solution Deployment – Packaging – Part 2

In the previous post we created the new package template project and checked the default files which  are created in the solution.

In this solution, we need to add the exported solution(s) under package folder and if we have any configuration data files, that can also be added to this folder. Once we add these files, we have to set up the configuration file which guides the package deploy what is to be imported and how.

Setting up this file is one of the important task in creating the package. Let us  see in details

Refer to the below file which is modified by for this post.  This is an xml file and we have to mention the names of the added exported solution files and the data files etc here.

Myappconfigdata.zip is the data file and MyappSolution_1_0_managed.zip is the solution which is to be deployed .

<?xml version="1.0" encoding="utf-16"?>
<configdatastorage xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                   xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                   installsampledata="true"
                   waitforsampledatatoinstall="true"
                   agentdesktopzipfile=""
                   agentdesktopexename=""
                   crmmigdataimportfile="Myappconfigdata.zip">
  <solutions>
    <configsolutionfile solutionpackagefilename="MyappSolution_1_0_managed.zip"
                        overwriteunmanagedcustomizations="false"
                        publishworkflowsandactivateplugins="true"/>
  </solutions>
 
  <cmtdatafiles>
    <cmtdatafile filename="Myappcongigdata.zip"
                 lcid="1033"
                 usermapfilename="" />

  </cmtdatafiles>
</configdatastorage>

Microsoft docs has very detailed explanation about this config files and there is explanation about all the tags and its importance . Hence I am not going in those details again in this  post. Kindly refer to below link for more details.

Specify the configuration values for the package

We have to mention all the solutions under <solutions>  tag . Here for example I have added only single solutions, but we can add multiple solutions. The order we mention the solutions in this, solutions will be imported in the same order. We can specify whether we want to overwrite the existing customization while importing and also whether we want to publish the workflows and activate plugins post import using the attributes\

  • overwriteunmanagedcustomizations
  • publishworkflowsandactivateplugins

If we have the data file, that also can be mentioned here. This data file can be created with the  help of configuration migration tool provided by Microsoft. We will discuss this in detailed  this in later posts. Kindly refer the Microsoft Docs link for more details on this

Using Configuration Migration tool 

Now we let see thMyappSolutione use of PackageTemplate.cs which helps us to write the custom code for our deployment. To make it simple, let us keep the default code in this file except the properties . We have to set the properties as per the names we have given to our files and folders. It helps the deployer to identify the solution(s) to be imported and data to to migrated.

#region Properties

/// <summary>
/// Name of the Import Package to Use
/// </summary>
/// <param name="plural">if true, return plural version</param>
/// <returns></returns>
public override string GetNameOfImport(bool plural)
{
return "MyappSolution";
}

/// <summary>
/// Folder Name for the Package data. 
/// </summary>
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 "PkgFolder";
}
}

/// <summary>
/// Description of the package, used in the package selection UI
/// </summary>
public override string GetImportPackageDescriptionText
{
get { return "My App created for learning solution deployment "; }
}

/// <summary>
/// Long name of the Import Package. 
/// </summary>
public override string GetLongNameOfImport
{
get { return "MyApp Solution Package created for learning the solution deployment using package deployer "; }
}


#endregion

Microsoft Docs has very intuitive explanation about this file’s usage and what to change. Kindly refer below link to go the more details

Define custom code for your package

Now its the last step. If you observe carefully, any installation starts with some welcome page with few information/ instructions and after the installation is complete, it gives some information/Thank you message etc. Same process applies here during package deployment as well and we can add such pages in html format and different languages. Inside the pkgfolder, we see a content folder and which has default html files for English language. we can customize those as per our requirement and required language

Kindly refer to Microsoft Docs site below about more details

Update the html files

Now our package is ready for build. Let us build the package and see in bin folder, we will see the one dll along with pkgfolder. As we have set the copy always for all the files in folder, it is copied in the bin folder.

We have come to the final step of deploying the package. Let us see the same in next post.

Microsoft Docs- Create Package

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.