Compiling ASP.NET 5 RC1 on a Mac or Linux
It is very exciting times as the Release Candidate for ASP.NET 5 was released a couple weeks ago. Of course, I just had to try it out on my Mac and it works! Simply awesome! I think this really opens up the doors for a lot of developers to try out ASP.NET and C#.
The Build Issue
I did run into one problem with compiling the project on my Mac which slowed me down when I first started the project. After creating a project using the [ASP.NET Yeoman Generator] (https://github.com/OmniSharp/generator-aspnet) (yo aspnet
), I tried to build the project (dnu build
) and got the following compile errors:
The Fix
The issue is obvious from the first line in the error message if you are aware of how ASP.NET 5 is architected but for the uninitiated this could be confusing. The issue is that you are building for the full .NET framework which is not available on Mac or Linux when using .NET Core based DNX (you can switch your .NET Execution Environment (DNX) using the .NET Version Manager (DNVM) and use Mono). The issue is well known and is documented in the Release Notes for RC1. Note that you can still work on the project on a Mac even with the errors as you are building for both versions of the .NET Framework.
The fix is also fairly straight forward. The project.json
has references for the .NET Frameworks that ASP.NET 5 can be compiled for:
As you can see, the default Yeoman Generator Template has dnx451
and dnxcore50
frameworks listed. The DNX451
reference is for the full .NET Framework which is not available on Mac or Linux. The dnxcore50
reference is a subset of the full .NET Framework that has been open source and developed to be cross platform. The fix is as simple as removing the reference for dnx451
in the project.json
file so that only the reference to dnxcore50
is left:
Now you should be able to run ```dnu build`` again and have a successful build. I hope this helps someone if they run into the same build errors. Being able to compile and run on Mac and Linux is awesome. I can’t wait to see where the platform goes from here!
Comments