Getting MusicStore to run on RHEL

The ASPNET Music Store application was built to demonstrate MVC and Entity Framework running on the newest .NET platform, including .NET Core. If you visit the link, you’ll see that various platforms are mentioned, including Mono. However, you’ll also notice that the instructions are dated: references to dnx and dnu are throughout the README file.

This blog post will show how to bring MusicStore up-to-date and run it on Red Hat Enterprise Linux (RHEL).

(If you don’t have RHEL, you can get your zero-dollar developer’s edition of RHEL)

The first step is to download, or fork and clone, the MusicStore repo from github. In my case, I forked the repo to my github account and then ran git clone so I’d have a copy of the source code.

At this point, I want to move into the directory and run dotnet restore. This will pull down the referenced libraries (DLLs) used by the project.

But wait; it didn’t work. There’s an error. For some reason, it’s referencing RC3 bits, where I want only the RC2 bits. Perhaps there’s a release targeted only to RC2. I run git tag --list and, sure enough, there it is:

The next step is to check out the tag, which will make only the RC2 code available to me. This is done with the command git checkout tags/1.0.0-rc2.

Now I can run dotnet restore and can expect successful results:

Success! Now all I need to do is run dotnet build and I’ll have the binaries necessary to run this web site:

Wait. What’s all that red, error message stuff? Let’s scroll up and see if we can find what’s going on:

There is it. It’s attempting to compile this program for framework v4.5.1, which is a framework that works on Windows, but not Linux. Remember; we want .NET Core 1.0. If only there was a way to specify the framework we’re targeting when calling the build command.

And, alas, there is! Running dotnet build --framework netcoreapp1.0 will skip the v4.5.1 build and build for .NET Core 1.0 only:

Now we finally have the bits we need (by the way, they’re at bin/Debug/netcoreapp1.0/MusicStore.dll). We can run dotnet run to fire up the web server…

…and point our browser to http://localhost:5000 and voil√†:

So, even though the MusicStore github repo mentions dnx and dnu and seems to favor not-RHEL platforms, we’ve seen how we can easily tweak the code to run on RHEL.

Now, wouldn’t it be cool to be able to debug this code from, say, within an IDE? Check back soon, because that’s my next blog post.

All The Best,

— Don

For additional information and articles on .NET Core visit our .NET Core web page for more on this topic.

Take advantage of your Red Hat Developers membership and download RHEL today at no cost.