Chris Gomez

Development topics for the indie programmer

ASP.NET 5 on Ubuntu Linux "from scratch"

[Update: The following is working with ASP.NET beta 6 and was tested on August 22, 2015.  I'll try to keep the post updated, but for one thing I have seen in Announcements for beta 7 that they are changing the dnx command syntax so that may need to be updated in the future.]

[Update: August 22, 2015: I was having problems with dnu restore. The script has been updated to add an environment variable to .bashrc to give Mono more threads per cpu, which made dnu restore much more reliable.]

I've been working at getting ASP.NET 5 running on Linux.  This post doesn't replace the great work of the documentation at the ASP.NET repos at github, or the great work of those working on the Yeoman generators for aspnet.  This merely stands on their shoulders.

I wanted a single script I could use to bootstrap a Linux VM.  After working at it and testing again and again for a few days, here is the script I've come up with for now:

install_aspnet.sh Gist on Github

This follows the instructions (essentially) for installing mono, libuv, and dnvm.  Then it installs node and yeoman (remember, I am basing this on a clean install of Ubuntu 14.04 LTS) and puts you just a few steps away from running an ASP.NET template.

How clean is that Ubuntu install?

My Ubuntu installation for this test is via VirtualBox 5.0.2.  The host is Windows Server 2012 R2.  I did accept the third party software and didn't skip anything during the installation.  I let the system get all the Software Updates.  Then I installed the VirtualBox Guest Additions just to make things smoother.  Finally, I installed Atom text editor from atom.io.

Getting the script

Method 1: Copy/Paste into Atom

If you enable the Shared Clipboard and at least Host to Guest (Bidrectional works too), I've opened the VM, opened atom and then copy and pasted the script home folder as install_aspnet5.sh.

Then I run:

bash install_aspnet5.sh

I had no interruptions other than needing to elevate for the sudo portions of the script right when it started.

Method 2: The one liner

Here, I copy the file down using wget (which seems to be preinstalled) and immediately run bash, but after authenticating for sudo elevation, I can walk away.

wget http://bit.ly/1U0reF6 --output-document=install_aspnet5.sh && bash install_aspnet5.sh


"How did this happen?" Q&A

1) Why not "sudo bash"?  Because the dnvm download in particular didn't really want to be installed as root.  I was much happier having that portion installed as my user.  Since the dnvm script updates .bashrc, if you download dnvm as root, you have trouble with the various utilities (dnvm, dnu, dnx) running in your user environment.

2) Why did you wget and then run via bash instead of piping curl output to bash?

A month ago, that sentence would have been meaningless to me.  I am not sure if it is truly literate or sounds like a first grader.  In any case, I really wanted to download and pipe the script to bash.  But what I found was, the script would halt after mono was installed.  I don't know why and I found that getting the file and then calling bash on it worked.  Why wget instead of curl?  No reason.  curl -L [url] > [filename] should work, too.


Script's Done

DNVM and the Mono environment won't be set up for you.  The shell will tell you it has no idea what dnvm is and you really need an environment variable set before you run dnu restore later.  The ASP.NET team's script adds dnvm to .bashrc, and after some reading, I decided to export the Mono environment variable there, too.  Let me know what you think about these choices.

You could always open a new shell but I found manually running:

source .bashrc

did what I wanted and I could continue on from here.

Now you take over

The script ends with mono, libuv, dnvm, node, yeoman, and the aspnet generators installed (along with dependencies).


You still need a version of aspnet to be installed (dnvm list shows none).  So:

dnvm install latest

After this was done, I still need to generate an ASP.NET 5 project using:

yo aspnet


So far I've tried the Console and WebApplicationBasic templates.  After one is created, it will give you a quick rundown of getting them running.  But for review:

First you need to cd to the folder you created the project in and restore NuGet packages:

dnu restore


Then finally, after all that I could run the Console application with

dnx . run


And I could run the WebApplicationBasic application with

dnx . kestrel


Once the WebApplicationBasic template is running, point to http://localhost:5000 in your browser.

How does this work for you?  I greatly appreciate suggestions, as I'm coming over to Linux from a career spent in Windows.

Visual Studio 2015 is here! How’s ASP.NET 5 coming?

Visual Studio 2015 is RTM today and there was a live launch event.  Besides a typical keynote highlighting new features, there was also an in-depth feature about building a real application with the new Visual Studio.  Along the way there were tons of great interviews and tidbits of information.

