How to compile a .NET application to native code?

net native
.net core native compile
net framework compiler
microsoft .net native shared framework
.net native visual studio 2019
compile with .net native tool chain
.net native linux
.net native wpf

If I want to run a .NET application in a machine where the .NET framework is not available; Is there any way to compile the application to native code?

Microsoft has an article describing how you can Compile MSIL to Native Code

You can use Ngen.

The Native Image Generator (Ngen.exe) is a tool that improves the performance of managed applications. Ngen.exe creates native images, which are files containing compiled processor-specific machine code, and installs them into the native image cache on the local computer. The runtime can use native images from the cache instead using the just-in-time (JIT) compiler to compile the original assembly.

Unfortunately, you still need the libraries from the framework in order to run your program. There's no feature that I know of with the MS .Net framework SDK that allows you to compile all the required files into a single executable

Compiling Apps with .NET Native, NET Native Code Compilation binaries in app packages (.appx files) to the Windows Store. In This Section. For more information about� Typically, apps that target the .NET Framework are compiled to intermediate language (IL). At run time, the just-in-time (JIT) compiler translates the IL to native code. In contrast, .NET Native compiles Windows apps directly to native code. For developers, this means: Your apps feature the performance of native code.

RemoteSoft makes a tool that compiles a .NET application into a package that can be run without .NET installed. I don't have any experience with it:

RemoteSoft Salamander

.NET Native and Compilation, At runtime, the just-in-time (JIT) compiler translates it into native code for the target platform. In addition to your main application assembly, an app� The latest member of the .Net ecosystem .Net Core, which is the open-source cross-platform implementation of .Net, lacked the opportunity to compile directly to native code. In this blog post I’ll show you, how you can compile an .Net Core app into native code using the CoreRT by utilizing RyuJIT to compile ahead-of-time (AOT) instead of JIT.

I have tested several of them and at this moment the only one that supports .NET 3.5 and also has a great virtualization stack is Xenocode Postbuild

With ngen you still need to have the .NET framework installed but using a tool as such all your managed code is compiled into native code so you can deploy it to machines without the framework presence.

Compile a .Net Core app to a single native binary – Secana Blog, Usually .Net code gets compiled to IL code which is then just-in-time (JIT) compiled on runtime to native code. This has has the advantage of� The .NET Native toolchain will compile your managed IL binaries into native binaries. Every managed (C# or VB) Universal Windows app will utilize this new technology. The applications are automatically compiled to native code before they reach consumer devices.

As some of the other answers here have mentioned, you can use the .NET Native tool to compile your app to native machine code. Unlike those answers, however, I will explain how to do it.


  1. Install the dotnet CLI (command line interface) tool, which is part of the new .NET Core toolchain. We'll use this to compile our app; you can find a good article about it here.

  2. Open up a shell prompt and cd to the directory of your app.

  3. Type this:

    dotnet compile --native

That's it! When you're done, your app will be compiled down to a single binary, like this:

It'll be a standalone executable; no PDBs, assemblies, or config files included (hooray!).

Alternatively, if you want an even faster program, you can run this:

dotnet compile --native --cpp

That will optimize your program using the C++ code generator (as opposed to RyuJIT), so your app is even more optimized for AOT scenarios.

You can find more info on this at the dotnet CLI GitHub repo.

Fight the global warming: compile your C# apps ahead of time, .NET framework had a technology called NGEN that allowed A JIT-compiling runtime will generate native code on demand — when your app An AOT- compiling runtime pre-generates native code as part of the app build. Is it possible to compile .NET IL code to machine code? Yes, but the .NET Framework does it for you at runtime (default) or at install time (ngen). Among other reasons, this IL -> machine code is done separately on each install machine so it can be optimized for that particular machine.

Microsoft has announced its .NET Native Preview that will allow to run .NET applications without having the framework installed.

Take a look:


You can download Microsoft .NET Native for VS2013 from here:

Generate Native Executable from .NET Core 3.1 Project, Introduction: Compilation of a Managed Code? compiles the result for producing a native executable of the application (That's why the C++� Compile code by using C# compiler The.NET Framework provides the ICodeCompiler compiler execution interface. The CSharpCodeProvider class implements this interface and provides access to instances of the C# code generator and code compiler.

.NET Internals and Native Compiling, NET assembly to native machine code and then removing the MSIL code holds its promise and actually removes the MSIL code from one's application, but the� Strictly speaking it means converting the MSIL code of a .NET assembly to native machine code and then removing the MSIL code from that assembly, making it impossible to decompile it in a straightforward way. The only existing tool to native compile .NET assemblies is the Salamander.NET linker which relies on native images to do its job.

Compilation Instructions for .NET Web Applications (ASP.NET), NET applications, Veracode requires you to supply all the forms the application and all the dependencies in the compiled form, which are the .dll, .exe, and .pdb files. NET 1.1 application, you must perform the steps on a machine that has .

Making a tiny .NET Core 3.0 entirely self-contained single , And I will compile and publish it for Win-x64, my chosen target. If your app uses reflection you can let the Tree Trimmer know by telling the NET Core 5.0, on Linux x64), because it contains native code that is only usable in�

  • I don't find any other reason to use this other than performances. The CLR code can still be read as before, and you still require .NET. So disappointing Microsoft didn't provide with a tool that would fix what I consider to be a big problem (anyone can view your high-level code as it is)
  • I do not agree with Espo. Because, the text in grey says the "Runtime" which means the CLR and thus the .NET Framework that comes into picture as rightly pointed by Chris. However, NGen point is true. The question is, without using CLR/Runtime/.NET Framework all are same.
  • It is time to get excited however, looks like the .net framework is finally getting a native compiler -
  • ILMerge your .NET executable and everything in its dependency tree then Ngen if you want an executable independent of .NET.
  • That's the only tool I've ever heard of that will do it without needing the framework. Of course, it costs $1249.
  • I tried a couple of times over the past few years, to get information or evaluation, but they never return my emails about pricing or demos so I think their product may be a bit suspect.
  • Note: this is only supported against projects built with .NET Core. (+1, though)
  • You forgot the very important detail that .NET Native requires Windows 10.
  • +1 - I've been waiting years for this to happen. I hoped the world's infatuation with the "Virtual Machine" would run it's course sooner, but nonetheless, it is happening. I expect we are about to see a resurgence of native compilation. As you said, its for Window's Store Apps at the moment, but it is only a matter of time before the desktop market demands equal treatment.
  • "CoreRt is alpha version and working only with simple helloworld type apps." This is not true - there are games on Steam (e.g. which are more complex than helloworld.