Understanding D365 CE solution Deployment – Packaging – Part 1

In previous post we have seen manual import and export method for the solution deployment. In this post let us see the deployment using package deployer.  Now we know manually export and import of the solutions is quite simple and easy to do, then why do we need a package  deployer for solution deployment?

  • In Manual export and import, only one solution can be deployed  at a time , and only solution can be deployed, however the package deployer would enable us to deploy the data in terms of flat files, xml files , multiple solution files
  • Even we can write some code which can be executed while we do the deployment.

To deploy the solution using package deployer, we have to create a package consisting of all our files such as solution files, data files etc and then we can deploy that package.  While we deploy the package using package deployer, it gives us a feel of set up file being deployed with customized welcome page to start with and an customized ending page, once the installation/ deployment is over.

Let us divide this deployment in two steps:

  1. Create a solution package
  2. Using Package deployer to deploy the solution

To create the solution package, we need below :

  • we should have our solution(s) and the data files ( how to create the data files will see in later posts) ready
  • Visual Studio 2015
  • CRM SDK package installed on VS 2015

To install the package template, go to the site install template and download.

Download Package template

It will download the CRMSDKTempaltes.vsix file as shown in below snippet, just double click on the vsix file and installation would start.

We need to check which version of visual studio and click on install as shown in below snippet.

Install Template1

It would complete the installation and show below message.

Install Template2

Once the installation is completed, open the visual studio and go to File menuNew project

Click on New and then Project

New project2

As we have installed the CRM SDK package, we can see  CRM  SDK Template under installed. In case we won’t see this option under Installed, understand that the CRM SDK package is not installed or visual studio is not restarted post installation.

Select the CRM package.

New project3

Enter name of the project and select the location for the new project and click on OK.

The project will be created and if we see in the solution explorer,  there will different type of files and folders by default created as shown in below snippet.

Project Files

I have given project name as PackageDeployerpost, hence the solution and project are created with the same name. This template consists of default folders such as GettingStarted and PkgFolder and files packages.config and PackageTemplate.cs

Project Files1

Gettingstarted folder is just for reference , it is not required in the project. However PkgFolder is most important folder in the package. It consists of Content Folder and ImportConfig file. Let us discuss the details about all these files in my next post.

Project Files2

One important thing we need to remember that for any file which is added in the pkgfolder, we need to check the property CopyToOutputDirectory set to Copyalways as we want these files to copied to the final package.

The steps to do the same are as shown in below snippets.

Select the file, right click and click on Properties.


Select the Copy to Out Directory Property and set as Copy Always. For default files, it will be always set , however need to set for any new file which will be added later. Continue reading “Understanding D365 CE solution Deployment – Packaging – Part 1”

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"
    <configsolutionfile solutionpackagefilename="MyappSolution_1_0_managed.zip"
    <cmtdatafile filename="Myappcongigdata.zip"
                 usermapfilename="" />


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
// 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 "; }


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.

Continue reading “Understanding D365 CE solution Deployment – Packaging – Part 2”