I started learning c# a couple days ago and want to send my first program to my friend but as a standalone exe file that can be shared through google drive. I've found several solutions but I coudln't understand any of them. Is there a simple solution to compile an exe file or a standalone app in visual studio 2019 that would just work when you open it
2 Answers
All you gotta do is simply build the project within Visual Studio, once that's done. Go to your projects folder and go into bin/Release (or Debug if you've selected debug build)/myprogram.exe. It should make a standalone .exe file!
Maybe this could also help you. Official Documentation: Compiling Building in Visual Studio
- 220
- 1
- 7
-
this produces a couple files and an EXE file which won't function without the others and I would need to use a setup program, and that just complicates the process more. iv'e tried to share just the EXE file and it did not work, but thank you anyway. – Ron Kan Aug 15 '20 at 17:17
-
Um... so an all-in-one .exe. I know for sure I used to use that NuGet package a few months back its called Fody, once installed and loaded It will automatically be embedded into your output .exe file! https://github.com/Fody/Costura – Jessy Guirado Aug 16 '20 at 00:26
One annoying thing with .NET Core is that when you build it in Visual Studio it makes lots of separate files, which is annoying for portability.
A fix to this is to right-click on your project in Solution Explorer and click Publish. Select Folder Profile, give it a name and save it.
After that, you will need to edit the target runtime option, and set it to win-x86. After that, you should see a dropdown box at the bottom of the dialog, expand it and check 'Produce a single file'.
Then you can hit Publish and it should produce a single file.
NOTE: This does not work in .NET Framework, only .NET Core.
- 343
- 3
- 11