knowledgecenter-breadcrum

Knowledge Center

02 Aug, 2023

Streamlining solution deployment in Power Platform/Dynamics 365 CRM using Package Deployer Tool

Posted on 02 Aug, 2023 by Fahar Ansari, Posted in C# Dynamics 365 Power Platform Blog

Package Deployer Blogs

Gone are the days of manually importing solutions one by one into the Dataverse environment. Package Deployer lets administrators deploy packages on Microsoft Dataverse instances. A Package Deployer package can consist of any or all of the following:

  • One or more Dataverse solution files.
  • Flat files or exported configuration data file from the Configuration Migration tool.
  • Custom code that can run before, while, or after the package is deployed to the Dataverse instance.
  • HTML content specific to the package that can display at the beginning and end of the deployment process.

In this blog we will setup package deployer tool to import multiple solutions into our Power Platform Environment.

Firstly, we will download and install the Package Deployer using PowerShell.

  1. Create a folder named CRM Tools in C: drive.
    CRM Tools in C drive
  2. Open Windows PowerShell using Run as Administrator
  3. Change directory (cd) to the CRM Tools folder we created in above step.
  4. Run the following block of commands one by one in PowerShell.
    Block1:
    [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
    
    $sourceNugetExe = "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe"
    
    $targetNugetExe = ".\nuget.exe"
    
    Remove-Item .\Tools -Force -Recurse -ErrorAction Ignore
    
    Invoke-WebRequest $sourceNugetExe -OutFile $targetNugetExe
    
    Set-Alias nuget $targetNugetExe -Scope Global -Verbose
    
    Block2:

    ##Download Package Deployer

    ./nuget install  Microsoft.CrmSdk.XrmTooling.PackageDeployment.WPF -O .\Tools
    
    md .\Tools\PackageDeployment
    
    $pdFolder = Get-ChildItem ./Tools | Where-Object {$_.Name -match 'Microsoft.CrmSdk.XrmTooling.PackageDeployment.Wpf.'}
    
    move .\Tools\$pdFolder\tools\*.* .\Tools\PackageDeployment
    
    Remove-Item .\Tools\$pdFolder -Force -Recurse
    
    Block3:
    
    ##Remove NuGet.exe
    
    Remove-Item nuget.exe

Once the PowerShell finishes successfully, we can verify the existence of PackageDeployment folder.
PackageDeployment Folder in CRM Tools

Now to install the Microsoft Dynamics CRM SDK Templates for Visual Studio which contains package template used to create the package deployer project.

  1. Go to the following link in the browser and download Microsoft Dynamics CRM SDK Templates.
    https://marketplace.visualstudio.com/items?itemName=DynamicsCRMPG.MicrosoftDynamicsCRMSDKTemplates
  2. Install it by double clicking the CRMSDKTemplates file.
  3. Once installed, we can now create CRM Package projects in a new solution or existing solutions.
  4. Here we will create a new solution with a new CRM Package project.
  5. Once created we will have a folder structure as below.

Now that we have created a Package Deployer project, we will proceed by adding the required solutions which we require to import into a target environment.

  1. We navigate to the project folder using File Explorer,
    Nisl.BlogDeployer project folder
    Or by right clicking the project name in visual studio and selecting “Open Folder in File Explorer.
  2. In the PkgFolder folder, add the required solutions that need to be imported.
    solutions in PkgFolder
  3. After adding solutions in PkgFolder, the solution would not show up in visual studio NISL.BlogDeployer Solution Explorer window. We need to add these solutions to our project. Since the solution files are already copied into PkgFolder, we need to right click the “PkgFolder” in our project and select “Add” and click “Existing Item…”
    Add Existing Item in PkgFolder
  4. In the “Add Existing Item” window, at the bottom right, change the file type to “All Files (*.*)”, which allow us to see our solutions .zip files. Navigate to the PkgFolder if not already in there. Select all the added solution files and press the “Add” button at the bottom right.

    Now we will be able to see our solution .zip files in our project.
    solutions in project in solution explorer
  5. After adding the solutions in PkgFolder, we need to use these files in our project. We do this by adding them in the ImportConfig.xml.
  6. Open ImportConfig.xml and add the tag "< configsolutionfile solutionpackagefilename="SolutionName.zip">" in between the "< solutions>" tag as given below. Add it multiple times for multiple solutions. Note: The order of the solutions given here is important. The first solution listed here will be the first solution to be imported and then second solution and so on. This is critical if some solutions have dependencies on other solutions.Edit ImportConfig.xml
  7. Also comment out (ctrl+k+c) the whole section of “” and “” as we don’t need it currently.
  8. Build the project by pressing (ctrl+shift+b) or using the Build menu on the top menu bar.
    Build Nisl.BlogDeployer project

Now that our project has been build. We will add the build files from this project to our the PackageDeployment folder in CRM Tools which we created earlier.

  1. Copy the PkgFolder where we added the solutions from our project folder.
    copy PkgFolder
  2. Navigate to the “PackageDeployment” folder in CRM Toos->Tools and paste the whole PkgFolder.
    PkgFolder in PackageDeployment
  3. Now we need to copy the project .dll file (here NISL.BlogDeployer.dll). Since we build this project as a Release Build.
    Release build

    We will navigate to “bin” folder in our project and open the “Release” folder. Here we will find the “NISL.BlogDeployer.dll” file.
    copy Nisl.BlogDeployer.dll
    Copy the “NISL.BlogDeployer.dll” file and paste it in the “PackageDeployment” folder in CRM Tools->Tools.
    Nisl.BlogDeployer.dll in PackageDeployment

We now have the Package Deployer ready to import the 3 solutions namely, BlogSolution1, BlogSolution2 and BlogSolution3 into any Power Platform/Dataverse environment.

To start process of importing, double click the “PackageDeployer” Application(.exe) in “PackageDeployment” folder and follow the steps to log in to the environment.
Package Deployer.exe run

Once logged in to the target environment. It will read all the solutions present in the package deployer project build and start importing.
Package Deployer reading solutions from importconfig
importing solutions to target environment

After Successful import, we can verify the solutions are present in target environment.
solutions in target environment

Thanks for reading our blog.

Comment

This is a Required Field

Loading

Recent Updates

Blogs
18 Jul, 2024

How to use Fiddler to debug your PCF while doing development.

Have you ever felt like you're spending too much time debugging your PCF (PowerApps Component Framework) during development, only to…

READ MORE
Blogs
16 Jul, 2024

How to use Solutions with Power Pages

What is Solution in power Pages? A solution is a container for components such as Website Configuration and Dataverse Components.…

READ MORE
Blogs
15 Jul, 2024

Create a Dataverse table with a SharePoint List

In today’s business world, Organization uses SharePoint lists for document management, and data storage. Let's assume a scenario where an organization…

READ MORE