C
C#2y ago
ero

Compile .NET Framework class library with NuGets to single DLL [Answered]

I have a .NET Framework 4.8.1 (unable to upgrade) class library which references a number of NuGet packages. I would like to compile this library to a single, self-contained DLL file. Is this possible? How?
4 Replies
ero
ero2y ago
Hm, Costura.Fody seems to work. Is there another way? It kinda bloats my library with a bunch of NuGets that I don't even use.
Accord
Accord2y ago
✅ This post has been marked as answered!
ero
ero2y ago
so, let me try to cover what happened i'm trying to create a .NET Framework class library for a program which allows a sort of plugin-system. what it does is load specified DLL files and then interacts with their code this means that i have (almost) free reign about what i put into that library. it's obviously sandboxed, only allowing specific calls to interact with the program now, unfortunately this system means that i cannot actually use any NuGets or other referenced libraries in my own plugin the reason is that calling any methods or using any types from those libraries will result in a FileNotFoundException for the target assembly i was hoping i could compile my plugin to a single file with all references embedded i was playing around with this yesterday, trying out different combinations of CLI commands, csproj tags, Costura, and ILMerge and for some odd reason, i was eventually able to simply compile, and the FileNotFoundExceptions would simply not throw at all anymore without Costura, and without ILMerge unfortunately i wasn't smart enough to use source control, and i fiddled around a bit with the solution and project settings, and it broke again and i have absolutely no clue how this worked in the first place does anyone have even the slightest idea? yeah so i just added the Costura.Fody nuget package, compiled my project, and removed it again, and now all my referenced types are embedded... no idea what's going on
Accord
Accord2y ago
✅ This post has been marked as answered!