-1

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

Ron Kan
  • 13
  • 1
  • 1
    This seems to have been [answered](https://stackoverflow.com/q/50703578/3791245) here [before](https://stackoverflow.com/q/44074121/3791245). Do those links help? – Sean Skelly Aug 13 '20 at 23:18

2 Answers2

1

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

Jessy Guirado
  • 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
0

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.

linux_kettle
  • 343
  • 3
  • 11