Showing results for 
Search instead for 
Did you mean: 
Frequent Visitor

Difficulty creating a plugin with merged assemblies or shared code

I'm developing a Dataverse plugin. I've setup a solution in Visual Studio 2019 using the PowerPlatform Soltuion and Project templates (here). All works well - I can build and deploy a plugin, add steps etc.

However I now want to add further code in a BusinessLogic project (rather than having all the code in the plugins project) within my VS2019 solution. As the plugin code needs to reside in 1x DLL for uploading to Dataverse, need some way of combining the DLL's from each of these 2x projects.


Searching online indicates that there are 3 ways of doing this: ILMerge, ILRepack or shared projects. I've tried each of these without succes:

  • Shared project: Can't add a reference to a SharedProject to a project based on the "Power Platform Plug-in Library" template
  • ILMerge: Added the MSBuild.ILMerge.Task nuget package to the Plugins project. However this stops the plugins project from building with an error about not being able to find the Plugin.dll in the bin\debug directory.
  • ILRepack: Can build and merge the plugin and BusinessLogic dll's but trying to upload this via the Plugin Registration Tool gives a bad image format error.

Has anyone had success with this?



Any of ways should work fine.

Can you please provide a broader description on Adding fo Shared Projects - maybe some screenshots?

Can you please show the script that you use with ILRepack - to be more specific - what version of .Net Framework do you use?

Frequent Visitor

Thanks for your quick reply. Some more details:


My Visual Studio solution is based on the "Power Platform Solution Template". It contains a CRMPackage project from the "Power Platform Package" template and a Plugins project from the "Power Platform Plug-in Library" template. There's also a class library project called Entities (not based on any templates). The Plugins project references the Entities project. From within VS2019, the solution can build and deploy to Dataverse. All projects based on .Net 4.6.2.


However if the code of the Plugins project references the Entities project then D365 throws an error as expected when the plugin fires (because Entities.dll wasn't deployed).


Shared Project

From the Plugins project, doing AddReference from the menu shows the "Reference Manager" popup as expected. But this doesn't contain "Shared Projects" on the left menu. Interestingly, doing the same on the Entities project does show SharedProjects - so I assume it's something to do with the template that was used to create the Plugins project?



Prior to adding the ILMerge nuget packages, the solution would build successfully. The bin\debug directory of the Plugins project contained plugin.dll and entities.dll as expected (because Plugins references Entities). However after adding "MSBuild.ILMerge.Task " package to the Plugins project, the solution wouldn't build, complaining of not being able to find Plugin.dll in the bin\debug directory.



I removed ILMerge and tried ILRepack package. This successfully created a merged Plugin.dll in bin\debug\merged, and judging by it's size, it looked to be a merge of Plugin.dll and Entities.dll. However when trying to upload this to Dataverse using the plugin registration tool, the error said that the dll didn't contain a manifest file


Any ideas?


I was able to add Shared Project and reference it with no issues:



Regarding the usage of ILMerge, I used this one - and it worked with no issues.

I don't have an experience using ILRepack personally, check this post -




Frequent Visitor

Thanks for looking into this.

In your screenshot, is the solution and/or the project created from the Power Platform templates?

I'm wondering if it's the template(s) that are causing my issues.


The solution was not there initially but it was created once I opened the project using VS.

Frequent Visitor

Was the project created from the PowerPlatform template?

I will try it (create project from a template but use a vanilla solution).

Will report back tomorrow.

Frequent Visitor

I created a new project based on the PowerPlatform plugins template. Added a SharedProject to the solution.

Can't add reference from the plugins project to the shared project - see screenshot:



Using VS2019:



If a add a normal class library project to the solution then can add a reference to shared projects:



Super User
Super User

Yes, ILMerge is the way to go for this, and I've done it myself, but it is unsupported by Microsoft. This has been the case for over a decade now and a source of constant frustration for many developers. But there is new hope: coming soon (next month, supposedly) we will be getting a new feature called Dependent Assemblies that will eliminate these ILMerge headaches once and for all. Hopefully you can wait that long!

Frequent Visitor

Update on this



Removing the <ProjectTypeGuids> element from the csproj file allows a SharedProject to be added. It may break something else



See above from @cchannon 



I think the issue about the manifest was caused by an incorrect key file. Was using a pfx, need to use an snk

Helpful resources

Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Users online (4,295)