{"id":2068,"date":"2015-07-30T00:00:00","date_gmt":"2015-07-30T00:00:00","guid":{"rendered":"https:\/\/test.simple-talk.com\/uncategorized\/what-is-dnx\/"},"modified":"2021-05-17T18:35:57","modified_gmt":"2021-05-17T18:35:57","slug":"what-is-dnx","status":"publish","type":"post","link":"https:\/\/www.red-gate.com\/simple-talk\/development\/dotnet-development\/what-is-dnx\/","title":{"rendered":"What is DNX?"},"content":{"rendered":"<div class=\"article-content\">\n<p class=\"start\"> \tMicrosoft have been doing a great deal of innovation in the .NET space over the last year, and vast quantities of this source code has now been provided open-source on GitHub. .NET is finally starting to become portable onto other platforms such as Linux and  \tOSX using just Microsoft-supported technology. Not so long ago, you could only run on Linux by using a technology such as Mono, but now a cut-down, open-sourced version of the .NET runtime, the CoreClr, is starting to become fully functional on both Linux and  \tOSX. <\/p>\n<p> \tDNX, a Dot Net eXecution environment, contains all of the code that is required to bootstrap and run an application. It includes the compilation system, SDK tools and the native CLR host, with NuGet packages being used to access assemblies that are referenced by the application. This system gives us the ability, for the first time ever, to deploy applications merely by copying them. Each application can reside in its own directory which will contain the NuGet packages for all of its dependencies. <\/p>\n<p> \tWhen you install VS 2015, you get a version of DNX installed onto your machine. If you start a command prompt and run DNVM, the DNX version manager, you can see the variants of the CLR that are initially installed. <\/p>\n<p> \t<img decoding=\"async\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/2261-1-7618279f-5609-4513-a5d4-8b16ce6fc1bd.png\" alt=\"2261-1-7618279f-5609-4513-a5d4-8b16ce6fc\" \/><\/p>\n<p> \tUsing a simple cs code file which writes a message, and a simple project file to list the dependencies: <\/p>\n<p> \t<img decoding=\"async\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/2261-1-99802370-36d3-4246-aba3-24cf57455ba7.png\" alt=\"2261-1-99802370-36d3-4246-aba3-24cf57455\" \/><\/p>\n<p> \tI can choose a version of the CLR, and then run that version of the CoreClr. <\/p>\n<p> \t<img decoding=\"async\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/2261-1-de1f9005-72bc-493b-bb9c-75ebec4843e8.png\" alt=\"2261-1-de1f9005-72bc-493b-bb9c-75ebec484\" \/><\/p>\n<p> \tThe restore command shown above downloaded the packages that the application needs, and you might wonder where the packages are stored. By default they go into a .dnx\\packages folder under your user &#8211; so for me they were at C:\\Users\\clive.tong\\.dnx\\packages. <\/p>\n<p> \tIf I go to that location and clean things out then, when I run my application, I get notified of the missing packages. <\/p>\n<p> \t<img decoding=\"async\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/2261-1-1425ca0c-2016-439c-9dab-9e26046d8205.png\" alt=\"2261-1-1425ca0c-2016-439c-9dab-9e26046d8\" \/><\/p>\n<p> \tRunning the restore command fetches them, and my application starts working again. <\/p>\n<p> \t<img decoding=\"async\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/2261-1-c5f603a3-d119-4e0b-a596-a9ea5cf9b37e.png\" alt=\"2261-1-c5f603a3-d119-4e0b-a596-a9ea5cf9b\" \/><\/p>\n<p> \tInside VS2015, there is a way to produce a packaged console application just like the example above called &#8216;<em>Console Application (Package<\/em>)&#8217;. <\/p>\n<p> \t<img decoding=\"async\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/2261-1-c46019ef-c881-4736-a730-dd7e4efddb04.png\" alt=\"2261-1-c46019ef-c881-4736-a730-dd7e4efdd\" \/><\/p>\n<p> \tHowever, the main focus is on ASP.NET web applications that sit on top of this new framework. A choice of ASP.NET Web Application leads me to a number of ASP.NET 5 preview templates: <\/p>\n<p> \t<img decoding=\"async\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/2261-1-57e6c0ac-b505-4c27-add0-a85228c8313f.png\" alt=\"2261-1-57e6c0ac-b505-4c27-add0-a85228c83\" \/><\/p>\n<p> \tPicking, for example, Web Application, produces a demo web site that sits on top of the DNX framework. <\/p>\n<p> \tNotice that the project file is in the DNX-friendly JSON format. <\/p>\n<p> \t<img decoding=\"async\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/2261-56781840-381e-407c-9840-dfdde60f2ad8.png\" alt=\"2261-56781840-381e-407c-9840-dfdde60f2ad\" \/><\/p>\n<p> \tThe framework choice is now slightly hidden on the project properties page. However, if I go to the properties page for the WebApplication1 project note (highlighted above), on the properties tab I can control the DNX version for the solution. <\/p>\n<p> \t<img decoding=\"async\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/2261-462e531c-78e2-4d94-8496-ecfdbf11aad9.png\" alt=\"2261-462e531c-78e2-4d94-8496-ecfdbf11aad\" \/><\/p>\n<p> \tIf you have difficulty trusting tooling like me, then you can try changing this setting to pick the core clr instead. <\/p>\n<p> \t<img decoding=\"async\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/2261-8cea65ef-ea3d-4523-9827-2bd9fb2cde78.png\" alt=\"2261-8cea65ef-ea3d-4523-9827-2bd9fb2cde7\" \/><\/p>\n<p> \tThen start the solution running and use the Debug\/Modules window to see which version of the CLR is loaded. <\/p>\n<p> \t<img decoding=\"async\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/2261-735f163f-9593-42fe-9c1d-983960231096.png\" alt=\"2261-735f163f-9593-42fe-9c1d-98396023109\" \/><\/p>\n<p> \tI should also point out that you can choose if the application is hosted inside IIS Express, which it is by default. <\/p>\n<p> \t<img decoding=\"async\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/2261-c9ceb88f-d201-41a3-9cee-9568924f837b.png\" alt=\"2261-c9ceb88f-d201-41a3-9cee-9568924f837\" \/><\/p>\n<p> \tChoosing web runs the application inside a standalone web server. <\/p>\n<p> \t<img decoding=\"async\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/2261-1-3705bd49-d1e2-4716-b77e-2c4cdde28fb7.png\" alt=\"2261-1-3705bd49-d1e2-4716-b77e-2c4cdde28\" \/><\/p>\n<p> \tWhich is in turn achieved by a set of commands embedded inside the project json file. <\/p>\n<p> \t<img decoding=\"async\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/2261-9b341117-e190-4b95-8331-cdff04373780.png\" alt=\"2261-9b341117-e190-4b95-8331-cdff0437378\" \/><\/p>\n<p> \tHaving done that, and having got a functioning site running, you might be wondering how you can then profile the results. This is how I became interested in DNX. I have to confess that I don&#8217;t lie awake at night dreaming about hosting ASP.NET sites on Linux boxes. However, I<em> do<\/em> admit to being rather engrossed in trying to make sure that ANTS Profilers keep pace with all the new things that Microsoft&#8217;s .NET team introduce, such as DNX and Async. I&#8217;m not actually admitting that ANTS profiler is my baby, but I&#8217;m currently one of those holding the baby and helping it grow. It is my job to make sure that you can look at performance and memory issues easily when you are developing DNX applications. <\/p>\n<p> \t<img decoding=\"async\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/2261-1-113ac130-6b80-456c-bb28-ee826be6e793.png\" alt=\"2261-1-113ac130-6b80-456c-bb28-ee826be6e\" \/><\/p>\n<p> \tTo make it possible to look at performance for these applications, we have added a new project type within both the ANTS Performance and Memory Profilers. This manifests itself in a really simple way &#8211; there is a new tab named ASP.NET 5 that allows you to point ANTS at the relevant project.json file. You can then choose the framework to use for running the application. <\/p>\n<p> \t&#8220;Start Profiling&#8221; will then launch the application. If you have chosen &#8220;Launch using IIS Express&#8221; under the start options then it will be hosted inside iisexpress, or otherwise as a standalone web application which will be executed using the web command inside the project file. <\/p>\n<p> \t<img decoding=\"async\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/2261-6f42b06d-d9a5-4685-8da1-cd2cb2ff7414.png\" alt=\"2261-6f42b06d-d9a5-4685-8da1-cd2cb2ff741\" \/><\/p>\n<p> \tWith this new type of project, the profiling experience should be much the same as normal. The new web projects are using Roslyn to do the compilation, which means that the system no longer compiles assemblies to temporary directories, but uses the Roslyn framework to generate in-memory assemblies. When the source code is edited, the system can seamlessly recompile the changed application making the development experience a lot richer. <\/p>\n<p> \tWhen you look at profiled output, you&#8217;ll instantly notice loads of async methods in the new framework, so the Performance Profiler&#8217;s async view gets a great workout. <\/p>\n<p> \t<img decoding=\"async\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/2261-a08e60d1-eed8-4441-980f-b3a52b154c29.jpeg\" alt=\"2261-a08e60d1-eed8-4441-980f-b3a52b154c2\" \/><\/p>\n<p> \tNaturally, you can still examine all the SQL Calls that the application makes, and see how long they take, but you&#8217;ll be pleased to know that the Query Plan can be also displayed graphically to let you know not only which SQL Queries are slowing things down but why they are slowing things down. <\/p>\n<p> \tYou might imagine that the task of keeping Ants Performance and Memory Profiler up-to-date involves having plenty of time to stare out of the window and chat to colleagues at the water cooler. In fact, .NET is a moving target. There are always new features being introduced, and we have to be sure of being able to profile them. Our customers expect us to be able to profile anything in .NET and when Microsoft announce a whole raft of new features we sigh and reckon we have a busy time ahead to keep up! However, DNX is something rather special and we found being able to write applications that didn&#8217;t require an installer to be a giant step forward. We hope that many of you will find ANTS profilers useful for profiling these DNX applications. We&#8217;ve been able to deliver this functionality simultaneously in both APP and AMP thanks to work done earlier in the year to improve the way we share code between the two profilers &#8211; and hopefully in future we&#8217;ll be able to continue to deliver functionality to both profilers at the same time. <\/p>\n<p> \tThere are also a number of minor features in APP, including async support in .NET 4.6, an average time column in the methods view, support for the pure-managed Oracle driver and some improvements to the query plan UI. And, as ever, there&#8217;s a large number of bug fixes and general improvements. We feel quite smug about it all, but if you&#8217;re a bit hesitant, no worries because you can try both <a href=\"http:\/\/www.red-gate.com\/products\/dotnet-development\/ants-performance-profiler\/?utm_source=simpletalk&amp;utm_medium=publink&amp;utm_campaign=antsperformanceprofiler&amp;utm_content=whatisdnx\">ANTS Performance Profiler<\/a> and <a href=\"http:\/\/www.red-gate.com\/products\/dotnet-development\/ants-memory-profiler\/?utm_source=simpletalk&amp;utm_medium=publink&amp;utm_campaign=antsmemoryprofiler&amp;utm_content=whatisdnx\">ANTS Memory Profiler<\/a> for 14 days free. <\/p>\n<\/p><\/div>\n","protected":false},"excerpt":{"rendered":"<p>In the past, working in .NET for non-Windows platforms has been dependent on third-party frameworks like Mono. Now, with VS2015 and DNX Microsoft have stepped up to provide everything you need to code multi-platform apps straight out of the box. Clive Tong introduces this new .NET technology.&hellip;<\/p>\n","protected":false},"author":40093,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[143538],"tags":[4143,4229,6084,6085,4878,6086],"coauthors":[],"class_list":["post-2068","post","type-post","status-publish","format-standard","hentry","category-dotnet-development","tag-net","tag-net-framework","tag-dnx","tag-ios","tag-linux","tag-mono"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/2068","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/users\/40093"}],"replies":[{"embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/comments?post=2068"}],"version-history":[{"count":3,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/2068\/revisions"}],"predecessor-version":[{"id":91085,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/2068\/revisions\/91085"}],"wp:attachment":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/media?parent=2068"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/categories?post=2068"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/tags?post=2068"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/coauthors?post=2068"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}