Support for merging .NET Core / .NET 6/7/8 class libraries into a single DLL

Padma Dighe 40 Reputation points
2026-01-06T08:30:53.4633333+00:00

Hi,

I’m working with .NET 6/7/8 class libraries and want to bundle a library and all of its dependencies into a single DLL file.

I’ve explored the following options:

  • ILMerge / ILRepack (but these are officially for .NET Framework and unreliable for .NET Core / modern .NET).
  • Fody/Costura (embeds dependencies as resources) — seems workable but not sure about production reliability.
  • PublishSingleFile (official .NET feature) — works for applications (exe) but not for class libraries.

Questions:

  1. Is there any Microsoft‑supported way to merge .NET Core/.NET 6/7/8 class libraries and their dependencies into a single DLL?
  2. Are community tools like ILRepack, dnMerge, or Costura.Fody recommended for production‑grade library merging? If so, are there known limitations?
  3. What is the recommended modern pattern for distributing class libraries with all dependencies while minimizing deployment complexity?

Thanks for the help!

Developer technologies | .NET | Other
0 comments No comments
{count} votes

Answer accepted by question author
  1. Surya Amrutha Vaishnavi Lanka (INFOSYS LIMITED) 1,725 Reputation points Microsoft External Staff
    2026-01-07T11:13:40.84+00:00

    Thanks for reaching out! Here are the clarifications for the questions

    1. Microsoft-supported way to merge class libraries into one DLL

    No.

    .NET Core / .NET 6+ intentionally does not support assembly merging for class libraries.

    ILMerge / ILRepack are not supported for modern .NET and are unreliable.

    Microsoft has explicitly moved away from this model.

    2.Are ILMerge / ILRepack / Costura recommended?

    No, for production grade modern .NET.

    Works by embedding dependencies as resources, not officially supported by Microsoft

    3.Why PublishSingleFile doesn’t apply here

    PublishSingleFile is ONLY for executable apps, it does NOT work for:

    Class libraries, NuGet packages

    This is by design and will not change

    Here are some correct way

    • NuGet package with dependency references
    • Package your class library as a NuGet package
    • Declare dependencies normally
    • NuGet handles versioning, resolution, and compatibility
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Q&A Assist
    2026-01-06T08:31:03.61+00:00
    AI generated content. This question contains an answer created with AI from Q&A Assist. Learn more
    1. As of now, there is no Microsoft-supported way to merge .NET Core/.NET 6/7/8 class libraries and their dependencies into a single DLL file. The PublishSingleFile feature is available for applications (executables) but not for class libraries.
    2. Community tools like ILRepack, dnMerge, and Costura.Fody can be used for merging class libraries, but they may not be recommended for production-grade library merging due to potential reliability issues and limitations. These tools were primarily designed for .NET Framework and may not fully support the modern .NET ecosystem.
    3. The recommended modern pattern for distributing class libraries while minimizing deployment complexity is to use NuGet packages. This allows you to package your library along with its dependencies, making it easier for consumers to manage and deploy the library without the need for manual merging or bundling.

    References:

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.