Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I build a native binary on .NET Core using the current preview?

Using the current .NET Core preview, how do I compile (Publish ?) a native binary for a console application. I am on Mac OS 10.11.

I did the following:

dotnet new
dotnet restore
dotnet publish

I kind of expected "publish" to build a native binary for me, but it did not. It places a .dll, along with some JSON, in the publish folder ? I should mention the application runs fine when using dotnet run.

So, how do I get a native binary for my simple console application ?

like image 304
driis Avatar asked May 18 '16 19:05

driis


People also ask

How do I create a true Publishinginglefile?

Add <PublishSingleFile>true</PublishSingleFile> to your project file. On the Solution Explorer pane, right-click on the project you want to publish. Select Publish. If you don't already have a publishing profile, follow the instructions to create one and choose the Folder target-type.

What is native AOT?

The native AOT deployment model uses an ahead of time compiler to compile IL to native code at the time of publish. Native AOT apps don't use a Just-In-Time (JIT) compiler when the application runs. Native AOT apps can run in restricted environments where a JIT is not allowed.


1 Answers

According to an MS dev on the Slack channel, native compilation was removed/disabled in RC2 since it wasn't deemed ready yet.

There does seem to be a little bit of interest in it, so I've been debating whether to try to get it running myself, from the CLI source.

Otherwise, we'll just have to wait, but I agree, huge disappointment.

EDIT: just for completeness, I should add that .NET Core and .NET Native are available for UWP / Windows Store apps, though obviously this is not cross-platform.

EDIT #2: since this seems to continue to be getting attention, the new way that this is planned on being done is CoreRT, currently in active development.

like image 58
Steve Desmond Avatar answered Oct 20 '22 18:10

Steve Desmond