How do I publish a Windows Forms Application?

So I made a C# program, and its great and all (its a Windows Form Application). The issue with it, is I don't know how to use it outside of the debug mode form. How do I publish it? My target goal is to create a two folders, put a shortcut to the application in one, along with the other folder which will contain the application and all outside programs (some of the buttons link to batch files). Then I'd want to be able to put it in a RAR compressed file, and upload it online for others to download it. How do I publish it so that happens? How do I take it out of debug mode?

161k 26 26 gold badges 249 249 silver badges 402 402 bronze badges asked May 22, 2011 at 1:14

That's not very wize to create you own update/download/maintinance solution for every platform, dot net framework does, unless you are using ClickOnce technology. I will teach you how to do this, if you change you question accordingly

Commented May 22, 2011 at 13:43

If you will be using ClickOnce, you will be able to update your application automatically to the clients, as well as override, if needed, (for example, to call some batch before actual update of files using spwned processes, notify users for available updates, and such) distribution logic of your application using ClickOnce technologly. You will be able to publish your updated versions directly from your building environment.

Commented May 22, 2011 at 13:51

Additionally, ClickOnce thechnology is avalible on almost any web distrbution platform, either ASP.NET IIS or PHP Apache or Mono. Also it can build updateable CD distributions or for a network share.

Commented May 22, 2011 at 14:02 Do you want to make a setup for your project ? Commented Feb 22, 2017 at 9:23

4 Answers 4

Go into your project folder, then navigate to /bin/Release. If there's an EXE file with the title of your project in there, copy it somewhere (along with any DLLs that you may have linked) and there's your program. If it's not there, first try Build -> Compile Solution in Visual Studio. If it's still not there, navigate instead to /bin/Debug and do the same thing. Then, copy all your batch files into another folder, put them into the same folder, and RAR it.

P.S. Try not to use RAR, few people can extract them. Use ZIP or SEA (self-extracting archive) if at all possible.

answered May 22, 2011 at 1:16 223k 56 56 gold badges 484 484 silver badges 489 489 bronze badges

I downvoted your answer because you suggested RAR-ing the output in the Debug directory. You shouldn't ever distribute a debug version of the application unless you have a specific reason to do so.

Commented May 22, 2011 at 1:29

@Jacob: Well, yes, but ZIP functionality is built-in to Windows, Mac, and Linux. You have to install WinRAR, and some people with limited permissions can't do that. Of course, if your program needs such permissions to run, then it doesn't matter. @Chris Fulstow: Thanks :)

Commented May 22, 2011 at 1:30

Ok - now your answer is sufficient, nice job. +1 And yes, I know that the actual code is not in the debug version, however there are other minor points that make a debug build less advantageous for distribution.

Commented May 22, 2011 at 1:34

I suppose there is a much better solution than that one, and, additionally, use of static liked DLL's sometimes is not enouth to build modern application, (for example extensible ones, using MEF, of Unity as containers)

Commented May 22, 2011 at 13:54

First off, you need to build your application in Release mode, in Visual Studio simply change the drop down near the top of the window to "Release." This will create a bin/Release directory where your sources are located. The folder will contain an EXE for your application and DLLs you need to include. It could (and probably will) include some debugging *.PDB files that you do not want to include -- as those include debugging information.

Copy the contents of that directory somewhere and RAR it up.

Building in x86 Mode

(You should only do this if you have a specific reason to)

If your application uses 3rd party DLLs that are not 64-bit compatible, you may need to do a release build in x86 mode. To do that, click the "Any CPU" drop down and click "New Configuration" (or something like that) and follow the steps to add x86. Then build with the x86 -- Release setting. That will output x86 binaries to a bin/x86/Release folder where your sources are located.

The Preferred Soltuion

Most users are going to prefer some form of automatic installer instead of a simple RAR or ZIP. Visual Studio (Standard/Pro) can create self installing MSIs that do all the work for you. A basic overview is here. You can add shortcuts/etc using the wizards Visual Studio provides.

If you need an even more robust installer you could check out solutions such as InnoSetup or NSIS