Session: A lap around Visual Studio 2015

Lap around VS 2015 SessionIn October, I had an opportunity to talk about Visual Studio 2015 at Microsoft Innovation Center (Karachi, PK). I talked mostly about debugging enhancements, C# 6 language enhancements, the new ASP.NET 5 ecosystem including CoreCLR, .NET execution environment (DNX) etc.

Slide deck:

If you are interested in reading about C# 6 stuff, I have written a seperate blog post around that. Playing with C# 6 features

Setting up .NET development environment on OSX

Yes we have lived to day where, this week at BUILD 2015 conference, Microsoft made few interesting announcements related to cross platform where they released a preview distribution of “.NET Core” runtime on Linux/Mac and a cross platform code editor “Visual Studio Code”. How cool is that!

In this post, I am going to setup .NET development environment on Mac. Note that I am after plain .NET core and not ASP.NET.

So let’s get started.

You would need HomeBrew package manager to install .NET version manager, so if you don’t have it already installed, you can paste following script on terminal to install. Further details at

ruby -e "$(curl -fsSL"

Ref screenshot

.NET Version Manager (DNVM)
To get started, we need to setup DNVM using HomeBrew. All you need to do is to install following commands in sequence.

brew tap aspnet/dnx
brew update
brew install dnvm

Ref screenshot

Like suggested, register the command



At this time not all tools are using .NET Core, some of them are still using Mono. Therefore we need to acquire both DNX, Mono and CoreClr. As its mentioned in documentation, mono is the default DNX, so we can acquire it by calling

dnvm upgrade -u 

Next, get the .NET Core DNX

dnvm install latest -r coreclr -u

Ref screenshot

If we now call dnvm list command, we can see the installed DNX.

Visual Studio Code
We will leverage the latest code editor announced by Microsoft. You can use any other editor you like but I am going to use VSCode for this post.

  • Install the Visual Studio Code for OSX.
  • Create a new folder in Finder at your preferred location say “HelloWorldApp”.
  • Run VSCode and open that folder inside editor


