.net - Compile C# Application to native executable -
i know question came few times before, not find answer our simple case:
is there free tool compiles small .net c# application native executable?
what found far expensive tools strip down .net framework , compile executable, thats no neccessarry in our case. installing .net framework no problem, want precompile c# project user can not decompile il code security reasons. .net obsucator not enough, have sensitive code sections.
mono-aot not option, needs have mono installed on target machine undersood.
ngen.exe seems closest need, how can distribute output file? seems include il code well, says "whenever ngen-generated image run in incompatible environment, .net framework automatically reverts using jit".
are there practical workflows scenario?
edit2: wonder why question closed...
the solution mkbundle mono project:
i found shell script compiles .net application mono's mkbundle standalone native executable , modified latest versions, of may 2013 can use script follows:
https://gist.github.com/tebjan/5581296
1.) install cygwin , make sure select following packages: - gcc-mingw - pkg-config - mingw-zlib1 - mingw-zlib-devel
2.) install mono release package: "mono windows, gtk#, , xsp"
3.) download script , place besides application , modify fit environment (read comments in file carefully).
4.) open cygwin , navigate output folder of application executable , scipt lies, e.g. yourproject/bin/release
5.) execute script command: ./mkbundle_cygwin.sh
troubleshooting: if bundled executable not work, make sure original .net application works on mono. can test calling mono.exe , pass .net app or installing xamarinstudio , running project there (make sure set mono runtime).
for particular case, seems simplest approach put magic bytes separate native dll, , have managed code use p/invoke retrieve them. meets 2 requirements have mentioned:
- separate magic data code uses it
- keep magic data out of .net assemblies
Comments
Post a Comment