1

How do you compile and export a finished C# program in Visual Studio in a single executable?

Kiang Teng
  • 1,675
  • 4
  • 23
  • 42

2 Answers2

3

As soon as you press the compile button an executable file is created inside the bin/debug-folder of where you save your project. Unless you've created a class-library the program is just that one .exe file. For every class-library you create there will be a .dll file so as long as you don't use class-libraries you'll be fine.

peterthegreat
  • 406
  • 3
  • 9
  • Except not using class-libraries results in horribly unmaintainable monster assemblies, and hakes it harder to enforce single responsibility. A better solution is to allow development to proceed taking full advantage of different libraries and merge them afterwards. – Michael Shimmins Nov 29 '10 at 06:21
  • But if you're ending up with one assembly then there is no single responsibility for every class-library you use in your project, because you still have to recompile the whole project into one monster assembly as you call it. Though I agree for your own purposes that it's more maintainable. – peterthegreat Nov 29 '10 at 07:09
  • But you do the merge after development - for all intents and purposes you maintain a nicely separated assembly structure. Merging them becomes a deployment concern not a development concern. – Michael Shimmins Nov 29 '10 at 07:16
  • Yes that's what I meant with "Though I agree for your own purposes that it's more maintainable". I agree with your opinions, I was just stating that when assembled there is no more single responsibility e.g. you can't just recompile one of the .dll's. – peterthegreat Nov 29 '10 at 07:23
3

You can merge libraries into your exe using a variety of tools.

See Merging dlls into a single .exe with wpf for an example.

Community
  • 1
  • 1
Michael Shimmins
  • 19,961
  • 7
  • 57
  • 90