Create a new file project.json to specify dependencies/frameworks.

    "version": "1.0.0-*",
    "dependencies": {
    "frameworks" : {
        "dnx451" : { },
        "dnxcore50" : {
            "dependencies": {
                "System.Console": "4.0.0-beta-*"

Now it’s time to write code. Create a new .cs file say Main.cs and start writing C# code, you would notice you are getting intellisense, auto completion for even things like snippets but I will keep VSCode features for another blog post.



Run it
When you are done writing code, go back to terminal and download packages based on project.json. However one thing to highlight here is that restoring packages tool works on mono and has not moved to .net core. So in order to download packages you need to specify that you want to use mono dnx and then run the restore command.

Mac:HelloWorldApp adilmughal$ dnvm use 1.0.0-beta5-11682 -r mono
Mac:HelloWorldApp adilmughal$ dnu restore

Once you have restored the packages, run the app by switching dnx to coreclr and using run command

Mac:HelloWorldApp adilmughal$ dnvm use 1.0.0-beta5-11682 -r coreclr
Mac:HelloWorldApp adilmughal$ dnx . run
Hello .NET on Mac
For Adil's weblog

Congratulations, you just run C# code compiled by Roslyn compiler, executed by .NET Core CLR on OSX.

UPDATE: coreclr version 1.0.0-beta5-11682 has a bug where when you try to run the code, roslyn throws exception. This issue has been reported on github, as a workaround you can download and use version 1.0.0-beta5-11657 which works fine!

dnvm install 1.0.0-beta5-11657 -r coreclr -u
dnx . run

Hope this helps!

Where is Windows 8 Store App Suspend Resume Shutdown Option in Visual Studio 2012 Ultimate?

If you have been developing Windows 8 apps using Visual Studio 2012 Express and recently started working on Visual Studio 2012 Ultimate, it might take you few minutes to figure out where is “Suspend”, “Resume”, and “Suspend and Shutdown” option during debugging. 

Because you may know that Visual Studio is a huge product and each express version is tailored as per its usage. So default toolbar of VS ultimate does not include this option enabled.
So all you have to do is to select “Debug Location” under View -> Toolbar -> Debug Location. 

That’s it. Now you can see the “Suspend” etc. option in toolbar. 

Just thought to share this small thing as it took my couple of minutes to figure this out.

Restoring NuGet Packages for External Dependencies

NuGet is an excellent visual studio extension and answer to dependency management in .NET. It makes super easy to manage third party libraries. If are working on .NET and have not noticed NuGet, you are missing something very useful, read about NuGet here.
If you have been working on Java platform then this is something similar to Maven dependency management 
In early days… developers used to commit third party libraries (.dlls) into source control, those who don’t tend to get part of GAC. So we have seen developers maintaining folders like Lib, External Libraries etc. as part of repositories or branches into source control. This approach is easy but have it’s own limitation such as version management and manual maintenance etc.
Then comes the NuGet Package Manager to resolve dependencies. It’s has benefit of integration with Visual Studio and manages packages over just libraries (dlls). It creates a “packages” folder to download all external libraries and their dependent libraries along with version management.

NuGet Package Manager
With that developers started committing “packages” folder into source control to share external dependencies across team or contributors and that is fine but over time this would make distributed versioning control systems like Git to grow significantly large due binaries.

Restoring Packages Automatically

With NuGet 2.0, now you don’t need to commit “packages” folder and let NuGet download and restore missing packages when you build solution
For NuGet to do this, you need to take few steps.
1) Check “Allow NuGet to download missing packages during build” in Tools -> Options -> Package Manager
2) Enable NuGet Package Restore
That will do the needful, it would create a nuget folder as part of your solution file and will now automatically restores the missing libraries. What happens is that at the time of build, NuGet reads the packages.config file, identify the missing ones and download the missing packages with mentioned version from NuGet gallery.
This way you don’t have to commit your “packages” file into source control and yet easily maintain dependencies.
Have you tried NuGet Package Manager, dear reader?

MVP Summit 2013 Summary and Take Away

Hello folks!
I am at the Seattle Airport (SEATEC) leaving for home via Dubai waiting for boarding to start. So I thought to utilize the time and share my summit experience.
As I mentioned in a blog post earlier, this was my third time attending the MVP Summit and yet it’s always good to attend the summit, interact with product teams at Microsoft and take something out of it.

Complimentary copies from Practices & Patterns teamTypeScript with Mads togerson
Scott Hanselman on Future of ASP.NETSummit attendee party
But I am not going to share about usual happenings occurred at Summit instead I would like to share some technology updates and good tools I came across at MVP Summit. While much of the content at MVP Summit was under NDA (Non-Disclosure Agreement) yet there are many things that I can share with you and are publicly available as of today. I am going to glimpse through them.

1) ASP.NET and Web Tools 2012.2 Released

One of the recent update announced this week from ASP.NET team is the tooling update for web development. This includes bunch of updates such as support of LESS framework (.less extension), enhancements in Web API, SignalR templates, new template for Facebook application and updated reference to libraries. Note that some of the feature I mentioned in my earlier blog post as part of Web Essential extension are now graduated to Visual Studio as part of this update. Check out detail update on ScottGu blog.

2) PerfView

PerfView is a performance-analysis tool that helps isolate CPU- and memory-related performance issues. It’s a very handy tool if you are into to investigating performance bottle necks so things like blocking time, memory allocation, GC collection time etc. can be identified from using this tool.

This tool is developed by CLR team. It doesn’t have very good UI, but I am impressed by its data and benefits. Also please note that with default options, it’s not very heavy and can be used in production environment as well. Summary: If you are facing performance challenges in your .NET server side apps, give it a try.

3) Visual Studio DevLabs Extensions

DevLabs extensions are experiments/trials of potential upcoming features in Visual Studio. But guess what? you can try them today. I can’t explain much about this, you can check it out on Visual Studio Gallery. Please note that this is in addition to Productivity Power Tools available for Visual Studio which I mentioned in an earlier blog post.
View DevLabs Extensions on Visual Studio Gallery

4) TypeScript

TypeScript is typed super-set of JavaScript and it helps you write JavaScript with static type checking and some sort of benefit of static typed language. For example, it let’s you define interfaces, object type, method type rather than everything as ‘var’. If you write a lot of JavaScript, consider evaluating it. However it’s still in preview version.

Tutorial | Playground

That is all for now, the boarding is about to start in next five minutes.

Keep Exploring!

Web Development Goodies in Visual Studio 2012

