.NET Ecosystem 2015 and Windows 10 Universal Applications
NET Framework and .NET Core – what happened?
.NET Framework (now in version 4.6) is still the basic programming platform from Microsoft which includes runtime environment. It still consists of Common Language Runtime (CLR) and BCL (Base Class Library). When you install .NET Framework you get the runtime and also mentioned BCL that is installed centrally in a known location in Windows so all all programs can use it. Any .NET application launched in Windows has certain support level depending on the version of machine that it is installed and ran on.
This edition of .NET is not cross-platform so that means that you can only run it on devices with Windows operating system. I suppose that you are familiar with technologies like Windows Presentation Foundation (WPF), Windows Forms and ASP .NET (Microsoft web platform). You can see all these are on the top of the left site of the image above.
You can also see that in short .NET Framework is only for Windows (left site).
.NET Core is something new in Microsoft technology families. In short .NET Core is cloud-optimized, cross-platform port of the .NET Framework described above (modern version of .NET Framework). The main target of .NET Core is to be accesible from three main operating systems – OS X, Linux and Windows. The most important thing is that it is freely available to download from GitHub.
Great! But what does it mean exactly?!
Let me refer to ASP .NET. Initially this Microsoft web technology was compatible only with .NET Framework and Windows. This generated a problem for developers who wanted deploy their solutions without limiting to Windows. With .NET Core and ASP.NET 5 now developers can run their applications on Linux, Windows and OS X (their solution is fully packed and isolated on the machine).
Because ASP .NET 5 will be cross-platform technology. What is more, developer has a choice. ASP. NET 5 can either use .NET Core or full .NET Framework.
Back to .NET Core – it is fully componentized framework which means that everything is available for developer as a package. There is a whole list of libraries that developer can pull as a packages and ship them as a part of the application. Of course they can be updated without worrying about centrally installed version. That makes it much easier to deploy applications to the cloud.
It also consists of libraries named CoreFX.
.NET Core runtimes
1) .NET Core runtime (CoreCLR)
This is the opposite (modern) version of .NET Framework runtime that still includes garbage collector, JIT compler and base .NET data types. The main difference is that it is cross-platform so you can use it on OS X, Linux and Windows. It uses .NET Core libraries named CoreFX.
2) .NET Native runtime
Before writing broadly about .NET Native we should estabilish some facts how .NET runtime executes code currently. After compiling the application its code is compiled to Intermediate Language (IL) – it does not matter if your code is written in C# or Visual Basic for instance. Remember that IL is not directly executed. Just-in-time (JIT) compiler compile the IL to machine code.
Now you know (or already known) how does the application is executed in .NET Framework.
In .NET Core this is a tool chain that is responsible for compiling Intermediate Language (IL) code to native code.
In short – .NET Native is runtime with Ahead of Time (AOT) compiler in contrast to .NET Framework Just in Time (JIT) compiler.
How does it work exactly?!
It means that code of your application is compiled to native code firstly and then executed (without JIT compilation).
It also uses .NET Core libraries named CoreFX.
.NET Core – what about Windows 10 Universal Applications?
.NET Natvie and Windows 10 Universal Applications
Every Windows 10 Universal Application is using .NET Core as its runtime and is comipled with .NET Native compiler.
It is assumed that Windows 10 Universal Application is app that runs on any Windows 10 device:
- Desktop device family: Laptops, tablets and phablets
- Mobile device family: Phablets and Windows Mobile
- Team device family: Surface hub
- IoT device family: Raspberry Pi 2, Intel Galileo
- Xbox device family
What is the impact on the Windows 10 Universal Application connected with using .NET Native?
- Application startup is 50% faster
- Application consumes 14% less memory
- No dependencies on the desktop .NET Runtime installed on the system
- You can still use your favourite programming language (C# or Visual Basic for instance) and tools connected with it
New compiler in the cloud – Windows 10 Universal Applications Store
When talking about new Windows Store there should be mentioned the whole process connected wtih testing and publishing your application (including compilation process).
When creating your application for sure you use Debug/Release configuration in the Visual Studio.
When you build your application and run it in “Debug” mode the IL code is executed using the CoreCLR (.NET Core) runtime. It means that your application takes dependency on Microsoft.NET.CoreRuntime (CoreCLR) package. This option creates opportunity for fast compilation and deployment and also rich debugging and diagnostics.
When you build your application and run it in “Release” mode it takes more time (about +30 seconds) to change the IL code of your application and other references into optimized native machine code. The result of this process is that at the end you receive single DLL file. This configuration uses .NET Native runtime.
Store packaging process
The first very important thing here is that you must choose CPU version with reference to running your application on different devices. AnyCPU option in Visual Studio is gone. That is because .NET Natvie compiles to native machine code.
If you want to run test your application on local machine or emulator you must select x86.
For testing application on Windows 10 Mobile device you should select ARM.
For others there is x64 option to select.
When you created the Windows 10 Universal Application project in Visual Studio you can create package with your application for different CPU architectures. Please look at the picture below:
You should also remember to check “Always” under the “Generate app bundle” option. This will result with in single .appxupload file ready to upload to the Windows Store:
When you have already tested your app and created package for upload to the Windows Store (.appxupload file) there is one more step before publishing. You must launch Windows App Certification Kit. This one will test your application and show the result:
After testing your application is ready to be upload and published.
The most important thing is what about different devices (with various CPU)?
Cloud compiler in Windows Store
New cloud compiler in the new Windows Store will use .NET Native to compile your uploaded application package (single DLL that keeps your application code as an IL code) to the native code.
If the end user decides about downloading your application, cloud comipiler will automaticly check the CPU version of and choose the proper compiled version.
As the end user there is also possibility to check the CPU version that are supported by your application in the Windows Store:
Microsoft have changed many things connected with .NET Framework. The most important is that .NET is now open source.
With reference to Windows 10 Universal Applications – there is new runtime called .NET Native that is used with appications.
What’s more Windows 10 Universal Applications are compiled to the native code in the cloud (Windows Store does it).
I hope that this article helped you understand some changes connected with new .NET ecosystem.