I am developing a Windows Forms project in Visual Studio 2019. My question is that when compiling the project, multiple files are generated, on which the executable is dependent. Is there a way to compile them all into a single .exe file? NOTE: I don't intend to use setup.exe: I just want a single executable that I can run from any part of my file system.
Thanks in advance.
Here are the steps to publish a single file Winforms (.NET 7.0) app (Release mode) in VS2022:
Right click on project node -> "Publish..." and press "Show all settings" link

Choose your target runtime, I use Win-x64 in Release mode. Open "File Publish Options" and make sure "Produce single file" option is checked.
Close the "Show all settings" dialog and press publish.
Voila!

I was having the same problem, I was using .Net Framework 4.7.2, and this was the only solution I found:
Just follow these steps:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With