I don’t want to forget everything I looked at today, so frankly this post is mostly about keeping track of all the links to look at over the next few weeks:

Recordings of the Release Event

https://channel9.msdn.com/Events/Visual-Studio/Visual-Studio-2015-Final-Release-Event

Page one is filled with sequential videos of the keynote and then on toward In The Code, the special feature I was mentioning earlier.  If you skip over the out-of-place Git Branches and Policies video that got placed first, you can relive the event by watching these videos.

But don’t stop there.  Page two and beyond have more short videos that expose new features of Visual Studio 2015.

Go Get Visual Studio 2015 now

https://www.visualstudio.com/

If you just want a free version, get Visual Studio Community.  It’s all the features of Visual Studio Professsional, except it’s free and you can use it on small teams or indie development.  Publish your first app, web site, game, or whatever.

ASP.NET 4.6 and .NET 4.6 RTM

ASP.NET 4.6 is finished and “in the box”.  This release is similar to past releases with some nice new incremental features for WebForms, MVC, Web API and so on.  Alongside is the .NET Framework 4.6.  If you’re a seasoned .NET developer, this will all seem like a familiar upgrade progression.  It works much the same as you remember.

Here’s a nice video describing the updates to Web Forms in ASP.NET 4.6:
https://channel9.msdn.com/Events/Visual-Studio/Connect-event-2014/812

Jeff Fritz blogged about ASP.NET 4.6 at the top of this post (that goes into general editor improvements and ASP.NET 5, too)

http://blogs.msdn.com/b/webdev/archive/2015/07/20/announcing-asp-net-4-6-and-asp-net-5-beta-5-in-visual-studio-2015-release.aspx

Okay, so how about ASP.NET 5?

As stated above, Jeff’s post talks about ASP.NET 5 beta 5 being “in the box” of Visual Studio 2015 RTM.  The most important thing to remember here is that ASP.NET 5 is NOT DONE.  I am truly concerned about this and definitely hope the word gets out before people get frustrated with ASP.NET 5 in this release.

But here are some links I want to look at that have to do with this release:

The ASP.NET 5 Roadmap – We have a good release schedule through the end of the year and we’re looking at a possible Q1 2016 release.

The biggest takeaway I got from all of this is SignalR will not be ready.  I’m a big fan of SignalR and I’ve got to dig in and see what we’re going to have and when.  Web Pages also won’t be ready.  I’ve always thought of Web Pages as a gem that is too often overlooked.  There are plenty of web sites that would work just fine just using Web Pages and not getting bogged down in MVC or something larger.

Now, what about stuff Jeff Fritz didn’t blog about?

In an effort not to just reblog here, I loved these videos on ASP.NET 5:

Up and Running with ASP.NET on Linux – Mark Rendle  - Entertaining and informative.  One thing it really brought home (unintentionally) is how the age of package managers makes us that much more dependent on being always online.
https://vimeo.com/131631887

Omnisharp: .NET sans Microsoft – Mathew McLoughlin – Nice look at using the other editors that are being supported in this really cool open source project (plus Visual Studio Code).  Makes you want to jump in and and help, doesn’t it?
https://vimeo.com/131199088

(Don’t forget to look at the OmniSharp site itself)

Migrating your API from Web API 2 to MVC 6 – Filip W – Awesome and insightful look at how it’s REALLY going to feel when you port a Web API over to MVC 6.
https://vimeo.com/131633175

Documentation

ASP.NET 5 documentation seems to be in a few places.  The team is trying out some different things and still supporting the usual places to find things.

ASP.NET 5 documentation on Read the Docs: http://docs.asp.net/en/latest/index.html

ASP.NET 5 on the ASP.NET site: http://www.asp.net/vnext/overview/aspnet-vnext.
Okay, so this isn’t really documentation, but there are some pages here that are documentation like posted by the teams tech writers such as:
Creating a Web API in MVC 6
View components and Inject in ASP.NET MVC 6

And then there’s stuff to read on the wiki in the GitHub repo too

https://github.com/aspnet/Home/wiki

ASP.NET Community Standup

And if you aren’t watching the (usually) weekly ASP.NET Community Standup, then WHY NOT?

ASP.NET Community Standup YouTube Playlist

Philly Code Camp – Web developers are already game developers