Visual Studio 2012 and it’s extensions ecosystem brings excited enhancements for web developers. I am glad to see that web platform team is giving attention to open source, adapting industry trend faster than ever and making developer life easy and standard-complaint.
In this post I am going to share some of web development goodies that ships with Visual Studio 2012 (including Visual Studio Update 1 along with ASP.NET and Web Tools 2012.2 RC update) as well as some popular and must have extensions.


HTML5/CSS3/JavaScript Editor Enhancement Support:


The Visual Studio 2012 IDE includes great tooling update for supporting HTML5/CSS3/JavaScript intellisense. This includes new HTML5 tags and CSS3 properties. This helps in writing code relatively faster.

And who said to work on color hex codes? CSS color picker is now supported directly in CSS editor in Visual Studio. Makes it super easy to select and customize colors.
Further, JavaScript editor has improved significantly supporting better intellisense including for jQuery library.

An important point for JavaScript intellisense is to add reference path to js files. If you have noticed in ASP.NET MVC 4 project templates there is a js file “_references.js”

This file add references of common scripts referred in project to support their intellisense. However the reference to “_references.js” is added as global references in Visual Studio -> Options -> Text Editor -> JavaScript -> Intellisense -> References

It’s not the case that you cannot develop HTML5/CSS3 application without it. It’s just a editor support. Part of the features were also made available for Visual Studio 2010 SP1.

Page Inspector:

Page Inspector is a new feature in Visual Studio 2012. If you have developed web layout using HTML/CSS, you must have came across situation to give hit and try web layout for example, setting the right position, padding, selecting the color and see what best suited. I previously used to do this using FireBug, a Firefox browser extension. Page Inspector one feature is to answer this scenario. Scott Hanselman has produced a great animation to show what page inspector does. So I have copied it below.

Paste JSON as Classes 

A new feature to convert JSON into classes. A copied JSON can be pasted using Edit -> Paste Special -> Paste JSON As Classes

