转载自http://www.joebest.org/2011/09/mono-and-mkbundle-on-windows.html

A problem for a fair few Mono and .NET developers is "what if the user doesn't have Mono or .NET installed?" You can bootstrap the .NET installer into an .msi installer, but if you really need to just zip up a few files and send them to someone, and have your application just work, then you might need mkbundle.

 
Mkbundle is a great tool included in the Mono framework, which allows you to embed the Mono runtime with your application, into a single executable. On OSX you can just use MonoMac (especially if you want to distribute something on the Mac App Store), but on Windows we'll need to crank up the good ol' command line!
 
Right, the first thing to say, is that on Windows, mkbundle is sort of broken (at least in Mono 2.10.5 which I'm using), the code is pretty straightforward, so I might have a go at patching it up if I get some time in the next few months, I've never contributed to an open-source project before, first time for everything. Anyway, here's the list of workarounds I had to use to get an application to bundle and run:
  1. Install Mono to a path with no spaces (mine is C:\Mono-2.10.5)
  2. Install Cygwin, adding the following packages:
    • gcc-mingw
    • mingw-zlib
    • pkg-config
    • nano
  3. Start up Cygwin and type nano .bashrc
  4. At the end of the file add:
    • export PKG_CONFIG_PATH=/cygdrive/c/Mono-2.10.5/lib/pkgconfig
    • export PATH=$PATH:/cygdrive/c/Mono-2.10.5/bin
  5. Restart Cygwin
  6. Copy the Mono executable to C:\Cygwin\<user>\home
  7. Copy C:\Mono-2.10.5\etc\mono\4.0\machine.config to the home directory alongside the executable
  8. Type the following into cygwin:
    • mkbundle -c -o host.c -oo bundle.o --deps --machine-config machine.config YOUR_APPLICATION.exe -z
    • nano host.c
  9. Scroll down to find:
#ifdef _WIN32
#include <windows.h>
#endif

Change it to:

#ifdef _WIN32
#include <windows.h>
#endif
#undef _WIN32

  1. Save the file by hitting CTRL + o, and then enter
  2. Finally, to compile the intermediate files into a final executable, type the following into Cygwin:
    • gcc -mno-cygwin -o BundledExecutable.exe -Wall host.c `pkg-config --cflags --libs mono-2|dos2unix` bundle.o -lz
  3. You'll need to copy mono-2.0.dll and zlib1.dll from C:\Mono-2.10.5\bin to wherever your final executable will be, other than that, you should be good to go.
That should do the trick, but this specific series of steps might not work (or be unnecessary) in later releases of Mono.
 
打包后文件会在运行时在8m左右而且无需安装 直接绿色文件解压即可运行 对。net的部署来说简直就是福音 下图是打包后的程序