Deploying to Linux and macOS

Let's look at deploying apps from Visual Studio to Linux or macOS. We can also develop the application in the Linux or macOS platform using Visual Studio Code.

First, install a DNX for the framework, .NET Core or Mono. Next, copy the whole Visual Studio project, including source code and project.json and no assemblies.

Then, use the dotnet cli to restore all the NuGet packages. This will include the assemblies the DNX needs to host the CLR in .NET Core. However, NuGet packages can have dependencies on other packages, so there has to be some kind of list of all packages needed before a restore can occur. The compilation of such a list takes time because all packages have to be inspected to see what their dependencies are. The lock file contains this compiled list, so the figuring out has to be done only once. All the subsequent restores use the lock file, provided that the list of packages in project.json hasn't changed.

Finally, instruct the DNX to run the program using Kestrel as the web server. The DNX will use Kestrel as an entry point, and Kestrel will then host the app. Kestrel gives me a notification that the app is running on port 5000. Browsing to localhost as the domain name with port 5000 launches our application in Linux or macOS.

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

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