I know that this question came up a few times before, but i could not find an answer for our simple case:
Is there a free tool which compiles a small .NET C# application into a native executable?
What i found so far are expensive tools which strip down the .NET framework and compile it into the executable, but thats no neccessarry in our case. Installing the .NET framework is no problem, we just want to precompile a C# project so that a user can not decompile the IL code for security reasons. A .NET obsucator is not enough, as we have sensitive code sections.
Mono-AOT is not an option, as it needs to have mono installed on the target machine from what i undersood.
Ngen.exe seems to be the closest to what we need, but how can we distribute the output file? it seems to include the IL code as well, as it says "whenever an NGen-generated image is run in an incompatible environment, .NET framework automatically reverts to using JIT".
Are there any practical workflows for this scenario?
EDIT2: I really wonder why this question was closed...
The SOLUTION is mkbundle from the Mono project:
I found a shell script which compiles a .NET application with Mono's mkbundle to a standalone native executable and modified it to the latest versions, as of May 2013 you can just use the script as follows:
https://gist.github.com/tebjan/5581296
1.) Install cygwin and make sure you select the following packages: - gcc-mingw - pkg-config - mingw-zlib1 - mingw-zlib-devel
2.) Install the Mono release package: "Mono for Windows, Gtk#, and XSP"
3.) Download the script and place it besides your Application and modify it to fit your environment (read the comments in the file carefully).
4.) Open cygwin and navigate to the output folder of your application where the executable and the scipt lies, e.g. YourProject/bin/Release
5.) Execute the script with the command: ./mkbundle_cygwin.sh
Troubleshooting: If your bundled executable does not work, make sure the original .NET application works on mono. You can test that by calling mono.exe and pass your .NET app to it or by installing XamarinStudio and running your project from there (make sure you set mono as runtime).