{"menu": {
"id": "file",
"value": "File",
"popup": {
"menuitem": [
{"value": "New", "onclick": "CreateNewDoc()"},
{"value": "Open", "onclick": "OpenDoc()"},
{"value": "Close", "onclick": "CloseDoc()"}

is pasted as



NuGet is a popular extension of Visual Studio that makes it easy to manage third party libraries and dependencies in Visual Studio. In fact it’s so good that it now ships with Visual Studio 2012.
You can open up NuGet Package Manager using user interface or Package Manager console window available in View -> Other Windows -> Package Manager Console.

The way it works is that if you develop third party libraries and want to share with other developers then you create a package in NuGet. Other developers can retrieve package from NuGet repository and download the library along with required configuration, such as entry in web.config. See an example blog post, where I demonstrated configuring ELMAH using NuGet.

Web Essentials

If you are currently working on web application front-end in VS and you don’t have web essential extension installed then you are simply missing something essential. Web Essential is an visual studio extension created by Mads Kristensen and its like playground for the web tools team. It has a bunch of great features which provide help in development, I am just going to highlight few of them. Complete feature set is explained at
LESS Editor/Preview: LESS extends CSS with dynamic behavior such as variables, mixins, operations and functions. If you write CSS and don’t know about LESS, you are missing something really handy. Web essential extension supports .less extensions file in a way that it previews the output CSS and some refactoring as well.

Vendor Specifics Generation: Many of the CSS3 properties required vendor specifics properties to work across web browsers. These include -moz, -webkit, -ms and -o. Consider following example below:

would result in:
There are many other goodies for web developers, TypeScript, CoffeeScript, advance intellisense in HTML, JS and CSS editors, ZenCoding etc. Go get it. This extension is also available for Visual Studio 2010 as well.

Productivity Power Tools

Productivity Power Tools is another must have extension of Visual Studio developed by some engineers at Microsoft Visual Studio team but they are not yet part of the Visual Studio official shipment. Some of the feature has graduated to official shipment over the time yet there are many good to have feature in productivity power tools. Some of the features I like are:
  • Ctrl + Click for Go To Definition
  • Remove unused Using from code editor context menu
  • Power Commands
  • Quick Tasks. Quick Tasks is nothing revolutionary rather it brings out most commonly used settings in Visual Studio to your finger tips. (see snapshot below)

For details, check out the Productivity Power Tools page on Visual Studio Gallery. This extension is also available for Visual Studio 2010 having relatively different feature set.

Open Source Web Platform

Over the last two years, I am glad to see the interest and shift of Microsoft Web and Azure team towards open source. Since then they have started publishing some of their source code on codeplex and github. This really helps developer community in contributing towards frameworks and understanding code which is good to have in case you faced any issue and wanted to know internals.
That is all for now. I have tried to highlighted some of good stuff available in Visual Studio ecosystem, which are helpful for web developers. I recommend you to check out details of each item.
Happy Coding!

Visual Studio Commands

***This blog post is part of the series Visual Studio underutilized features***

Visual Studio Commands

Almost all interactions in visual studio in form of menus, dialog boxes, windows, toolbars etc. are executed using commands. Some of them are even available from command line argument. For instance, you can build your solution from “Developer Command Prompt for VS2012” that ships with visual studio tools, using command:
> devenv /Build HelloWorld.csproj
To get good understanding on built-in commands in visual studio IDE, open up the “Command Window” in visual studio from (View -> Other Window -> Command Window), you will notice a command prompt. All your menu items, toolbar items, editor context menu, nearly everything that can be done using user interface can be actually executed via commands and you can validate this in “Command Window”

For instance, try executing a command e.g. File.NewProject, the visual studio will open the file new dialog. The same command is executed when you select File -> New Project or press Ctrl+Shift+N.
The key point here is to understand that visual studio IDE uses centralize command system binded with user interface element. If you have idea about command pattern or you have worked with commands in Windows Presentation Foundation, you must be having good understanding of this concept.
Besides learning shortcuts, Command window is quick way to execute commands in Visual Studio instead of achieving the same by navigating though menus with mouse intervention. This saves a lot of time, part of the reason is because it’s difficult to memorize many shortcuts.
Visual Studio 2012 provides a great alternative in form of “Quick Launch” to quickly search/navigate to different commands, menus, dialogs, tool windows etc. However, I think that Quick search is a great alternative available in Visual Studio 2012

External Tools and Commands

Another nice option that visual studio provides is to create an external command that can be bind with an external tools.  You will find “External Tools” option under “Tools” menu.
You will observe that there is already some list of pre-defined external tools defined with associated commands along with the arguments etc.

Here we can create our custom menu item. For example, I want to view solution (.SLN) file in editor. Out of box solution context menu does not ship with item to open solution file in editor, however you can do this from windows explorer/directory. So let’s add a new external tool with title “Open Solution File in Notepad” and associate command of notepad.exe. The arguments will be $(SolutionDir)$(SolutionFileName) which together refers to complete path to solution file.
What it does that given any solution open, it will look run the notepad command with solution file path as argument. That’s it. Now you will see the newly added item in Tools menu.

So, if you haven’t, go ahead and try using command window.

Visual Studio Underutilized Features

Visual Studio is a powerful IDE and have grown remarkably over the last decade. Perhaps used by great number of developers out there for building products for Microsoft platform yet I have came across so many developers who haven’t fully explored IDE features yet and are not utilizing all goodies in it.

Do you know that?
– There are around 4500 Commands in VS
– Over 750 key bindings
– More than 100 tool windows
– A large number of extensibility areas

I believe that it is essential for every software craftsman to master its tool set.

So I have decided to write some blog posts, as shout out from my side, mentioning worth while features, tips and stuff under the hood. I will add the link to posts below.

If you have any tip or feature you would like to share, please feel free to add in comments below or contact me via my blog.

Thanks, stay tuned!

Search using Navigate To

Navigate To is a great feature that lets you search and navigate to symbols especially when you are not sure for what exactly you are searching for. You can open up ‘Navigate To’ dialog either from menu Edit -> Navigate To or using shortcut Ctrl + , (comma).
For example, consider we are looking for controller for shopping cart but not exactly sure of what were the name. So we what we can do we write “cart” “controller”, for which it would come up with matching results containing ‘ShoppingCartController’ which is exactly we were looking for.

Note: For this blog post I have used MvcMusicStore, an open source project for ASP.NET MVC to demonstrate feature

Few things to remember:

  • The results does not include namespaces or local variables however it may include definition, file names etc. 
  • A search string is case-sensitive, if search term has character in uppercase otherwise it would be case-insensitive
As a developer, it’s better for me to avoid mouse intervention and perform quick navigation. Now if I want to jump to any file, I can quickly open up the code element I want to edit using Ctrl+, (comma) and typing the file name. This is fast and saves a lot of time in avoiding scrolling through solution explorer especially when you have many projects as part of your solution.
“Navigate To” feature was first shipped with VS 2010 however I have observed that many experienced developers are not utilizing this feature to increase their everyday productivity. 
So gets your hands on this feature and start using Ctrl + (comma) for search or quick navigation to different types and its symbols.

Why am I excited about Roslyn Project

Microsoft announced Community Technology Preview (CTP) of Roslyn project during BUILD 2011. I am really excited about the Roslyn project (and I will tell you why soon…).

Roslyn? Isn’t it name of a city?

Well you are right and many of Microsoft product code names are now based on city/town names mainly due to copyright issue. If you don’t have idea and you love to dig in languages/compilers, it’s a MUST SEE for you.

The concept is simple that traditionally compilers are kind of black box thing where we provide source files as input and it provide assemblies/DLLs/exe as output. The Roslyn project is all about opening the black box of compiler and allowing us to get internal language object model and things such as syntax tree etc. through Compiler APIs. The objective of the project is to rewrite the VB and C# compilers and language services in managed code. See slide below from Anders’ talk at BUILD 2011.

The Roslyn Project

Interested? Check out for project overview document and to download the available bits. For further introduction, please read Introducing the Microsoft “Roslyn” CTP on Visual Studio blog.

Roslyn APIs

Roslyn APIs exposes four collection of APIs. You can read details of each API in project overview document (from where the image below is taken).

Roslyn APIs Collection

The Services API have dependency over Visual Studio SDK and contains Visual Studio IDE features, such as intellisense, code refactoring and formatting etc.

Before reading on, if you haven’t installed Roslyn binaries, go ahead download them and skim through overview document.

Exciting Part?

If you have been kind of student, who enjoyed compiler construction course(s) during undergrad and really enjoy in going deep into mechanics, then you would definitely love exploring Roslyn APIs. This is because the rewriting of compiler and exposed APIs would allow you to understand the syntactical and semantic model of your code.

Roslyn Core APIs

With this you can not only generate code on fly but also REPL (read-eval-print-loop) operations can be done. Plus you can visualize/parse your existing code and see what syntax tree it has generated. For example, consider the following code snippet using Roslyn API:

SyntaxTree tree = SyntaxTree.ParseCompilationUnit(
@"using System;
namespace HelloWorld
class Program
static void Main(string[] args)
{ Console.WriteLine(""Hello, World!""); }

Syntax Visualizer

If you traverse/print tree or use Roslyn Syntax Visualizer control, you would get to know the underlying syntax tree structure and its components. Using the above code, the syntax tree has parsed the code and decomposed it into tokens, nodes, and trivia. The debugger visualizer (see image on left) will help you understand the syntax tree generated. This debugger is of great aid if you are developing any IDE extension using Roslyn API.

Please note that syntax visualizer control is available with samples, along with source code, in Samples folder created when you downloaded Roslyn bits. Currently there are some known issues with this control and workaround (code modification) has been explained at Roslyn forum “Known Limitations and Unimplemented Language Features”.

Another fun point is Workspace API which allows you to programmatically do stuff with your solution, projects, assemblies and documents. As a very simple example, consider the following code snippet:

IWorkspace workspace = Workspace.LoadSolution(@"<%PROVIDE PATH OF .SLN FILE");
ISolution solution = workspace.CurrentSolution;

foreach (IProject project in solution.Projects)
foreach (IDocument document in project.Documents)

And if you are interested to create visual studio extension for developers productivity, Roslyn Service APIs are going to provide you breakthrough. Try exploring Service APIs project using “Roslyn Installed Templates”. Surely, you can VS extensions directly using SDK but with the power of Roslyn, you can get into the code tree and provide intelligent refactoring and productivity aids to developer.

Roslyn Templates 

Do I need Roslyn?

You need to explore Roslyn APIs,

  • if you do a lot of heavy lifting with Reflection in the .NET Framework. At my previous employer, when we used to develop Form Designer for BPM Suite, much percent of our code was based on Reflection due to dynamic nature of the application
  • Already using Visual Studio SDK
  • Interested to understand compiler services
  • Interested to create Visual Studio extensions

But there is much more in Roslyn and I would try to share my experience of whatever I experiment with Roslyn APIs in spare time. If you are working on Roslyn, please do share your experience in comments below.