Publishing with dotnet command-line interface

Let's see how we can publish using dotnet command-line interface. From Visual Studio, open up a command shell directly in the project folder of our application. If we look at the DOTNET command, we can see that it has a number of commands where you can build your projects and install dependencies, especially NuGet-based dependencies. You can handle packages and publish the application. The following is the command that shows the Windows result that shows various options and arguments in the command:

C:RajeshPacktAngular2>dotnet
.NET Command Line Interface
Usage: dotnet [common-options] [command] [arguments]

  • Arguments:
    [command]: The command to execute
    [arguments]: Arguments to pass to the command
  • Common Options: (passed before the command):
    -v|--verbose Enable verbose output
  • Common Commands:
    new: Initialize a basic .NET project
    restore: Restore dependencies specified in the .NET project
    compile: Compiles a .NET project
    publish: Publishes a .NET project for deployment (including the runtime)run: Compiles and immediately executes a .NET project
    repl: Launch an interactive session (read, eval, print, loop)
    pack: Creates a NuGet package

The dotnet command-line interface is useful in that you can actually script all these processes, you can have it install the dependencies, run the build, and then publish it. So, it provides an easy way to automate a lot of these tasks. In fact, Visual Studio is just automating this using the Dotnet tool.

The published folder contains the code of the application, all the dependencies, both the client dependencies, the tooling dependencies, and the NuGet dependencies, and contains the entire version of the runtime that's required. We can take this folder and put on any box and run. If you want to package this up for Linux or OS 10, you'll need a version of the runtime that is appropriate for those platforms, like CoreCLR would be. This folder has the self-contained application and can run on any browser. This doesn't use any framework that's installed on the machine; it's all within that one folder, completely portable.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset