Running ASP.NET Core Applications on Windows Subsystem for Linux

DZone 's Guide to

Running ASP.NET Core Applications on Windows Subsystem for Linux

Did you know you can run Linux applications through Windows 10 without the need for Hyper-V or other VMs? Well, you can! Read on to find out how!

· Web Dev Zone ·
Free Resource

NB! I have a Windows 10 Fall Creators Update and this post is written based on this. In general, same steps apply to other Windows 10 versions with some minor differences.

Setting up Linux on Windows 10

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

Enable Windows Subsystem for Linux

After installing the feature, Windows needs to 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 the Store app and installed Ubuntu Linux from there.

Ubuntu Linux in Windows Store

It takes time to get things up and running, as after installation there are some configurations needed. The user is asked for a 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 the Windows 10 search to run it.

Search for Ubuntu on Windows

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

Installing .NET Core

I installed Ubuntu Linux, but these .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 time to get .NET Core installed, as after installation it also initializes things.

Running the Application From Local Disk

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

ASP.NET Core application running on Linux on Windows

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


NB! I have experienced some issues thus far. Sometimes after running an ASP.NET Core web application on Ubuntu it’s not possible to close the terminal. If you close it from Task Manager, on the next run the terminal window opens but nothing happens. In case of any issues please report problems to the Windows team using the 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 a Linux environment available to test and try applications quickly. Although I faced a 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 Linux on Windows a good try.

virtualization ,windows 10 ,linux ,asp.net core ,web dev

Published at DZone with permission of Gunnar Peipman , DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}