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!
Join the DZone community and get the full member experience.Join For Free
windows 10 has something called windows subsystem for linux and this something enables us to run linux applications on windows 10 using linux without hyper-v or other virtual machines. when building multi-platform applications like my open-source temperaturestation solution , then having linux right there for testing comes very much in handy. this blog post shows how to get linux running on windows, how to install .net core, and how to run web applications on linux.
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.
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.
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.
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.
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.
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.
Published at DZone with permission of Gunnar Peipman, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.