Visual Studio 2017, Visual Studio Code and Visual Studio for Mac – What Should I Use?

Jamie Taylor
Visual Studio 2017, Visual Studio Code and Visual Studio for Mac - What Should I Use? - Header ImageSource: https://stocksnap.io/photo/EAYRJAXV9F Copyright 2017: Anthony Ginsbrook

Today’s header image was created by Anthony Ginsbrook, the original source for the image is available here

Last month Visual Studio 2017 was released. Microsoft celebrated it’s release by having a live streamed release event.

You can watch the entire event, on demand, over at Channel9.

Now that it’s been released (along with the .NET Core 1.1 tooling), we.NET Core developers are left wondering which IDE we should use to develop out .NET Core apps.

I’ve touched on this subject before, but this post will be an update to that one.

Currently, we have a choice between:

  • Visual Studio 2015
  • Visual Studio 2017
  • Visual Studio for Mac
  • Visual Studio Code

I wouldn’t recommend VS 2015 going forward, as it only has support for the earliest .NET Core toolsets and SDK versions.

Of course it’s your decision, but you wont have access to all of the .NET Core 1.1 features if you continue to use VS 2015 moving forward.

What Should We Be Using To Develop Our .NET Core Applications?

This is a tricky question because it relies so heavily on the Operating System that you are using on your development machine.

If your dev machine is running Windows, for instance, then you have the choice between:

  • Visual Studio 2017
  • Visual Studio Code

Similarly, if your dev machine is running MacOS then you have a choice between:

  • Visual Studio for Mac
  • Visual Studio Code

But if your dev machine is running one of the supported Linux distributions, then you are limited to using Visual Studio Code.

For official IDEs and tooling, anyway.

That being said, .NET Core source files are just text files, if you don’t mind using the terminal to build your application then you could just as easily not use an IDE, using the terminal and a text editor instead.

This is true of Windows and MacOS, obviously.

There is another cross platform option in Jet Brains’ Project Rider, but it’s still in early public beta.

Jet Brains are the developers behind IntelliJ and ReSharper among a few others.

My Setup

As an example, I run the following across my OS installations:

  • MacOS Sierra – Visual Studio Code and Visual Studio for Mac
  • Ubuntu 14.04 – Visual Studio Code
  • Windows 10 – Visual Studio Community Edition

Cross Platform Options

As long as you’re running Windows, MacOS Sierra or one of the supported Linux distributions, then you have a cross platform option open to you: Visual Studio Code.

Technically you should be able to run VS Code on most Linux distributions, but you won’t be able to install and run the .NET Core SDK on unsupported ones.

Visual Studio Code

Visual Studio Code started out life as a text editor and, through it’s extensive plugin system, has become a modular IDE with support for hundreds of languages. As such, it feels a little like Sublime Text or Atom.

In fact, it’s written in TypeScript and runs on Electron (much like Atom – except that Atom is written in JavaScript)

Because of this, the installer only contains the IDE and basic debugger and you will have to install the .NET Core SDK (which the debugger will connect to, if present) yourself. You’ll also need to install a small number of plugins to get maximum functionality out of VS Code.

I’ve covered getting VS Code set up, with a short list of recommended plugins, in an earlier blog post.

To give you an idea of how good I think VS Code is, I’ve used it to write all of the code for every blog post I’ve written for this blog so far.

Windows

If you’re running Windows, then can use two of the three official tools. Namely: Visual Studio and Visual Studio Code.

Visual Studio

I’ve written about the many Visual Studio editions that are available (and why I’ve chosen to use Visual Studio Community Edition) in an earlier post. As I’ve written about it before, I’m not going to go into a lot of detail in this post. If you’d like to read more about Visual Studio for Windows, then please take a look at my earlier post: Installing and Setting up Visual Studio 2017

MacOS

With MacOS you have two options:

  • Visual Studio for Mac
  • Visual Studio Code

