I am trying to publish my C# Console .Net Core App using VS 2019, .NET v5.0.
In
bin\Release\net5.0\win-x64
folder, there is an .exe executable but also other extensions. When I delete some of them, the executable does not run. I have tried both self-contained and framework-dependent. Is there a way to merge all the files to a stand-alone .exe or to publish as a stand-alone executable?
Asked
Active
Viewed 2,713 times
0

alperen
- 21
- 1
- 2
-
Maybe https://stackoverflow.com/a/62086103/51685 ? – AKX Nov 11 '21 at 10:08
-
There I get 4 .dll files and a .pdb file with the .exe – alperen Nov 11 '21 at 11:30
-
1Does this answer your question? [.Net whole application as a single .exe file?](https://stackoverflow.com/questions/3261942/net-whole-application-as-a-single-exe-file) – Progman Nov 11 '21 at 12:33
1 Answers
2
You have to choose a specific target runtime and then under publish options - "Produce Single File".
-
-
hm the way actually worked for me. It created the .exe in the target location. Does it also not work for you in a fresh/new console application? – Kudos Nov 11 '21 at 16:02
-
Yeah I tried with fresh consoles so many times, the .exe that has been created didn't run without the .dll files. Would the type of the project make any difference? – alperen Nov 11 '21 at 16:13
-
Dont think so. For me it was working right out of the box. I was creating a .Net 5 console app, right click on the project -> publish, Created a publish profile, then changed the target runtime and file publish option. After that i could find it in the target location bin\Release\net5.0\publish\ – Kudos Nov 11 '21 at 16:42
-
I can find it there too. I mean are you able to run it as a single file when you copy the .exe file and paste it to a different directory (like desktop)? In my case it shuts down upon starting. I tried with a few projects and result is the same. – alperen Nov 12 '21 at 21:19
-
Ok, so wait: Did you add sth. like Console.ReadLine() at the end of Main() ? For me it certainly shows the Hello World, no matter which directory I paste the .exe in. – Kudos Nov 12 '21 at 23:37
-
That 'File publish options' section doesn't exist at all in my VS 2019. Is there something I need to do to enable it or make it appear? – Kyle Humfeld Jan 10 '23 at 00:04