How Visual Studio 2015 and ASP.NET 5 Impacts You

AnnouncementDevGoogleLink-SharingMicrosoftTech

Quick Summary:

  • The entire .NET framework is now open-source on GitHub
  • ASP.NET works cross-platform including on Linux and Mac
  • Visual Studio Community edition is free

I’m currently in New York City attending the Visual Studio Connect(); event. There’s a lot of excitement in the air for Visual Studio vNext, ASP.NET vNext, and Azure. In my opinion, this is the most impactful change that Microsoft’s Developer Division has made since first introducing .NET. I’ve been following this team closely since the first grumblings of .NET, more specifically ASP.NET. But, this is big. Sure, over the years the team has made cosmetic changes or introduced new functionality. But nothing has touched the foundation of the framework until now.

Announcement

Today, Microsoft announced that Visual Studio Pro will have a cousin called Visual Studio Community. While both have the same features and functionality, you’ll still pay for the Pro version. The Community version will be free. The Community version is a full fledged product that allows start-ups, students, hobbyists, and open source developers access to the Microsoft tools for free for ever. There’s no time limitation and there’s no catch. All of the details are explained in the EULA. If you have to ask yourself if you need to read it, you probably need to pay for the Pro license.

Also, Microsoft has announced even more items into the open source world. All of these items are available on GitHub. This includes the .NET Framework and complete ASP.NET stack. It also included Entity Framework. All of these teams are open to pull requests. So feel free to make your requests today! To add, ASP.NET will now work cross-platform on Mac and Linux. These capabilities are available due to the strengthened relationship between Microsoft and Xamarin. Be sure to visit http://microsoft.github.io.

How This Impacts Existing ASP.NET Developers

For most current ASP.NET developers, very little will change. ASP.NET 5 is still ASP.NET (minus Web Forms). It’s still C# or VB.NET. It’s still MVC. However, the foundation will be changing. A few of the changes are outlined below.

Global Assembly Cache (GAC)

What more can I say then to say “Goodbye GAC!” Really, that’s exciting. The GAC was the modern day version of DLL hell. This was one piece of baggage that continued to hold back ASP.NET from being a true cross platform technology. The removal does leave behind a gaping hole for enterprises. As of this post, there is no centralized location for binaries in the file system. This means that if you have 105 applications on a box, you’ll have 105 copies of the MVC 6 binaries. I’m sure the team is diligently working on a solution, but it’s not here yet.

Configuration

One of the core elements of ASP.NET that has been around since the beginning has been configuration. One big change you’ll notice in the new version of the framework is the abandonment of .config files. Instead, the .config files are replaced by JSON files and Startup.cs. To get configuration, you’ll be able to use configuration like the following:

Configuration = new Configuration()
    .AddJsonFile("config.json")
    .AddEnvironmentVariables();

Notice the last line. We’re adding environment variables to our configuration. We can now use environment variables, INI files, JSON files, or XML to update the configuration.

You can also use #IFDEF statements for loading different configuration based on the environment.

If you use config transforms, you can do something relatively close in the new world by adding an environment variable describing the environment. This can be done as a process variable or a machine variable. I’ll most likely post more about this at a later time. But, to show a quick demo, I can update that configuration section like so:

// Setup my dynamic configuration
var ev = Environment.GetEnvironmentVariable("MyAppEnvironment");
 
// Setup configuration sources.
Configuration = new Configuration()
    .AddJsonFile("config.json")
    .AddJsonFile("appsettings." + ev + ".json")
    .AddEnvironmentVariables();

Notice in this update I’m grabbing an environment variable named MyAppEnvironment and adding a new JSON file to my configuration called appsettings.(my variable value).json. This will allow me to have similar functionality to what I have now.

Dependency Injection

DI is now prevalent in the application pipeline very early on. Microsoft has made DI a first class citizen by implementing their own DI capabilities, but allowing you to use third party such as ninject. We can now use injection within our views as well. So, using the configuration example above, I may want access to configuration that I’ve already imported in my view. In Startup.cs, I’ve made the following changes:

public IConfiguration Configuration { get; set; }
 
// This method gets called by the runtime.
public IServiceProvider ConfigureServices(IServiceCollection services, IServiceProvider previous)
{
    ... 
    services.AddSingleton<IConfiguration>(_ => Configuration);
... 
}

That’s it. I’ve added the Configuration as a singleton. Now in my view, I’ll do the following:

@using Microsoft.Framework.ConfigurationModel
@inject IConfiguration config
 
...
 
<div class="col-md-12">
    <h2>@config.Get("AppTitle")</h2>
</div>

As you can see it’s extremely simple to setup.

NuGet and Packages

With these announcements, Microsoft is also adding in Bower, Grunt, and Gulp support into Visual Studio 2015. If you are developing cross platform, you’ll notice that not all packages are ready for the Core CLR. Some packages are already configured to work such as JSON.net.

Others

There are several other items that have already been discussed on the ASP.NET GitHub page including KVM and KRE. I’d highly recommend checking out that page for more information.

Conclusion

Just sitting in the room as Visual Studio Connect(); I was able to feel the vibe from existing Microsoft developers and from developers using other platforms. I knew this was a big movement, but was surprised to hear from others how big.

What do you think about the announcements from today?

Nov 12 2014 1:11 PM