Thanks to everyone who attended my session: Web developer by day, Game developer by night at Philly.NET Code Camp 2015.  I’m so grateful that so many people would take the time out from important topics in the .NET world and beyond to come have a little fun learning about hobbyist game development.  The key message that I hope was well-received is ASP.NET developers are well-suited to put their skills to work building high performance games.

Game development seems like a black art.  If you were a career developer (on any platform) you often found the style of program flow to be foreign if you were switching from event driven programming to game programming.

Modern web development frameworks and events are working pretty hard to minimize the boilerplate code you have to write in your game loop.  In some cases, it even begins to feel somewhat event driven again.  I don’t want to oversell that.  Even in the code we wrote during the Code Camp session, we were still thinking about “what do we have to update every frame”. 

We looked at Phaser, a JavaScript framework that helps you build fast action video games.  Phaser offers plenty of great tools to help you “set-and-forget” attributes of your game components and then let the engine take care of it. More...

A DevOps “Jump Start” Using Azure Web Sites and GitHub

Previously, I discussed that I started a side project to discover better ways to build “web apis”.  In this case, I am using ASP.NET Web API but I think the lessons I am after could be applied to many technologies and clouds.

One of the things I was looking for was some light continuous deployment after code is committed.  At the same time, I wanted to see what the process was to get different kinds of web sites, using different frameworks and technologies, running on Azure Web Sites

After all, the marketing says it supports .NET, Java, PHP, Node.js, and Python.  It also claims continuous deployment.  So is it faster, easier to use, and more fun?

What To Deploy?

I created a repository on GitHub called WebJumpStart for the purpose of testing out a few tricks Azure Web Sites has up its sleeve. 

In it, you will find three web sites. 

  • AspNetMvc is an ASP.NET 5 MVC site right out of the gate after File > New Project. 
  • HelloWorld is just static content files (simple html/js/css files). 
  • NodeExpress is the Node Express starter site, also unmodified (it is a bit out-of-date at this point, but the magic of npm ensures the versions I’ve picked in package.json are there for me to use).

Note that only one of these projects is based in ASP.NET.  HelloWorld and NodeExpress could have been built with notepad, Sublime Text, Brackets whatever…

More...

A path to happiness with ASP.NET Web API

I recently started a side project to learn how to better compose a “web api” project.  I am using ASP.NET and ASP.NET Web API, but there were a lot of things I really wanted to drill down on.

First of all, I have seen many a project at various places I’ve worked begin with the ASP.NET templates.  Obviously, this is nothing new.  Many a team has gotten the chance to work on a brand spankin’ new ASP.NET project and hits File > New Project in Visual Studio and starts coding away in what the project template spits out.

But I really believe the project templates are meant more for exploration of what is possible.  You look at them to see how the framework operates and some ideas of what you can do with it.  When you start wanting to go down the road of laying out the project so it’s actually easier to code, deploy, and maintain… well that’s an entirely different story.  And since I may find myself in the situation of being asked to hit File > New Project someday, I’d like to have practiced with starting on a truly EMPTY project and composing the building blocks that will make it deliver real business value quickly and EASILY.

So I wanted to come up with a non-trivial project that I might actually have a use for.  And I came up with the following.

The Project

I’d like to have a small website that allows me to enter dues payments for residents who live in a homeowner’s association.  Each quarter, the residents have dues to pay, and it’s nice to be able to record some information about the dues payments.  I’ve found it’s nice to keep track of when the payment was received, deposited in the HOA account, what the check number was, and how much they paid (because it’s not always the balance due!).  I’d like to be able to build in the logic to automatically assess fines for being late and eventually generate the billing statements (perhaps either for display in the site or by email).

More...

Intro to Git in Visual Studio

More and more, my topics are going to involve you downloading and looking at code.  And that will mean you can get the code from GitHub.  The idea of “social coding” has gone beyond the hot new fad to being the standard for open source projects.

Even for Microsoft developers who are used to waiting for CTP’s and Preview SDKs, this is changing rapidly.  The ASP.NET team has embraced open source, and are developing the next generation of ASP.NET in the open, and it’s all available to view and contribute to on GitHub.  Even TFS supports Git repositories now and so do the other sites in the “social coding” space.

If your daily home is Windows and Visual Studio, here’s a short primer on how you can get started.

Okay, I have Visual Studio, what else do I need to install?

