Running ASP.NET Core applications on Windows Subsystem for Linux

Setting up Linux on Windows 10

First thing is to enable Windows Subsystem for Linux. It doesn’t install Linux but gets Windows ready for it. Linux support is Windows feature and it must be activated from Windows Features dialog.

After installing the feature Windows needs restart.

As Windows is ready to host Linux now it’s time to install one. Windows 10 Fall Creators Update supports more than one Linux. I opened Store app and installer Ubuntu Linux from there.

It takes time to get things up and running as after installation there are some configuring needed. User is asked for username and password and everything else is done by Linux from this point. Just wait until it gets done.

Running Linux on Windows

After installing Linux it is possible to use Windows 10 search to run it.

Those who need to run it frequently can also pin Ubuntu to taskbar or start menu.

Installing .NET Core

As I installed Ubuntu Linux then .NET Core installation commands here are for Ubuntu 16 that came from Windows Store.

curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg
sudo mv microsoft.gpg /etc/apt/trusted.gpg.d/microsoft.gpg
sudo sh -c ‘echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-xenial-prod xenial main" > /etc/apt/sources.list.d/dotnetdev.list‘
sudo apt-get update
sudo apt-get install dotnet-sdk-2.0.2

It takes some minutes to get .NET Core installed as after installation it also initializes things.

Running application from local disk

Linux on Windows uses its own file system and disks on machine are visible through mounting. The following screenshot shows how I moved to project folder on test machine and ran ASP.NET Core application. It’s the same folder where I build application on Visual Studio.

And here is the web front-end of my TemperatureStation solution served by Linux on Windows.

NB! I have experienced some issues this far. Sometimes after running ASP.NET Core web application on Ubuntu it’s not possible to close terminal. When closing it from Task Manager then on next run terminal window opens but nothing happens there. In case of any issues please report problems to Windows team using Feedback app.

Wrapping up

Windows subsystem for Linux is easy to enable and install. It makes Linux available on Windows without hardware level virtualization and there’s no need to install Hyper-V or some other virtualization platform. When building multi-platform apps it is handy to have Linux environment available to test and try application quickly. Although I faced few issues when working with .NET Core on Linux this way these issues were not show stoppers and I got my tasks done. Those who build multi-platform apps should give a Linux on Windows a good try.

时间: 2024-11-12 11:48:49

Running ASP.NET Core applications on Windows Subsystem for Linux的相关文章

[转]Publishing and Running ASP.NET Core Applications with IIS

本文转自:https://weblog.west-wind.com/posts/2016/Jun/06/Publishing-and-Running-ASPNET-Core-Applications-with-IIS#DoyouneedIIS? When you build ASP.NET Core applications and you plan on running your applications on IIS you'll find that the way that Core ap

Windows Subsystem for Linux 环境变量

WSL(Windows Subsystem for Linux )的环境变量是包含Linux子系统和Windows系统的,测试如下: [email protected]:/mnt/c/Windows/System32$ python -V Python 2.7.12 [email protected]-PC:/mnt/c/Windows/System32$ python.exe -V Python 2.7.14 [email protected]-PC:/mnt/c/Windows/System

Summary of Windows SubSystem for Linux

Summary of Windows SubSystem for Linux Install Ubuntu Run PowerShell as administrator and input: Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux Install Ubuntu 18.04 LTS from Microsoft Store Setup SSH Remove inher

ASP.NET Core部署到Windows IIS

网上已经有许多ASP.NET Core关于Widows IIS部署的文章,在部署到服务器时遇到了一些问题,在这里我就不再对原理进行阐释(复制)了,只写下一些关键环节,想看原理的同学请参考官网,此文章作为留用. 步骤: 1.ASP.NET Core程序内配置 2.Windows Server配置  一.ASP.NET Core应用程序配置 web.config 配置(官方教程) 重点修改 processPath 和 arguments 两个参数 processPath 修改为 dotnet arg

Asp.net Core 初探(发布和部署Linux)

前言 俗话说三天不学习,赶不上刘少奇.Asp.net Core更新这么长时间一直观望,周末帝都小雨,宅在家看了下Core Web App,顺便搭建了个HelloWorld环境来尝尝鲜,第一次看到.Net Web运行在Linux上还是有点小激动(只可惜微软走这一步路走的太晚,要不然屌丝们也不会每每遇见Java VS .Net就想辩论个你死我活). 开发环境和部署环境 Windows 10.VS2015 Update3.安装.Net Core SDK.DotNetCore.1.0.1-VS2015T

【ASP.NET Core】在Win 10 的 Linux 子系统中安装 .NET Core

在上一篇文章中,老周扯了一下在 Windows 10 中开启 Linux 子系统,并且进行了一些简单的设置.本篇咱们就往上面安装 .net core . 老周假设你从来没有用过 Linux,所以,接着上一次的博文,老周先给您介绍几个可能比较常用的东东. 切换到 root 用户上下文 当你启动 Ubuntu 子系统后,你会看到,在你的用户名.机器名.路径名后有个 $ 符号.如下图. 这表示当前用户的权限是受到限制的,如果想要执行某些需要高权限的命令(这个类似于 Windows 中的以管理员身份运行

Asp.Net Core 发布和部署( MacOS + Linux + Nginx )

在上篇文章中,主要介绍了 Dotnet Core Run 命令,这篇文章主要是讲解如何在Linux中,对 Asp.Net Core 的程序进行发布和部署. 有关如何在 Jexus 中进行部署,请参见本人的另一篇文章:http://www.cnblogs.com/savorboard/p/dot-net-linux-jexus.html 目录 新建一个 WebApp 项目 发布到 Linux,Mac OS 使用 Nginx 进行反向代理 新建一个 WebApp 项目 在 Asp.Net Core

WSL(Windows Subsystem for Linux)的安装与使用

有关WSL的介绍这里就不做解释了.另外,本文仅适用于win10 build 16215以及之后的版本,之前的版本可参考官方链接. (可使用“winver”命令查看windows版本号) 安装: 1.  管理员权限运行powershell并运行下面的命令: Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux 或者:控制面板->程序和功能->启用或关闭Windows功能->勾

Windows Subsystem For Linux

准备材料,windows 10, Xshell 5/putty, Xmanager/Xming. 1. 打开控制面板,程序和功能,左侧"打开或关闭windows功能",windows子系统,勾选复选框 2. windows命令行输入bash等待下载安装 之后,就可以从开始菜单搜索bash打开了 3. 从开始菜单打开bash 编辑/etc/ssh/sshd_config 添加/修改以下几项 ListenAddress 0.0.0.0 UsePrivilegeSeparation no P