Today’s header image was created by Annie Spratt, the original source for the image is available here
This month Visual Studio 2017 was released. Microsoft celebrated it’s release by having a live streamed release event, too.
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 might be left wondering which Windows tools we can use to develop our .NET Core applications.
Currently, we have a choice between:
- Visual Studio 2015
- Visual Studio 2017
- Visual Studio Code
What should we be using to develop our .NET Core applications?
The first thing I feel that I need to say is that I wouldn’t recommend VS 2015 going forward, as it only has support for the earliest .NET Core toolsets and SDK versions.
I mean, you can still use it. You just wont have access to MSBuild, .NET Core 1.1, .NET Standard 2.0 (when it’s released), and all the cool new features in VS 2017
That being said, it’s still a tricky question because it relies so heavily on your individual requirements.
Most of the developers I’ve worked with prefer to use a fully featured IDE with rich tooling support. This has meant that, nine times out of ten, those developers have used a version of Visual Studio.
In this case I would recommend Visual Studio
However, there are many developers out there who want their tools to be a light and quick as possible
That’s not to say that Visual Studio isn’t quick
and as such, they will stick to using the most lightweight configuration of the tools available. A set of tools which cut out as much of the complexity as it possible whilst still offering enough to be an IDE, including a debugger and connections to source control built in.
Here’s where I would recommend VS Code
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.
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 the plugins you might need 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.
Visual Studio has a number of licensing options
Just to make your choice a little more complicated 😛
as Visual Studio is Microsoft’s premier development product. You’ll need to take some time and figure out which version of Visual Studio best fits your needs. To make this easy, Microsoft have put together a comparison page for you to compare all of your options.
I use Community Edition, as I’m only ever working on Open Source or free apps. the short (and horrendously over simplified) version is that if you want to make profit from your apps, you need to use one of the paid versions of Visual Studio.
Please read through the comparison page for the full details.
But for what I do, Community Edition is fine.
Installing Visual Studio 2017 Community
VS 2017 (regardless of flavour) is incredibly simple to install.
The web installer available here, and the installation wizard is really simple to follow:
One thing to bear in mind with the web installer is that it will pull down installation packages from the web. I didn’t keep a log of the total downloaded package size when I installed, however I installed the following components:
- .NET desktop Development
- ASP.NET and web development
- .NET Core cross-platform development
and the total install size was around 4.8 GB. the packages pulled from the web were a lot less than that (although I can’t say what the size was for sure), as VS Community was fully installed in less than half an hour.
And I only have a moderately fast Internet connection 😛
This was a personal choice, and as such you can ignore it, but when I checked the .NET desktop development option the “.NET Core 1.0 – 1.1 development tools” option is not checked by default (check in the summary, on the right-hand side of the installer).
I checked this box, because I wanted support for the .NET Core 1.0-1.1 tooling for .NET desktop apps, but you may not want this.
I have yet to build any desktop specific apps using .NET Core, or pulling in .NET Core libraries, but I want to in the future.
Let’s say that you don’t run Windows, but want to use Visual Studio 2017.
As a real example, I do the majority of my .NET Core development on one of two machines running very similar operating systems:
- MacOS Sierra
- Ubuntu 14.04
Similar in that MacOS is based on Unix, and Ubuntu is a distribution of Linux (a free, open source re-implementation of the Unix kernel)
Both are supported target platforms for the .NET Core SDK, but neither are supported platforms for Visual Studio 2017. So what are my options:
- Dual Boot/Bootcamp
- Run a VM on my host OS
Dual booting (or using Bootcamp on MacOS) is a legitimate option with two draw backs:
- Longer boot time
- Hard drive space requirements
Regardless of whether you run a Linux distro or MacOS, dual booting slows your initial boot time considerably.
I dual booted Windows and Debian throughout university, I remember the bad days – and that was before UEFI came along and made it harder to do
This means that your lightening fast machine isn’t as lightening fast off the mark anymore. You’re also using two, three (or more!) times as much storage space for an extra operating system (and all the drivers and software that you need), one which you’re only using half the time.
Let’s be honest, we’re all still going to use our daily driver OS for most tasks
If you’re still running a mechanical hard drive, or can afford a massive SSD,
I have one install of Windows 10 that takes up the majority of a 250 GB SSD because of all of the software I need and Windows updates
this second point wont be a huge issue. But for those of us who can’t afford massive SSDs or have a system which cannot be easily upgraded, we’re stuck with the OSs we already have.
This is where Azure can help. But you need to know that there is a potential cost with this option.
The following is meant as a guide as to how to set up an Azure account with a Windows 10 virtual machine with Visual Studio pre-installed. This is entirely optional and you should only do it, once you have weighed up the pros and cons.
It is your decision as to whether you should create an Azure VM, not mine.
I’ll preface this with saying that Azure can be very expensive, if mismanaged. But if you stay on top of it, then it should be quite manageable.
Azure is a cloud computing service offered by Microsoft. It supports web hosting, app hosting, VMs a whole host of other services. There’s a cost involved (depending on which services you want to use, and the hardware you want them to run on), but you get some free resource credit to get you up and running when you create your account.
Azure, unless you’re willing to pay for it, isn’t a permanent solution. But it can be viable and cheap (if managed well).
Creating a free account
The first thing that you need to do is go and read all of the documentation regarding pricing over at the Azure website, as it’s important to know how much a hosted VM is going to cost.
seriously, this is an important step. You paying any bills that you incur is your responsibility.
As a side note: one of the cool things about Azure (especially if you choose a pay-as-you-go option), is that you can set up alerts and have your VM stop and deallocate
saving it’s data and session
as you get close to a certain usage limit.
Once you’ve done that,
and if you’re ok with the potential cost of your hosted VM
you can create a free account by clicking on the “Free account” or “Start for free” buttons.
A free account get’s you £150 of credit (if you’re in the UK anyway) for your account, which is more than enough to try out a hosted VM
and a few other services, if you want to try them
The account wizard is similar to most others for online accounts (Amazon, Gmail, etc.), so follow that all the way through.
Adding a Subscription
Once you’ve created your account, and it has been verified and activated
This can take a few minutes, as there’s some backend processing that Microsoft need to do
you can sign into the azure portal to get started.
The first thing you’ll need to do (if you didn’t do it during the set up) is create a subscription.
Click in the Subscriptions box and you’ll be taken to a page which will list all of your subscriptions.
Clicking on the “Add” button will take us to the Azure Subscription options page.
I would recommend the Pay-As-You-Go Dev/Test offer, as this gives you access to Visual Studio and is designed to get developers working int he cloud. But make sure that you read through all of them
Reading through the “Learn More” pages too
and pick one that suits your needs.
Adding a VM
Once you’ve added a subscription, its time to add a Virtual Machine. On the left-hand menu of the Azure portal, click on “Virtual Machines”.
Clicking the “Add” button will bring in the compute partial.
In the search box at the top of the page enter “Visual Studio”. There will be a whole bunch of options to choose from, I would recommend either:
- Visual Studio Community 2017 on Windows 10 Enterprise N
- Visual Studio Enterprise 2017 on Windows 10 Enterprise N
Both of these are 64 bit builds of Windows 10, with the latest updates. The only difference is the version of Visual Studio 2017 that you want to use. Again, this is completely up to you.
Clicking “Create’ will take you through the process of creating the VM instance and all of the supporting resources.
Once the setup has completed, go back to the dashboard (by clicking on the ever present “Microsoft Azure” in the top left corner of the screen), and you’ll see all of your new resources.
Starting and Stopping a VM
From the dashboard, click on your Virtual Machine instance
In the above screenshot, mine is called “MainVM”
and you’ll be presented with a lot of information on it.
To start the VM instance you need only click on the “Start” button and wait a few moments.
From this point onwards, until you stop the VM, it will be costing you Azure credit.
Remember that you get a fair amount when you create your free account.
Once the Windows installation has booted on your VM (it boots in real time, just as a local installation of Windows does), the Connect button will be available.
More on that in a moment
Stopping a VM is a matter of hitting the “Stop” button. However, if you have unsaved work on the VM, it will be lost, as this will shut down the VM (if it that hasn’t already been done) and deallocated it from your running resources.
Again, until your VM has been deallocated, it will be costing you credit to keep running. It’s important to remember to do this bit.
Connecting to a VM
Connecting to a VM requires a remote desktop client application to be installed on your host machine. Windows 10 has the Microsoft Remote Desktop client installed by default.
For MacOS, I would recommend the Microsoft Remote Desktop client, as it’s simple to set up and running.
Connecting to your Azure remote desktop requires you to click on the “Connect” button, once your VM instance is running
Disconnecting is a case of closing your Remote Desktop Client.
But you probably knew that already.
Remember to Stop (see previous section) your VM when you’re done with it, otherwise it will remain allocated and continue to cost you, even though you’re not running it.
Hello, World in VS 2017
Now that we’ve got access to a version of VS 2017, we can start building something with it. For now
seeing as how this blog post has gone on way too long already
we’ll build a “Hello, World” application and call it a day.
We’ll build something more interesting next time, honest.
Start Visual Studio and go to File > New > Project
In the New Project Wizard, make sure that you select .NET Core (under Visual C#), and give the project a useful name.
Once the project has been created, we need to make a slight change to the program.cs file. Make it match this one:
|static void Main(string args)|
|Console.WriteLine("Hello World from VS 2017!");|
After you’ve saved the program.cs file, hit the run button and VS 2017 will compile and run our shiny new project
It’s not the best project in the world, it’s just a tribute
After compiling, Visual Studio will run our new application and you should get a console window similar to this one:
The reason we included the Console.ReadLine() was to trap execution of our application. Without it the console would appear, our message would be written to the console, our application would return 0, and the console window would close.
And there you have it. We have VS 2017 installed
by heft or weft
and we can finally start working on our .NET Core applications across all available platforms. Which is what we’ll do next time.