Right now, nothing.  Let’s start with Visual Studio’s capabilities and move on from there.

At the Philly.Net Hands-On Lab last September, I demonstrated a few tools by using a GitHub repository.  We’ll practice cloning this repository first.

The purpose of this post, and this lab, is just to show you how to use the Git tools built into Visual Studio.  As you get more advanced, there are a lot of other great things you can do with Git, and I’ll have some tips for you on that as well.

Get the URL for the repository

If you head to https://github.com/SpaceShot/PdnJsToolsHol, you’ll find the repository.  First off, you could just use the Download ZIP button in the lower right to get the code.  But instead, copy the clone url.  We can use that inside Visual Studio.

The url is: https://github.com/SpaceShot/PdnJsToolsHol.git

Open Team Explorer in Visual Studio 2013

You can use any Visual Studio edition to do this.  Whether you have Ultimate, Professional, Community or an Express Edition, this works.  Since this project is an ASP.NET Web API project, you COULD use Visual Studio 2013 Express for Web.

But don’t do that.  If you need a free version of Visual Studio, get Visual Studio Community.  It is equivalent to the Professional version, but it is absolutely free for you to use to get started learning to code.  Get it here.  Do not bother with the Express editions anymore.  It is high time they were unified again and kudos to Microsoft for doing it.

More...

3D Game Development: Sculpting Worlds with Unity

Last night at Philly GameWorks in Malvern, we learned the basics of using the Unity game engine to create an outdoor world you can then explore using standard first person gaming controls.

We’ll be working more with Unity and other game engines at the meetup, and we want to see you there.  There should be no worries that you haven’t been keeping up as we strive to have meetups that cater to the beginner and the Philly GameWorks enthusiast.

(You can download this ZIP file stored on Dropbox and run the Windows executable if you want to see the product. Hopefully that works for you if you are interested:  NighttimeScene.zip)

We hadn’t written a single line of script code and we had built a world that we could explore in a first person viewpoint complete with a beautiful sky, mountains, hills, trees, grass and environmental sounds.

 

We used the standard installed Character Controller package to insert a First Person Controller that you could use to walk around your creation when playing the game right inside Unity.

More...

Start your journey in code

It is cliche to say a journey of a thousand miles begins with a single step.  Nevertheless, starting a journey to become a software developer is going to take awhile.  Therefore, my advice is you start today.

When I related how my journey began when I was ten years old, it isn’t to scare you into believing that you only have a few decades to go.  Not every moment of every day of that time was spent improving as a developer.  I gave up on the whole thing for a few stints of years at a time.  Then I became reinvigorated and got a few jobs.  Next thing you know, it’s a career.

What I believe you must do is begin immersing yourself in the discipline.  This doesn’t mean immersion as in fanatic devotion.  It means that you should do what you can to start listening to voices in the development community.  It means you should try to build some meaningful application.  It means you should code. More...

Functional Programming Starters

Here are some links I want to save regarding getting more proficient with functional programming.

Try F# right in your browser - http://www.tryfsharp.org/Create

Try Haskell right in your browser - https://tryhaskell.org/

F Sharp for fun and Profit – Scott Wlaschin – http://fsharpforfunandprofit.com

A Functional Architecture in F# – Mark Seemann builds an ASP.NET Web API in F#, JUST F#, but along the way he gives a great practical overview of why functional programming will improve your applications.  http://www.pluralsight.com/courses/functional-architecture-fsharp
(Requires Pluralsight subscription)

Functional programming design patterns by Scott Wlaschin - http://www.ndcvideos.com/#/app/video/2311

Underscore - http://underscorejs.org/
A library with functional helpers that will help ease your transition to thinking functionally and using collections effectively.

How did I get started coding?

In the 80’s, it became common for personal computers to be sitting out on store shelves with some kind of green scrawling of characters sitting naked in an ocean-like black display.  These new personal computers would be turned on and available for you to type on.  The Commodore 64, VIC-20, TRS-80, and Atari PC models would be beckoning you at local department stores.

I am kicking myself right now trying to remember what the Atari PC screens would display after booting.  My faint memory was that it said “READY” when they were booted.  Almost every time I walked by, someone would have typed their name in only to be greeted by a response of “SYNTAX ERROR”.  What were you supposed to do with these things?

One day, I saw someone actually using the thing. More...