KEMBAR78
.NET Core, ASP.NET Core Course, Session 1 | PDF
.NET Core + ASP.NET Core Training Course
Session 1
.NET Core
History Of .NET
History
.NET Core
About
Why .NET Core?
.NET Core
Google Trend
Why .NET?
.NET Core
TIOBE
Index for June 2016
Why .NET?
.NET Core
w3techs.com
Why .NET?
.NET Core
About
What is the .NET Core Platform?
• .NET Core is a cross-platform implementation of .NET Framework
• Main Goal: modular, performant and cross-platform execution environment for
modern applications
• .NET Core is a subset of the .NET Framework
• It’s primarily being driven by ASP.NET Core workloads
• .NET Core consists of the CoreCLR runtime and the CoreFX framework libraries
• A set of cross-platform tooling can be found in the .NET CLI
• The Roslyn compiler and LLILC compiler are sibling projects that support .NET Core
.NET Core
.NET Core is…
What is the .NET Core Platform?
32-bit and 64-bit Windows platforms, as well as on mac OS and Linux
manages memory with a garbage collector, compiles your code with a JIT compiler or ahead of time with .NET Native.
.NET Core is a set of runtime, library and compiler components.
Generics, Language Integrated Query (LINQ), Async support, "Roslyn" Managed compiler usable as a service
Streamlined and easy interoperability with native code
.NET Core
.NET Core is…
What is the .NET Core Platform?
Runtime modularity allows for an extensibility model, and componentization strategies with package manager NuGet
client applications, across web, server workloads to mobile apps
Platforms: OS and Processor Architectures | Application Stacks: Mono
Open ECMA standard, both its runtime and its class libraries
.NET Core
Console Application:
.NET Core Application Types: Console Application
• Cross-platform: Console apps can run on Windows, OS X, and Linux.
• Native compilation: This combines the benefits of a managed app with the
performance of a native C/C++ app.
.NET Core
Features
.NET Core Features
• Ease of Installation
• Because .NET Core is not an operating system component, installation:
• Does not require administrator privileges.
• Does not touch system components like operating system directories or, on Windows
systems, the Windows Registry.
• Is as simple as copying some files to a directory on the target computer or compiling
the framework natively into the app.
.NET Core
.NET Core has two deployment models:
.NET Core Deployment models: Portable Apps
• Portable Apps
• You will deploy only your app and any of its dependencies other than the .NET Core libraries
• A portable app requires that .NET Core is installed on the target machine in order for it to run
• .NET Core is an independent component so you do not need to determine in advance which
platforms your app supports
• Portable apps are the default app type in .NET Core
.NET Core
.NET Core has two deployment models:
.NET Core Deployment models: Self-contained Apps
• Self-contained Apps
• include all of their dependencies, including the .NET Core runtime, as part of the app
• .NET Core is local to your app so it can run on any supported platform whether .NET Core is
installed on it or not
• .NET libraries that your app uses are isolated from .NET Core libraries used by other apps
• Requires that you determine the target platforms that your app supports in advance
.NET Core
.NET Core Components
.NET Core Components
• Common Language Runtime: which in .NET Core is named CoreCLR
• CoreFX: a modular collection of libraries
• allows you to include the libraries that your app needs without the overhead of including those that you don't need
.NET Core
The Common Language Runtime
.NET Core Components: CLR
CoreCLR, or the common language runtime found in .NET Core, is a lightweight runtime that offers many of the same
services as the .NET Framework's common language runtime on the Windows desktop. These include:
• Garbage Collector
• provides automatic memory management
• Allocates and frees memory as needed; you do not have to do it programmatically
• .NET Core uses the same garbage collector as the .NET Framework
• Just-in-time (JIT) compiler
• compiles IL, or .NET intermediate language, to native machine code at runtime.
• On some architectures, the JIT compiler includes support for SIMD hardware acceleration
• An exception handling mechanism
• allows you to handle exceptions with try/catch statements
.NET Core
The Class Library
.NET Core Components: The Class Library
Is very much like the .NET Framework Class Library for the Windows desktop.
With one major difference: On the Windows desktop, it is a monolithic library that is part of the operating system and is
maintained by Windows Update.
On .NET Core it is a modular and factored collection of individual libraries organized by functionality
Microsoft.NetCore.App is included with the runtime and contains the basic types needed for all app development. Some of
these include:
• Primitives, such as the Boolean type, signed and unsigned integral types, floating-point types, and the Char structure.
• The String type, UTF-16 code units. .NET Core also includes a number of encoding types that let you convert UTF-16 encoded strings
to an array of bytes in other encodings. For example, you can use the UTF8Encoding class to convert a .NET Core string to a UTF-8
encoded byte array that represents a string on Linux.
.NET Core
The Class Library
.NET Core Components: The Class Library
• General-purpose exception classes, such as the ArgumentException, ArgumentNullException, and NullReferenceException types.
• The task types, such as Task and Task<T>, to support asynchronous programming.
• Basic threading types
• The Console class, to support the development of console apps.
• Other libraries are installed as NuGet packages
.NET Core
dotnet.exe
.NET Core Tools: CLI
• dotnet --help : Displays information about .NET Core CLI commands
• dotnet new : Initializes a new C# project
• dotnet new --lang F# : Initializes a new F# project.
• dotnet restore : Restores the dependencies for an app.
• dotnet build : Builds a .NET Core app.
• dotnet publish : Publishes a .NET portable or self-contained app. (See the "Ease of Deployment" section below.
• dotnet run : Runs the app from its source code.
• dotnet pack : Creates a NuGet package of your code.
dotnet.exe also has an extensibility model that lets you add additional commands.
.NET Core
Language Support and Development Environments
.NET Core Tools: Language Support and Development Environments
• Any programming language that targets .NET Core can be used to develop .NET Core app
• An app that targets .NET Core and is written in one programming language can seamlessly access types
and members in .NET Core libraries that were developed by using a different programming language
• You can currently develop .NET Core apps in either of two languages:
• C#, which is based on the .NET Compiler Platform, also known as Roslyn.
• F#.
• Additional languages are planned for the future
• Development Environments: Notepad, Visual Studio Code, Visual Studio 2015 Update 2 (and higher)
.NET Core
.NET Core vs .NET Framework 4.x
.NET Core vs .NET Framework 4.x
.NET Core
Includes CoreCLR, a more lightweight runtime that provides basic
services: automatic memory management and garbage collection,
along with a basic type library.
Includes CoreFx, a set of individual modular assemblies that you can
add to your app as needed. Unlike the .NET Framework 4.x you can
select only the assemblies that you need, suitable for a full range of
modern apps, including apps that operate on small devices with
constrained memory and storage.
Can be used to develop apps that take advantage of a number of
technologies, such as ASP .NET Core, WCF, WF
Can be app local. That is, the .NET Core implementation that your app
relies is tightly bound to your app. This mitigates versioning problems.
vs
.NET Framework 4.x
Includes CLR, a sizeable runtime that provides memory management,
isolation by application domain, and a host of other application
services.
Includes the .NET Framework Class Library, a large, monolithic library
with thousands of classes and many thousands of members. they are
always present and accessible.
Is suitable for developing traditional Windows desktop apps, including
Windows Forms (WinForms) and Windows Presentation Foundation
(WPF) apps.
ASP.NET and ASP.NET Web Forms, Windows Communication
Foundation (WCF), Workflow Foundation (WF
Is globally available on a given system. An app can include a chain
installer that installs a particular version of the .NET, this can create
versioning problems. Starting with Windows 8, a version of the .NET
Framework is installed as an operating system component and is serviced by
Windows Update.
.NET Core
.NET Standard
.NET Standard
.NET Framework 4.6.2 Preview and .NET Core both conform to the .NET Standard 1.5. They target different
platforms and represent different approaches to app development and deployment
• Experienced .NET Framework developers can easily adapt to developing with .NET Core when whey want
to target different platforms and devices.
• .NET Core developers can easily transition to developing apps with the .NET Framework that target
Windows desktop, tablet, and phone.
• Libraries written for the .NET Framework or .NET Core can easily be made to work on the other platform.
.NET Core
.NET Core implementations
.NET Core implementations
• ASP.NET Core
• . ASP.NET Core is a modular version of ASP.NET that combines ASP.NET MVC and the ASP.NET Web API.
• It runs on both the .NET Framework and .NET Core and is designed for building high-performance cloud and microservice apps
• It is not intended as a replacement to ASP.NET in the .NET Framework.
• .NET Native.
• .NET Native is a compilation and deployment technology for Universal Windows Platform (UWP) apps written in C# and Visual Basic.
• .NET Native compiles apps to native code, and statically links into an application's assemblies only those code elements from
.NET Core libraries and other third-party libraries that are actually used.
.NET Core
.NET Core implementations
.NET Core implementations
• Universal Windows Platform (UWP) apps.
• The UWP allows you to build a single app that can run on the Windows desktop, Windows tablet devices, and Windows Phone.
• These apps can also be placed in the Windows Store.
• UWP apps are compiled to native code for their target platforms by .NET Native.
.NET Core
.NET Core System Requirements
Installing .NET Core: System Requirements
• Windows client supported in both 32-bit and 64-bit editions
• Windows 7 SP1, Windows 8.1, Windows 10
• Windows Server 2008 R2 SP1, 2012 SP1, 2012 R2 SP1 (Full Server or Server Core)
• Windows Server 2016 (Full Server, Server Core or Nano Server)
• Linux
• CentOS 7.1, Debian 8.2, Red Hat Enterprise Linux 7.2, Ubuntu 14.04 LTS
• OS X
• OS X 10.11 (El Capitan) and above
.NET Core
.NET Core Software Development Kit (SDK) Overview
Installing .NET Core: .NET Core Software Development Kit (SDK) Overview
.NET Core Software Development Kit is a set of libraries and tools that allow developers to create .NET Core
applications and libraries. It contains the following components:
• The .NET Core Command Line Tools that are used to build applications
• .NET Core (libraries and runtime) that allow applications to both be built and run
• The dotnet driver for running the CLI commands as well as running applications
.NET Core
Acquiring the .NET Core SDK
Installing .NET Core: .NET Core Software Development Kit (SDK) Overview
• The native installers are primarily meant for developer's machines. DEB packages on Ubuntu or MSI bundles on
Windows. These installers will install and set up the environment as needed for the user to use the SDK
immediately after the install and they require administrative privileges on the machine.
• Install scripts, do not require administrative privileges. They will also not install any prerequisites on the machine;
you need to install all of the pre-requisites manually. The scripts are meant mostly for setting up build servers or
when you wish to install the tools without admin privileges.
By default, the SDK will install in a "side-by-side" (SxS) manner means that multiple versions of the CLI tools can coexist
at any given time on a single machine.
.NET Core
https://www.microsoft.com/net/download#core
Installing .NET Core
.NET Core
Step by Step Hello World with .NET Core
.NET Core: Hello World 
$ dotnet new
dotnet new creates an up-to-date project.json file with NuGet dependencies necessary to build a console app. It also creates a Program.cs, a
basic file containing the entry point for the application.
.NET Core
project.json
.NET Core: Hello World 
.NET Core
$ dotnet restore
.NET Core: Hello World 
dotnet restore calls into NuGet to restore the tree of dependencies.
NuGet analyzes the project.json file, downloads the dependencies stated in the file (or grabs them
from a cache on your machine), and writes the project.lock.json file.
The project.lock.json file is necessary to be able to compile and run.
The project.lock.json file is a persisted and complete set of the graph of NuGet dependencies and
other information describing an app. This file is read by other tools, such as dotnet build and dotnet
run, enabling them to process the source code with a correct set of NuGet dependencies and binding
resolutions.
.NET Core
$ dotnet run
.NET Core: Hello World 
dotnet run calls dotnet build to ensure that the build targets have been built, and then calls dotnet <assembly.dll>
to run the target application.
You can also execute dotnet build to compile and the code without running the build console applications.
.NET Core
Building a self-contained application
.NET Core: Hello World 
Change the project.json file to direct the tools to build a self-contained application.
The first change is to remove the "type": "platform" element from all dependencies. This project's only dependency so far
is "Microsoft.NETCore.App". The dependencies section should look like this:
.NET Core
Building a self-contained application
.NET Core: Hello World 
Change the project.json file to direct the tools to build a self-contained application.
The first change is to remove the "type": "platform" element from all dependencies. This project's only dependency so far is
"Microsoft.NETCore.App". The dependencies section should look like this:
Next, you need to add a runtimes node to specify all the target execution environments. The build system will generate native executables
for the current environment. After making those two changes, execute dotnet restore, followed by dotnet build to create the native executable.
RID Catalog
.NET Core
Building a self-contained application
.NET Core: Hello World 
Notice that the native application takes slightly longer to build, but executes slightly faster. This behavior becomes more
noticeable as the application grows.
The build process generates several more files when your project.json creates a native build. These files are
created in binDebugnetcoreapp1.0<platform> where <platform> is the RID chosen.
In addition to the project's HelloNative.dll there is a HelloNative.exe that loads the runtime and starts the
application
.NET Core
Executing on a machine that does not include the .NET runtime
.NET Core: Hello World 
Use the dotnet publish command to create a new subdirectory under the ./bin/Debug/netcoreapp1.0/<platform>
directory called publish. It copies the executable, all dependent DLLs and the framework to this sub directory
package that directory to another machine (or a container) and execute the application there.
That application is a portable application which is the default type of application for .NET Core and requires that .NET Core
is installed on the target machine. Portable applications can be built on one machine and executed anywhere.
Native applications must be built separately for each target machine. dotnet publish creates a directory that has the
application's DLL, and any dependent dlls that are not part of the platform installation.
.NET Core
Samples
.NET Core: Hello World 
1. Hello
2. HelloNative
3. Fibonacci
4. FibonacciBetter
5. NewTypes

.NET Core, ASP.NET Core Course, Session 1

  • 1.
    .NET Core +ASP.NET Core Training Course Session 1
  • 2.
  • 3.
  • 4.
  • 5.
    .NET Core TIOBE Index forJune 2016 Why .NET?
  • 6.
  • 7.
    .NET Core About What isthe .NET Core Platform? • .NET Core is a cross-platform implementation of .NET Framework • Main Goal: modular, performant and cross-platform execution environment for modern applications • .NET Core is a subset of the .NET Framework • It’s primarily being driven by ASP.NET Core workloads • .NET Core consists of the CoreCLR runtime and the CoreFX framework libraries • A set of cross-platform tooling can be found in the .NET CLI • The Roslyn compiler and LLILC compiler are sibling projects that support .NET Core
  • 8.
    .NET Core .NET Coreis… What is the .NET Core Platform? 32-bit and 64-bit Windows platforms, as well as on mac OS and Linux manages memory with a garbage collector, compiles your code with a JIT compiler or ahead of time with .NET Native. .NET Core is a set of runtime, library and compiler components. Generics, Language Integrated Query (LINQ), Async support, "Roslyn" Managed compiler usable as a service Streamlined and easy interoperability with native code
  • 9.
    .NET Core .NET Coreis… What is the .NET Core Platform? Runtime modularity allows for an extensibility model, and componentization strategies with package manager NuGet client applications, across web, server workloads to mobile apps Platforms: OS and Processor Architectures | Application Stacks: Mono Open ECMA standard, both its runtime and its class libraries
  • 10.
    .NET Core Console Application: .NETCore Application Types: Console Application • Cross-platform: Console apps can run on Windows, OS X, and Linux. • Native compilation: This combines the benefits of a managed app with the performance of a native C/C++ app.
  • 11.
    .NET Core Features .NET CoreFeatures • Ease of Installation • Because .NET Core is not an operating system component, installation: • Does not require administrator privileges. • Does not touch system components like operating system directories or, on Windows systems, the Windows Registry. • Is as simple as copying some files to a directory on the target computer or compiling the framework natively into the app.
  • 12.
    .NET Core .NET Corehas two deployment models: .NET Core Deployment models: Portable Apps • Portable Apps • You will deploy only your app and any of its dependencies other than the .NET Core libraries • A portable app requires that .NET Core is installed on the target machine in order for it to run • .NET Core is an independent component so you do not need to determine in advance which platforms your app supports • Portable apps are the default app type in .NET Core
  • 13.
    .NET Core .NET Corehas two deployment models: .NET Core Deployment models: Self-contained Apps • Self-contained Apps • include all of their dependencies, including the .NET Core runtime, as part of the app • .NET Core is local to your app so it can run on any supported platform whether .NET Core is installed on it or not • .NET libraries that your app uses are isolated from .NET Core libraries used by other apps • Requires that you determine the target platforms that your app supports in advance
  • 14.
    .NET Core .NET CoreComponents .NET Core Components • Common Language Runtime: which in .NET Core is named CoreCLR • CoreFX: a modular collection of libraries • allows you to include the libraries that your app needs without the overhead of including those that you don't need
  • 15.
    .NET Core The CommonLanguage Runtime .NET Core Components: CLR CoreCLR, or the common language runtime found in .NET Core, is a lightweight runtime that offers many of the same services as the .NET Framework's common language runtime on the Windows desktop. These include: • Garbage Collector • provides automatic memory management • Allocates and frees memory as needed; you do not have to do it programmatically • .NET Core uses the same garbage collector as the .NET Framework • Just-in-time (JIT) compiler • compiles IL, or .NET intermediate language, to native machine code at runtime. • On some architectures, the JIT compiler includes support for SIMD hardware acceleration • An exception handling mechanism • allows you to handle exceptions with try/catch statements
  • 16.
    .NET Core The ClassLibrary .NET Core Components: The Class Library Is very much like the .NET Framework Class Library for the Windows desktop. With one major difference: On the Windows desktop, it is a monolithic library that is part of the operating system and is maintained by Windows Update. On .NET Core it is a modular and factored collection of individual libraries organized by functionality Microsoft.NetCore.App is included with the runtime and contains the basic types needed for all app development. Some of these include: • Primitives, such as the Boolean type, signed and unsigned integral types, floating-point types, and the Char structure. • The String type, UTF-16 code units. .NET Core also includes a number of encoding types that let you convert UTF-16 encoded strings to an array of bytes in other encodings. For example, you can use the UTF8Encoding class to convert a .NET Core string to a UTF-8 encoded byte array that represents a string on Linux.
  • 17.
    .NET Core The ClassLibrary .NET Core Components: The Class Library • General-purpose exception classes, such as the ArgumentException, ArgumentNullException, and NullReferenceException types. • The task types, such as Task and Task<T>, to support asynchronous programming. • Basic threading types • The Console class, to support the development of console apps. • Other libraries are installed as NuGet packages
  • 18.
    .NET Core dotnet.exe .NET CoreTools: CLI • dotnet --help : Displays information about .NET Core CLI commands • dotnet new : Initializes a new C# project • dotnet new --lang F# : Initializes a new F# project. • dotnet restore : Restores the dependencies for an app. • dotnet build : Builds a .NET Core app. • dotnet publish : Publishes a .NET portable or self-contained app. (See the "Ease of Deployment" section below. • dotnet run : Runs the app from its source code. • dotnet pack : Creates a NuGet package of your code. dotnet.exe also has an extensibility model that lets you add additional commands.
  • 19.
    .NET Core Language Supportand Development Environments .NET Core Tools: Language Support and Development Environments • Any programming language that targets .NET Core can be used to develop .NET Core app • An app that targets .NET Core and is written in one programming language can seamlessly access types and members in .NET Core libraries that were developed by using a different programming language • You can currently develop .NET Core apps in either of two languages: • C#, which is based on the .NET Compiler Platform, also known as Roslyn. • F#. • Additional languages are planned for the future • Development Environments: Notepad, Visual Studio Code, Visual Studio 2015 Update 2 (and higher)
  • 20.
    .NET Core .NET Corevs .NET Framework 4.x .NET Core vs .NET Framework 4.x .NET Core Includes CoreCLR, a more lightweight runtime that provides basic services: automatic memory management and garbage collection, along with a basic type library. Includes CoreFx, a set of individual modular assemblies that you can add to your app as needed. Unlike the .NET Framework 4.x you can select only the assemblies that you need, suitable for a full range of modern apps, including apps that operate on small devices with constrained memory and storage. Can be used to develop apps that take advantage of a number of technologies, such as ASP .NET Core, WCF, WF Can be app local. That is, the .NET Core implementation that your app relies is tightly bound to your app. This mitigates versioning problems. vs .NET Framework 4.x Includes CLR, a sizeable runtime that provides memory management, isolation by application domain, and a host of other application services. Includes the .NET Framework Class Library, a large, monolithic library with thousands of classes and many thousands of members. they are always present and accessible. Is suitable for developing traditional Windows desktop apps, including Windows Forms (WinForms) and Windows Presentation Foundation (WPF) apps. ASP.NET and ASP.NET Web Forms, Windows Communication Foundation (WCF), Workflow Foundation (WF Is globally available on a given system. An app can include a chain installer that installs a particular version of the .NET, this can create versioning problems. Starting with Windows 8, a version of the .NET Framework is installed as an operating system component and is serviced by Windows Update.
  • 21.
    .NET Core .NET Standard .NETStandard .NET Framework 4.6.2 Preview and .NET Core both conform to the .NET Standard 1.5. They target different platforms and represent different approaches to app development and deployment • Experienced .NET Framework developers can easily adapt to developing with .NET Core when whey want to target different platforms and devices. • .NET Core developers can easily transition to developing apps with the .NET Framework that target Windows desktop, tablet, and phone. • Libraries written for the .NET Framework or .NET Core can easily be made to work on the other platform.
  • 22.
    .NET Core .NET Coreimplementations .NET Core implementations • ASP.NET Core • . ASP.NET Core is a modular version of ASP.NET that combines ASP.NET MVC and the ASP.NET Web API. • It runs on both the .NET Framework and .NET Core and is designed for building high-performance cloud and microservice apps • It is not intended as a replacement to ASP.NET in the .NET Framework. • .NET Native. • .NET Native is a compilation and deployment technology for Universal Windows Platform (UWP) apps written in C# and Visual Basic. • .NET Native compiles apps to native code, and statically links into an application's assemblies only those code elements from .NET Core libraries and other third-party libraries that are actually used.
  • 23.
    .NET Core .NET Coreimplementations .NET Core implementations • Universal Windows Platform (UWP) apps. • The UWP allows you to build a single app that can run on the Windows desktop, Windows tablet devices, and Windows Phone. • These apps can also be placed in the Windows Store. • UWP apps are compiled to native code for their target platforms by .NET Native.
  • 24.
    .NET Core .NET CoreSystem Requirements Installing .NET Core: System Requirements • Windows client supported in both 32-bit and 64-bit editions • Windows 7 SP1, Windows 8.1, Windows 10 • Windows Server 2008 R2 SP1, 2012 SP1, 2012 R2 SP1 (Full Server or Server Core) • Windows Server 2016 (Full Server, Server Core or Nano Server) • Linux • CentOS 7.1, Debian 8.2, Red Hat Enterprise Linux 7.2, Ubuntu 14.04 LTS • OS X • OS X 10.11 (El Capitan) and above
  • 25.
    .NET Core .NET CoreSoftware Development Kit (SDK) Overview Installing .NET Core: .NET Core Software Development Kit (SDK) Overview .NET Core Software Development Kit is a set of libraries and tools that allow developers to create .NET Core applications and libraries. It contains the following components: • The .NET Core Command Line Tools that are used to build applications • .NET Core (libraries and runtime) that allow applications to both be built and run • The dotnet driver for running the CLI commands as well as running applications
  • 26.
    .NET Core Acquiring the.NET Core SDK Installing .NET Core: .NET Core Software Development Kit (SDK) Overview • The native installers are primarily meant for developer's machines. DEB packages on Ubuntu or MSI bundles on Windows. These installers will install and set up the environment as needed for the user to use the SDK immediately after the install and they require administrative privileges on the machine. • Install scripts, do not require administrative privileges. They will also not install any prerequisites on the machine; you need to install all of the pre-requisites manually. The scripts are meant mostly for setting up build servers or when you wish to install the tools without admin privileges. By default, the SDK will install in a "side-by-side" (SxS) manner means that multiple versions of the CLI tools can coexist at any given time on a single machine.
  • 27.
  • 28.
    .NET Core Step byStep Hello World with .NET Core .NET Core: Hello World  $ dotnet new dotnet new creates an up-to-date project.json file with NuGet dependencies necessary to build a console app. It also creates a Program.cs, a basic file containing the entry point for the application.
  • 29.
  • 30.
    .NET Core $ dotnetrestore .NET Core: Hello World  dotnet restore calls into NuGet to restore the tree of dependencies. NuGet analyzes the project.json file, downloads the dependencies stated in the file (or grabs them from a cache on your machine), and writes the project.lock.json file. The project.lock.json file is necessary to be able to compile and run. The project.lock.json file is a persisted and complete set of the graph of NuGet dependencies and other information describing an app. This file is read by other tools, such as dotnet build and dotnet run, enabling them to process the source code with a correct set of NuGet dependencies and binding resolutions.
  • 31.
    .NET Core $ dotnetrun .NET Core: Hello World  dotnet run calls dotnet build to ensure that the build targets have been built, and then calls dotnet <assembly.dll> to run the target application. You can also execute dotnet build to compile and the code without running the build console applications.
  • 32.
    .NET Core Building aself-contained application .NET Core: Hello World  Change the project.json file to direct the tools to build a self-contained application. The first change is to remove the "type": "platform" element from all dependencies. This project's only dependency so far is "Microsoft.NETCore.App". The dependencies section should look like this:
  • 33.
    .NET Core Building aself-contained application .NET Core: Hello World  Change the project.json file to direct the tools to build a self-contained application. The first change is to remove the "type": "platform" element from all dependencies. This project's only dependency so far is "Microsoft.NETCore.App". The dependencies section should look like this: Next, you need to add a runtimes node to specify all the target execution environments. The build system will generate native executables for the current environment. After making those two changes, execute dotnet restore, followed by dotnet build to create the native executable. RID Catalog
  • 34.
    .NET Core Building aself-contained application .NET Core: Hello World  Notice that the native application takes slightly longer to build, but executes slightly faster. This behavior becomes more noticeable as the application grows. The build process generates several more files when your project.json creates a native build. These files are created in binDebugnetcoreapp1.0<platform> where <platform> is the RID chosen. In addition to the project's HelloNative.dll there is a HelloNative.exe that loads the runtime and starts the application
  • 35.
    .NET Core Executing ona machine that does not include the .NET runtime .NET Core: Hello World  Use the dotnet publish command to create a new subdirectory under the ./bin/Debug/netcoreapp1.0/<platform> directory called publish. It copies the executable, all dependent DLLs and the framework to this sub directory package that directory to another machine (or a container) and execute the application there. That application is a portable application which is the default type of application for .NET Core and requires that .NET Core is installed on the target machine. Portable applications can be built on one machine and executed anywhere. Native applications must be built separately for each target machine. dotnet publish creates a directory that has the application's DLL, and any dependent dlls that are not part of the platform installation.
  • 36.
    .NET Core Samples .NET Core:Hello World  1. Hello 2. HelloNative 3. Fibonacci 4. FibonacciBetter 5. NewTypes