Tuesday, August 18, 2015

Creating and running a .NET without Visual Studio or anything over 100 megs...

At home I've got an older laptop with an SSD that isn't that big. This eventing I wanted to fiddle around a bit but I didn't want to install that massive Visual Studio 2015 and everything it comes with.

So ... vNext to the rescue. Here's what you need to do to get going. ( I'm assuming you've got nothing on your box installed ).

1. Get the DNX runtime and the DNVM host. Don't know what I'm talking about ? Check this out. In short - you just need to open up a command window ( in admin mode ) and run:

@powershell -NoProfile -ExecutionPolicy unrestricted -Command "&{$Branch='dev';iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/aspnet/Home/dev/dnvminstall.ps1'))}"

2. Install node from the node website.

3. Reboot your machine. This is convenient because it loads `npm` and `dnvm` / `dnu` commands into the path.

4. OK - once you're machine is back up, open up a command window and we need to install an dnx-runtime - so type `dnvm upgrade`.  Now you should have a runtime installed when you type `dnvm list`.

5. Install Yeoman! - this will help you scaffold the app. `npm install -g yo` will get you there. ( meaning: Node Package Manager ( NPM ) install the YeoMan! clr globally ).

6. If you want to scaffold something with YeoMan! - you need to install the generator itself through the Node Package Manager (NPM), so : `npm install -g generator-aspnet`. You can check out all the other generators over at the YeoMan website.

7. Cool: now we can scaffold our vNext app: `yo aspnet`. This will present a YeoMan! scaffolding menu where you can select the type of app you want. I'm going for console app for this walkthrough.

8. Once that's done - you can see the scaffolded files in the newly created folder:

As you can see - the scaffolded code already contains a Console.WriteLine - so can compile and run this - and should see something already in the console. So:

9. `dnu restore` . This will go out and get all the dependencies defined in the project.json onto your machine. If you don't do this - you will not be able to compile / build because of missing dependencies.

10. Now we can build - so `dnu build`. There you go - there's a /bin folder containing the assembly.

11. Since we run the app within the runtime, the run command is a `dnx` command : `dnx . run`.

Et voila: vNext hello world without Visual Studio!

1 comment:

  1. Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging. If anyone wants to become a .Net developer learn from Dot Net Training in Chennai. or learn thru ASP.NET Essential Training Online . Nowadays Dot Net has tons of job opportunities on various vertical industry.