ASP.Net is making a huge comeback! With the ASP.Net vNext the open source version of the .Net series, has opened up it’s framework to an entirely new web developer community . The cool thing about this lean framework is you can get use ASP.NET on the comfort of your Mac. In this tutorial , I will be going through the tools and frameworks you need to get ASP.NET vNext running on OS X Yosemite.
This post has been updated to reflect the changes made from vNext Alpha to Beta
To get started you will need the following software ,frameworks and package managers :
Before you get started installing the frameworks and PKGs you need to get ASP.NET vNext running, make sure that you have the latest version for Node and npm. Copy and paste the code below into terminal.
node --version && npm --version
Check to see if you have git installed as well .
Yeoman is an open source sleek scaffolding tool that consists frameworks that make it quick and easy to build web applications. The neat thing about Yeoman is it combines several functions into one place, such as template generators which we are going to use to get the ASP.NET vNext up and running .
sudo npm install —global yo
Now that Yeoman is installed the next step is to get our ASP.NET framework installed using the yeoman generator.
npm install -g generator-aspnet
For this examples I selected the MVC Application. Once you have entered an appropriate name, the generator will take care of the rest.
Now that MVC application all ready , navigate to the folder notice the model, view and control are all there. Similar to what you find if you used the MVC model template in Visual Studio.
Before you can run your ASP.NET vNext in sublime there are still a couple of dependencies that need to be installed. A lot of tutorials I have read miss the dependencies below but I encountered a lot of errors when trying to configure the K commands.
In order to run an ASP.NET vNext on a Mac and Linux environment you need Mono. Copy and paste the code below into your terminal.
git clone https://github.com/mono/mono.git
Homebrew is an open source software package management tool ; it enables you install all the stuff you can’t directly install in terminal out of the box. To install Homebrew you will need to copy and paste the Ruby code below.
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Now, that Homebrew installed make sure to install all the extra mono dependencies.
brew install autoconf brew install automake brew install libtool
Install the ASP.NET vNext Tools
If you had already tapped the repo for previous releases(Alpha) you will be to run the untap command to delete the old commands and tap again to get the updated brew scripts.
brew untap aspnet/k
Tap Command & Install kvm
brew tap aspnet/k brew install kvm
It is important to note that in the current version of Asp.Net vNext Kestrel doesn’t come with it out of the box. So in this case since I am using the “Kestrel”: “1.0.0-beta1″ (from “Kestrel”: “1.0.0-beta1″ ). To find out which version of Kestrel you are running, open your project.json file in your Asp.Net project. To install Kestrel copy and paste the code below.
kvm install 1.0.0-beta1
Setting up your project in Sublime
Since this is possibly the first ASP.NET project you will need to install the Kulture as instructed in here using the package control plugin. If you have some issues with these steps, you can install it manually using the following steps:
- Open your project in sublime
- Click view
- Click show console and copy and paste the python code below
import urllib.request,os,hashlib; h = '7183a2d3e96f11eeadd761d777e62404' + 'e330c659d4bb41d3bdf022e94cab3cd0'; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); urllib.request.install_opener( urllib.request.build_opener( urllib.request.ProxyHandler()) ); by = urllib.request.urlopen( 'http://packagecontrol.io/' + pf.replace(' ', '%20')).read(); dh = hashlib.sha256(by).hexdigest(); print('Error validating download (got %s instead of %s), please try manual install' % (dh, h)) if dh != h else open(os.path.join( ipp, pf), 'wb' ).write(by)
With Kulture installed you will be able to run you ASP.NET project successfully. To check to make sure that everything is working, try adding a new namespace into your HomeControllers.cs file. If everything is in place you will notice the intellisense is in working.
Steps to running your project
- In sublime enter Cmd + Shift + p
- Type K and select run K Command
- Select kpm build
- Select k kestrel – If everything has installed correctly the server should start
- Navigate http://localhost:5004/
And there you have it ! Asp.Net vNext on a Mac .