-1

Title

I am pretty new to C# (although I'm coming from java so I'm catching up quickly) and when using Visual Studio and building, I get a bunch of files as well as the executable, including dlls with the names of a few of the nuget packages I installed, a dll, pdb, etc. I also realized that I can't just give out the .exe from that folder because it references the files surrounding it. I want to put all of these files into one final executable that uses the needed files without installing them. Also, my project uses Tor and the only thing I need help with there is being able to package my project with tor as well (again, preferably in the same executable so that the user doesn't have to have tor installed to use my program.

TL;DR/summary: how do I include all the required dlls in 1 final .exe that will also be able to hold another exe (tor) inside it so that tor doesn't have to be installed for it to work?

I guess I could download the tor expert bundle when the application is launched but again it would be nice if this wasnt needed

jchernin4
  • 11
  • 2
  • 7
  • Does this answer your question? [Embedding DLLs in a compiled executable](https://stackoverflow.com/questions/189549/embedding-dlls-in-a-compiled-executable) – Joe Sewell Jun 09 '20 at 20:01
  • 1
    Are you using .NET Core or .NET Framework? – DaveShaw Jun 09 '20 at 20:01
  • What is your executable? A web site? A desktop app? – Dour High Arch Jun 09 '20 at 20:12
  • I am using core but if framework is needed I can switch to it. – jchernin4 Jun 09 '20 at 20:17
  • I use ILMerge to create single executables (mine are all .net and I believe it only works with .net). – Mike Cheel Jun 09 '20 at 20:23
  • I tried using ILMerge to create the executable earlier but for some reason it said that it "couldnt access the assembly" which when I googled seems to mean that my code is unmanaged and ILMerge only works with managed code, however this is C# so I don't know why this would be an issue. – jchernin4 Jun 09 '20 at 20:24

2 Answers2

0

I found an answer that I guess will work for now: How to merge multiple .NET Core assemblies into a single one (.dll / .exe)?

This still doesnt fix the problem of trying to keep tor inside the executable, but I guess I am just going to have tor download into some temp folder until I find a better fix.

jchernin4
  • 11
  • 2
  • 7
  • You could save the .exe as a resource in your binary (maybe compressing it first) and then write it out to disk, e.g. to a temporary folder, to execute. – Rup Jun 10 '20 at 08:05
-1

use .net core 5.0 . Use with Ilmerge nuget manager.

haseakash
  • 31
  • 1
  • 6