Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to configure .net native in Visual Studio 2015?

I read this guide for .net native, but I can't found 'Enable for .net native' in popup menu. Should I install some extra plugin for VS2015 for compile with .net native?

like image 735
qpator Avatar asked Aug 13 '15 07:08

qpator


People also ask

What is .NET native runtime?

NET Native is that the compiler is capable of being hosted in the cloud. When you build your Store package in Visual Studio, two packages are created – one . appxupload and one “test” . appx for sideloading.

What is native code in .NET framework?

Native code is computer programming (code) that is compiled to run with a particular processor (such as an Intel x86-class processor) and its set of instructions. If the same program is run on a computer with a different processor, software can be provided so that the computer emulates the original processor.

Is UWP native?

NET Native compiles UWP apps directly to native code. For developers, this means: Your apps feature the performance of native code. Usually, performance will be superior to code that is first compiled to IL and then compiled to native code by the JIT compiler.


2 Answers

[enter image description here

This is the Project + Properties, Build tab of a project that was created with one of the Project > New > Visual C# > Windows > Universal project templates. Your machine must boot Windows 10, you may need to download the SDK separately if you installed VS2015 before Win10. Red arrows indicate the important parts, it should only be enabled for the Release configuration. The Platform setting matters as well, you need to test this for all platforms you wish to support (ARM, x86, x64).

Emphasis on the word test. The only reason you have the .NET Native toolchain on your machine is to verify that your app still operates correctly after the Store server recompiles the package you submitted. It is rather imperfect and cannot handle every possible Universal app. Several pain points, the major one is Reflection. The toolchain cannot see any types you load with reflection so cannot know that these types need to be converted to native code as well. Your app will fail miserably on the user's machine if this isn't taken care of.

Testing is simply a matter of running the Release build of your program through its paces, verifying that everything still works correctly. Start with the x86 platform first. You can cut a few corners when you next test x64 and ARM.

The package you actually submit to the Store is the one that is not built with .NET Native. Microsoft wants to keep the option open to improve the toolchain so needs the MSIL version of your assemblies. Version numbering matters, the last digit is reserved for the store. They'll increment it when they rebuild your app.

In case it wasn't clear yet: the .NET Native toolchain is only available for Universal apps that are distributed through the Store. Maybe it will be usable some day on regular apps but that day is far off, a fundamental different way to package such apps will have to come first.

like image 88
Hans Passant Avatar answered Oct 06 '22 16:10

Hans Passant


.NET Native only works for Windows Store apps currently, you must make sure you chose a windows store app when you created the project for the option to be available.

From the .NET Native FAQ

Will Server/Desktop apps benefit from .NET Native and/or the Compiler in the Cloud?
Desktop apps are a very important part of our strategy. Initially, we are focusing on Windows Store apps with .NET Native. In the longer term we will continue to improve native compilation for all .NET applications.

like image 41
Scott Chamberlain Avatar answered Oct 06 '22 18:10

Scott Chamberlain