move runtime DLLs into bin/lib folder after dotnet publish

Is it possible to move all the runtime libraries found in the .deps.json file into a bin/lib folder to declutter the game .exe?

By libraries I mean the generic runtime libraries such as Microsoft.VisualBasic.Core.dll, Microsoft.Win32.Primitives.dll, etc. defined inside targets.NETCoreApp[…].runtimepack[…].runtime of the .deps.json file

More specifically, when I dotnet publish (self-contained) I get this:
MyGame.exe
MyGame.dll
Microsoft.VisualBasic.Core.dll
Microsoft.Win32.Primitives.dll

But I want to get:
MyGame.exe
MyGame.dll
bin/Microsoft.VisualBasic.Core.dll
bin/Microsoft.Win32.Primitives.dll

And I’m happy to do it as a manual task after the dotnet publish - just not sure what needs to be changed

Has anyone ever done this? Or does everyone just distribute their games with (a million of) DLLs in the same folder as the game .exe?

This SO post is very similar to what I’m trying to achieve. There is mention of additionalProbingPaths and such, but I’m unable to get it to work

I too would love to know this

I use: GitHub - nulastudio/NetCoreBeauty: Move a .NET Core app runtime components and dependencies into a sub-directory and make it beauty.

It works really well but you might have to exclude some DLLs depending on your game.

1 Like