Dataverse: Ways to Generating NuGet Package to be used in Dependant Assembly plug-ins

With all the crazy changes happening in Power Platform technologies, especially Dataverse/Model-Driven-Apps. We must admit, that the plugin development has not really changed. So I believe most organizations still use plugin projects that created so long time ago and when the Dependant Assembly plug-ins (preview) come to GA. Then they will start to migrate the old plugin project to the new version so we can make use of the Dependant Assembly plug-ins.

Before we go to the demonstration, you need to make sure to install the Power Platform CLI. This tool is updated regularly by Microsoft and they keep adding more and more features, especially for Developers to do their work! If you already installed it, make sure to update the version using the command “pac install latest“.

Create New Project + Copy All the files

The easiest way to do it in my opinion is to create a new project with the same name as the targeted project. For example, I have the below .csproj file:

Old plugin csproj

For demonstration purposes, I put the directory of SampleOldPlugin and create a new empty directory with the name of New. Once we set that, we only need to open command prompt > CD to the targeted folder (inside New folder) > then execute command “pac plugin init -o SampleOldPlugin” (for the detail command you can check here):

Create the same plugin project name

We need to pass the parameter -o SampleOldPlugin. When the CLI creates the plugin project, it will create the correct project name as what you want (in my case, I named it SampleOldPlugin). Once we did it, the next step we need to open both projects’ directories > copy the files that you need from the old project to the new one > paste to the new project’s directory:

Copy the files you needed from the old project to the new project

Once we copy all the necessary files into the new project, the next steps are to remove the generated files.

Delete unnecessary files

For your project, if you have a NuGet package/external DLL, you can add to the reference and you can build (and when you got the build error, you need to fix it) and deploy it.

Deploy the NuGet package

You also can verify your NuGet package using NuGet Package Explorer:

Verify your NuGet Package

Build Manually your NuGet Package + Edit Using NuGet Package Explorer

Before you scroll down, this is not worth it. 🤣 But I do it for observation + learning purposes. The first step is to make sure that you use .NET Framework 4.7.1 for the project. Then if your project is still dependent on the local files (especially Microsoft.Xrm.Sdk.dll/Microsoft.Crm.Sdk.dll), you need to remove that dependency + install Microsoft.CrmSdk.CoreAssemblies NuGet package (just to be safe). For this demonstration, I created a simple throw error where I used Newtonsoft as the third-party library:

using System;
using Microsoft.Xrm.Sdk;
using Newtonsoft.Json;

namespace SampleOldPlugin
    public class Test
        public string Message { get; set; }

    public class DemoPlugin : IPlugin
        public void Execute(IServiceProvider serviceProvider)
            var test = JsonConvert.DeserializeObject<Test>("{'Message': 'Hello Temmy!'}");
            throw new InvalidPluginExecutionException("ERROR FROM DemoPlugin: " + test.Message);

While this is my .csproj file to show you this is the old project:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="">
  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <TargetFrameworkProfile />
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
    <Reference Include="Microsoft.Crm.Sdk.Proxy, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
    <Reference Include="Microsoft.Xrm.Sdk, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
    <Reference Include="Newtonsoft.Json, Version=, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
    <Reference Include="System" />
    <Reference Include="System.Buffers, Version=, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
    <Reference Include="System.Core" />
    <Reference Include="System.DirectoryServices" />
    <Reference Include="System.DirectoryServices.AccountManagement" />
    <Reference Include="System.IdentityModel" />
    <Reference Include="System.Memory, Version=, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
    <Reference Include="System.Numerics" />
    <Reference Include="System.Numerics.Vectors, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
    <Reference Include="System.Runtime.CompilerServices.Unsafe, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
    <Reference Include="System.Runtime.Serialization" />
    <Reference Include="System.Security" />
    <Reference Include="System.ServiceModel" />
    <Reference Include="System.ServiceModel.Web" />
    <Reference Include="System.Text.Encodings.Web, Version=, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
    <Reference Include="System.Text.Json, Version=, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
    <Reference Include="System.Threading.Tasks.Extensions, Version=, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
    <Reference Include="System.ValueTuple, Version=, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
    <Reference Include="System.Web" />
    <Reference Include="System.Xml.Linq" />
    <Reference Include="System.Data.DataSetExtensions" />
    <Reference Include="Microsoft.CSharp" />
    <Reference Include="System.Data" />
    <Reference Include="System.Xml" />
    <Compile Include="DemoPlugin.cs" />
    <Compile Include="Properties\AssemblyInfo.cs" />
    <Compile Include="DemoPluginHelper.cs" />
    <None Include="app.config" />
    <None Include="packages.config" />
    <None Include="StrongSignKey.snk" />
  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
  <Import Project="..\packages\System.Text.Json.6.0.2\build\System.Text.Json.targets" Condition="Exists('..\packages\System.Text.Json.6.0.2\build\System.Text.Json.targets')" />
  <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
      <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them.  For more information, see The missing file is {0}.</ErrorText>
    <Error Condition="!Exists('..\packages\System.Text.Json.6.0.2\build\System.Text.Json.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\System.Text.Json.6.0.2\build\System.Text.Json.targets'))" />
  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
       Other similar extension points exist, see Microsoft.Common.targets.
  <Target Name="BeforeBuild">
  <Target Name="AfterBuild">

Next, open the Developer Command Prompt (from Visual Studio) > cd to the .csproj file > execute command “nuget spec“:

Generated .nuspec file

You can open and update the .nuspec file. Below is a sample of my changes:

<?xml version="1.0"?>
<package >
    <releaseNotes>Temmy updates</releaseNotes>
    <copyright>Copyright 2022</copyright>


Then if you want to make all the setup correctly, you can open your Visual Studio > right click on the project > Properties > Assembly Information (on the Application tab) > Update all the properties necessary for you:

Update the Assembly Information

After you make sure you can build the project successfully, the next step is to open your Developer Command Prompt again and execute the command “nuget pack” (make sure you are in the .csproj folder):

Create the NuGet Package

If you go to the .csproj directory, you will see that we got SampleOldPlugin. But, if you sneak peak the NuGet package using NuGet Package Explorer, you will see that there are some dependencies that not needed + missing dependency (Newtonsoft.Json.dll) that supposed included in the Package contents (right side):

Checking the NuGet Package generated

To remove those packages that we don’t need, you can open the packages.config in your project (by default if using an old project) and add the property developmentDependency=”true” to all the packages that you don’t want to include:

Left is the original, Right is with the changes

With this, when you execute the command “nuget pack” > open the NuGet Package using NuGet Package Explorer > in the Package contents, under net471 > right click > add existing file > add Newtonsoft.Json.dll in your debug folder. After added, click File > Save, and this package is ready to be deployed (I know this part still needs a manual way).

Adding the Newtonsoft.Json.dll manually

Once you deploy it, the package is ready to be used. For the demonstration purpose, I add a plugin step in the Message=Update + Entity=’Contact‘:


Happy CRM-ing!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

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