As I’ve said earlier, I’ve been using VS Code on my Mac to build all of the code projects and snippets I’ve used so far for this blog, so I can attest to it’s ability.

Visual Studio for Mac

The first thing that you need to know about VS for Mac is that (at the time of writing this blog post) it is still in beta (Microsoft are calling it “preview”), and is designed for working primarily with Xamarin applications, using the Mono framework (for full .NET projects) and .NET Core for cross platform projects. As such, you can build MacOS, Windows, Linux, Android and iOS apps in one IDE, using either .NET Core or full .NET framework.

Just to reinforce the fact: VS for Mac is currently a beta product.

The latest build of Visual Studio for Mac can be downloaded from the Visual Studio website here. It’s a web-based installer, so it will have to pull down and install packages for the following things:

  • Xamarin
  • Intel HAXM
  • Android SDK
  • Mono

As such, and depending on  your available Internet bandwidth, this could take some time. When I installed VS for Mac, for instance, the installer had to pull down 4 GiB of dependencies and took close to 45 minutes to do so.

It also requires xcode to be installed – this is so that VS for Mac can access certain the MacOS build chain, I believe.

Supported Application Types

Once Visual Studio for Mac has been installed and has been started, the main screen will be displayed:

Visual Studio for Mac - Main Screen
It’s a bit of a mish/mash of xcode and Visual Studio 2017

Visual Studio for Mac supports many different application types, and these can be seen when clicking on “New Project…”

Initially, we’re just going to focus on the .NET Core application types that Visual Studio for Mac supports

Visual Studio for Mac - Supported .NET Core Application Types
Both C# and F# support is present

The fact that VS for Mac supports both C# and F# shows that Roslyn is present in it’s supplied tool chain (because of the presence of Mono and .NET Core), which is handy but shows that VB.NET support is not present.

As you can see, the New Project wizard currently only supports the basic applications types for earlier versions of the .NET Core SDK

i.e. from before the templating engine was released

At the time of writing, VS for Mac doesn’t have built in support for the templating engine, but (as with Visual Studio for Windows), there is nothing stopping you form creating a new project with the templating engine outside of VS for Mac (i.e using the terminal and the dotnet new3 command) and opening the csproj with VS for MAC.

most of the templates don’t create .sln files, but VS for Mac can open the csproj file

When saving a csproj project which does not contain a solution file VS for Mac will create one for you, which is a nice touch.

And exactly how VS for Windows manages these types of projects.

Openning and Debugging

VS for Mac looks a little like a combination between Visual Studio 2017, xcode and Android Studio

Along with design elements of Xamarin Studio

Visual Studio for Mac - Solution open

VS for Mac has syntax highlighting for C#, F#, HTML, Razor, JS and CSS. It also has visual editors for the views and storyboards used in developing for Android and iOS (respectively). It even has support for Gtk#2.0 projects, so you can build native applications for Windows, MacOS and (the supported) Linux distributions with form based UIs.

Now THATS cool

Running the application, opens up the debugging tools. Again, these look a lot like the Visual Studio for Windows controls wearing an xcode-like coat.

Visual Studio for Mac - Debugging

As you can see from the screen shot, VS for Mac has the debugging tools that VS for Windows ships with.

even my favourite: the Immediate Window

VS for Mac and Node, A Caveat

One very important caveat if you want to build any applications which use node is that you’ll have to remember to run

npm install -d

in a terminal opened at the same directory as you package.json file (typically the root of the project which requires node packages) in order to install the npm packages (in the dev environment) before loading and running your project.

Otherwise you’ll unleash the fury of node.

and by that, I mean that you get a System.AggregateException

The error thrown will look a little like this

One or more errors occurred. (Call to Node module failed with error: Webpack dev middleware failed because of an error while loading 'aspnet-webpack'. Error was: Error: Cannot find module 'aspnet-webpack'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/private/var/folders/yj/2mxjdtpj59b471mnh8k1jrqm0000gn/T/tmpj6p5VW.tmp:83:19)
at __webpack_require__ (/private/var/folders/yj/2mxjdtpj59b471mnh8k1jrqm0000gn/T/tmpj6p5VW.tmp:20:30)
at createWebpackDevServer (/private/var/folders/yj/2mxjdtpj59b471mnh8k1jrqm0000gn/T/tmpj6p5VW.tmp:62:26)
at /private/var/folders/yj/2mxjdtpj59b471mnh8k1jrqm0000gn/T/tmpTAtKGe.tmp:113:19
at IncomingMessage.<anonymous> (/private/var/folders/yj/2mxjdtpj59b471mnh8k1jrqm0000gn/T/tmpTAtKGe.tmp:132:38)
at emitNone (events.js:86:13)
Current directory is: /Users/GaProgMan/HelloMvc)"

and it’ll be thrown in Program.cs at the highlighted lines

which makes it difficult to debug, unless you read the exception message

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Hosting;
namespace HelloMvc
{
public class Program
{
public static void Main(string[] args)
{
var host = new WebHostBuilder()
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration()
.UseStartup<Startup>()
.Build();
host.Run();
}
}
}
Publishing to Azure for VS for Mac

VS for Mac has built in support for publishing directly to Azure. The eagle eyed of you may have spotted a tiny “sign in” button on the VS for Mac start screen. You can either sign in to your Microsoft account here, or from the publish option (once a project has been loaded).

One note about the preview: Once you’ve signed into your Microsoft account, you may note a message saying that your pre-release software has an expiration date:

VS for Mac - Profile Expiration
The profile screen within VS for Mac

I believe that the expiration date is tied to the expiration date of my Azure subscription. There doesn’t seem to be any documentation about an explicit expiration date for the preview, but it would make sense that it was time locked.

Publishing

Publishing a project is a matter of right clicking on the project you wish to publish to Azure and clicking on publish.

VS for Mac - Publish Menu Location

If you aren’t signed into a Microsoft account, the sign in window will be displayed:

VS for Mac - Publish Sign in

Once you’ve provided your login credentials, VS for Mac will sign to your account

assuming that your credentials are correct, of course

The sign in step can take a few minutes, so it’s worth being patient with VS for Mac. But eventually you’ll be signed in and you’ll see a list of your active subscriptions:

VS for Mac - Subscription List

One you’ve selected a subscription and clicked the “publish” button, your application will be built, packaged and published to Azure.

The UI will change during the process, in subtle ways:

that very much like xcode

VS for Mac - publishing
Here my app is publishing

Once the application has been published, the UI will change slightly again:

VS for Mac - Published
Horrah!

And a quick visit to the URL

I knew it ahead of time, VS for Mac doesn’t tell you the URL whereas VS for Windows does

shows that the publish action worked:

VS for Mac - published

Conclusion

VS for Mac is a full featured IDE, based on VS for Windows and xcode. Even though it’s still in beta (as a pre-release), it’s very stable and useful.

It won’t replace VS for Windows or VS Code as my daily IDE, but it’ll a strong contender for my main IDE on MacOS, once it has been released as a full product and Microsoft have worked out the pricing strategy for it.

My opinion is that there will be a free tier (if it’s not free to use by default), as it seems to depend on Xamarin Studio (which is free to use). Either way, it will be nice to find out.

I’ll also update this post after 31/05/2017, to share what happens with VS for Mac on that date.

If this post has helped you out, please consider   Buy me a coffeeBuying me a coffee
Jamie Taylor
A .NET developer specialising in ASP.NET MVC websites and services, with a background in WinForms and Games Development. When not programming using .NET, he is either learning about .NET Core (and usually building something cross platform with it), speaking Japanese to anyone who'll listen, learning about languages, writing for his non-dev blog, or writing for a blog about video games (which he runs with his brother)