Visual Studio is an amazing bit of software. If you have been using Visual Studio for a number of years, you will certainly agree that the IDE offers developers a host of tools and features to make them more productive. You will also be aware that it has grown a lot during the past couple of years and is an absolute powerhouse when it comes to providing tools to develop world-class software.
The evolution of Visual Studio
Release | Version | .NET Framework | Release Date |
---|---|---|---|
Visual Studio 2019 | 16.0 | 3.5–4.8 | April 2, 2019 |
Visual Studio 2017 | 15.0 | 3.5–4.7 | March 7, 2017 |
Visual Studio 2015 | 14.0 | 2.0–4.6 | July 20, 2015 |
Visual Studio 2013 | 12.0 | 2.0–4.5.2 | October 17, 2013 |
Visual Studio 2012 | 11.0 | 2.0–4.5.2 | September 12, 2012 |
Visual Studio 2010 | 10.0 | 2.0–4.0 | April 12, 2010 |
Visual Studio 2008 | 9.0 | 2.0, 3.0, 3.5 | November 19, 2007 |
Visual Studio 2005 | 8.0 | 2.0, 3.0 | November 7, 2005 |
Visual Studio .NET 2003 | 7.1 | 1.1 | April 24, 2003 |
Visual Studio .NET 2002 | 7.0 | 1.0 | February 13, 2002 |
Visual Studio 6.0 | 6.0 | N/A | June 1998 |
Visual Studio 97 | 5.0 | N/A | February 1997 |
Installing Visual Studio
What workloads are
Exploring the IDE (integrated development environment)
Existing and new features available in Visual Studio 2019
Productivity tips
If you are using a macOS or a Windows machine, Visual Studio will happily run on both. Let us see where to find the Visual Studio Installer and get going.
Installing Visual Studio
At the time of this writing, Visual Studio 2019 is available for Windows machines as well as for macOS machines. You can download Visual Studio 2019 for Windows from https://visualstudio.microsoft.com/vs/, and if you are on macOS, you will need to head on over to https://visualstudio.microsoft.com/vs/mac/ to download the installer.
If you would like to compare the Visual Studio 2019 versions, you can have a look at https://visualstudio.microsoft.com/vs/compare/ for a detailed comparison. The bottom line is that if you want Visual Studio 2019 for free, download Visual Studio Community 2019.
Visual Studio Community 2019 is aimed at students, open source, and individual developers. The paid tiers include Visual Studio Professional 2019 which is aimed toward small teams and Visual Studio Enterprise 2019 aimed at large development teams.
Microsoft specifies enterprise organizations as those having more than 250 PCs or more than $1 million US dollars in annual revenue.
Let us have a brief look at the recommended system requirements for installing Visual Studio on your machine. For a comprehensive list, browse to https://docs.microsoft.com/en-us/visualstudio/releases/2019/system-requirements and have a read through that.
Visual Studio 2019 System Requirements
The system requirements for installing Visual Studio 2019 might differ from those of previous versions of Visual Studio. Refer to the documentation on https://docs.microsoft.com to review the system requirements for previous versions of Visual Studio.
Visual Studio Enterprise 2019, Visual Studio Professional 2019, Visual Studio Community 2019, and Visual Studio Team Foundation Server Office Integration 2019 all support the following minimum system requirements.
Operating Systems
Windows 10 version 1703 or higher
Windows Server 2019 – Standard and Datacenter
Windows Server 2016 – Standard and Datacenter
Windows 8.1 with update 2919355
Windows Server 2012 R2 with update 2919355
Windows 7 SP1 with latest Windows updates
Hardware
1.8 GHz or faster processor (quad-core or better recommended).
2 GB of RAM (8 GB of RAM recommended).
2.5 GB of RAM minimum if running on a Virtual Machine.
Between 800 MB and 210 GB of available hard disk space (depending on installed features, 20–50 GB of free space is typically required).
For improved performance, install Windows and Visual Studio on an SSD.
Minimum display resolution of 720p (1280x720) but works best at WXGA (1366x768) or higher.
Supported Languages
English
Chinese (Simplified)
Chinese (Traditional)
Czech
French
German
Italian
Japanese
Korean
Polish
Portuguese (Brazil)
Russian
Spanish
Turkish
Additional Notes
Administrator rights are required to install Visual Studio.
.NET Framework 4.5 is required to run the Visual Studio Installer and install Visual Studio.
Visual Studio requires .NET Framework 4.7.2 and is installed during setup.
Using Workloads
After Visual Studio has been installed, you can customize the installation by selecting feature sets, also known as workloads. Think of workloads as a collection of individual features that belong together. This allows you to easily modify Visual Studio to include only what you need.
The workloads also contain tabs, namely, Workloads, Individual components, Language packs, and Installation locations. If you needed to install an additional component such as Service Fabric Tools, you can do so by selecting the component on the Individual components tab.
This will modify your existing installation of Visual Studio 2019 and apply the changes you selected.
Exploring the IDE
The Visual Studio IDE is full of features and tools that help developers do what they need to do, efficiently and productively. Developers start off creating one or more projects that contain the logic for their code. These projects are contained in what we call a solution. Let’s have a look at the Solution Explorer first.
The Solution Explorer
In Visual Studio, the notion of solutions and projects is used. A solution contains one or more projects. Each project contains code that runs the logic you need in order for your application to do what it does.
ShipmentLocator – WinForms application – C#
ShipMethodLogic – Class Library – C#
Tracking – Class Library – VB.NET
Of particular interest, you will notice that you can have a solution that contains a mix of C# projects and VB.NET projects. You are therefore not limited by a particular language and can create applications containing a mix of .NET languages.
The reason that we can mix .NET languages in the same solution is due to something we call IL (Intermediate Language). IL is used by the .NET Framework to create machine-independent code from the source code used in your projects.
The WinForms application will contain the UI needed to track and trace shipments. In order for the WinForms application to be able to use the logic contained in the other two class libraries, we need to add what is called a reference to the other projects.
Under the Projects tab, you will find the other two Class Library projects in your solution. By checking each one and clicking the OK button, you will add a reference to the code in these projects.
- 1.
Preview Selected Items
- 2.
Properties
- 3.
View Code
- 4.
Show All Files
- 5.
Collapse All
- 6.
Pending Changes Filter
- 7.
Toggle between Solution and Folder views
I will not go through each one in detail, but of particular interest, you will notice that the Show All Files will display unnecessary files and folders such as the bin folder in your Solution Explorer. Go ahead and click the Show All Files button, and look at the Solution Explorer again.
By looking at Figure 1-11, you can see that it now displays the bin folder and the obj folder. These folders are not necessary for your code but are important to your solution.
The obj folder contains bits of files that will be combined to produce the final executable. The bin folder contains the binary files that are the executable code for the application you are writing.
This is a nice shortcut for anyone needing to navigate to the location of the Visual Studio files in the solution.
Build Solution will do an incremental build of the solution of anything that has changed since the last build.
Rebuild Solution will clean the solution and then rebuild the solution from scratch.
Clean Solution will only clean the solution by removing any build artifacts left over by the previous builds.
If you are receiving funny build errors that do not seem to be errors in your code editor, try cleaning your solution and building it again.
Toolbox
The Toolbox allows you to add controls to your application such as text boxes, buttons, drop-down lists, and so on. This allows developers to design the UI of the application by dragging and dropping the relevant controls on the design surface.
You can also open the Toolbox by clicking the View menu and selecting the Toolbox menu item. It is worth noting that for some project types, you will not see any items in the Toolbox.
Rename an item
Choose additional items
Remove items
Move items up and down
Sort items
Add a new tab
If you have third-party controls installed such as DevExpress or Telerik, you will find the controls specific to the installed components under their own tab in the Toolbox.
The Code Editor
The location data will be hard-coded in a Location class that was added to the project.
After adding the UI elements to the designer, swing over to the code window for the main WinForm application called Form1.cs. Add the following code in Listing 1-1 to the code-behind.
The Code-Behind Form1.cs
You are able to navigate between the warnings and errors by clicking the left and right arrows. You can also perform a code cleanup by clicking the little brush icon or by holding down Ctrl+K, Ctrl+E.
With all the code suggestions applied, Visual Studio displays a clean bill of health in the status indicator at the bottom of the code editor.
Navigating Code
Visual Studio provides several features allowing developers to navigate code throughout the solution. Knowing how to use these navigation features will save you a lot of time.
Navigate Forward and Backward Commands
You can also find these commands from the View menu under Navigate Backward and Navigate Forward.
Navigation Bar
It is useful to take note that members defined outside the current code file will be displayed but will be disabled and appear gray. You can cycle through the drop-down boxes in the navigation bar by pressing the tab key.
Each drop-down also has its own individual function. The left drop-down will allow you to navigate to another project that the current file belongs to. To change the focus to another class or type, use the middle drop-down to select it. To navigate to a specific procedure or another member in a particular class, select it from the right drop-down.
Find All References
Change the search scope
Copy the selected referenced item
Navigate forward or backward in the list
Clear any applicable search filters (filters are added by hovering over a column in the results window and clicking the filter icon that is displayed)
Change the grouping of the returned results
Keep the search results (new searches are opened in a new tool window)
Search the returned results by entering text in the Search Find All References text box
Hovering your mouse of a returned search result will pop up a preview screen of the code. To navigate to a search result, press the Enter key on a reference or double-click it.
Reference Highlighting
Change the color to yellow and click OK. All the references to the variable you just selected will now be highlighted in yellow.
Go To Commands
As can be seen in Figure 1-28, a window pops up that allows you to jump to a specific line of code. This is incredibly useful when trying to explain something to another developer not sitting in the same room as you.
Ctrl+G – Go To Line which allows you to move to the specified line number in the currently active document
Ctrl+T or Ctrl+, – Go To All which allows you to move to the specified line, type, file, member, or symbol
Ctrl+1, Ctrl+F – Go To File that allows you to move to a specified file in the solution
Ctrl+1, Ctrl+R – Go To Recent File allows you to move to a recently visited file in the solution
Ctrl+1, Ctrl+T – Go To Type allows you to move to a specific type in the solution
Ctrl+1, Ctrl+M – Go To Member allows you to move to the specific member in the solution
Ctrl+1, Ctrl+S – Go To Symbol allows you to move to the specific symbol in the solution
Alt+PgDn – Go To Next Issue in File
Alt+PgUp – Go To Previous Issue in File
Ctrl+Shift+Backspace – Go To Last Edit Location
While typing Ctrl+1 might seem slightly finicky, you soon get used to it, and the commands start to feel more natural. Ctrl+Shift+Backspace is another command that I find very useful. This is especially true when editing large code files.
Go To Definition
Go To Definition allows you to jump to the definition of the selected element. Go to the example project for this chapter, and find the click event for the Track button.
Just a reminder that the code for this book can be downloaded from GitHub.
Place your cursor on Package, and hit F12 to jump to the class definition. You can also hold down the Ctrl button and hover over the class name. You will notice that Package becomes a link you can click on. Lastly, if you have your feet up and you only have your mouse to navigate with (the other hand is holding a cup of coffee), you can right-click and select Go To Definition from the context menu.
Peek Definition
As can be seen in Figure 1-30, the pop-up window displays the code for the Package class. You can navigate through the code displayed in this pop-up as you would any other code window. You can even use Peek Definition or Go To Definition inside this pop-up.
You can now navigate using the circles and arrows that appear above the Peek Definition pop-up window. The arrows only appear when you hover your mouse over the circles, but this definitely makes it much easier to move between the code windows.
Features and Productivity Tips
Visual Studio is full of existing productivity tips that have been around for years and that some developers do not know about. In this section, we will be looking at some of those.
Track Active Item in Solution Explorer
With this setting enabled, the arrows are not displayed in the toolbar of the Solution Explorer.
Hidden Editor Context Menu
This gives you a little more control over navigating through errors, methods, etc., in your current code file.
Open in File Explorer
This will open a new File Explorer window where your Visual Studio solution is located.
Finding Keyboard Shortcut Mappings
Press the shortcut keys, and Visual Studio will show you what the shortcut is currently used for. This is also very useful for assigning new keyboard shortcuts to check that the keyboard shortcut you have in mind is not already bound to another command.
Clipboard History
Visual Studio allows you to access your clipboard history. This is very useful if you have to copy and paste several items repeatedly.
Now you can just select the copied text that you want to paste and carry on with editing your code. The copied item also remains in the clipboard history after pasting.
Go To Window
So this could actually have gone under the Navigating Code section, but I wanted to add it here because it made more sense to discuss it as a productivity tip.
You can view the recent files by typing in an r instead of a question mark. Also nice to note is the ability to jump to a specific line of code. You will remember earlier in the chapter that we discussed the Go To commands and Ctrl+G in particular. Here, you can do the same thing by typing in : followed by the line number.
Navigate to Last Edit Location
Earlier on in this chapter, we discussed the Navigate Backward and Navigate Forward commands. This is great, but if you want to navigate to the last place you made an edit in the code file, hold down Ctrl+Shift+Backspace. This will jump to the last place that you made an edit in one of your code files.
Multi-caret Editing
Create SQL Table Statement
This is a rather small table, but sometimes we have very large tables that we need to work with. I want to create a simple C# class for this table and need to create some C# properties. Why type out everything when you can copy, paste, and edit all at once.
The cursor is placed at each line at the position you placed it. Now start typing the property definition. All the lines are edited. After typing public string, hit delete to remove the first square bracket.
I selected the text “cat” and held down Shift+Alt+; and Visual Studio selected everything that matches. As you can see, it also selected the category property, which I don’t want to be selected. In this instance, Shift+Alt+. will allow me to be more specific in my selection.
If you find yourself forgetting the keyboard shortcuts, you can find them under the Edit menu. Click Edit, Multiple Carets to see the keyboard shortcuts.
Features in Visual Studio 2019
Visual Studio 2019 comes packed with a few very nice productivity features. A lot of thought has been put into making Visual Studio easy to navigate and to find things in Visual Studio 2019. The first feature I want to have a look at is Visual Studio Search.
Visual Studio Search
I think that we can all agree that more speed equals improved productivity. The faster I can access a menu item, and the less time I have to spend looking for something, the more my productivity increases. This is where Visual Studio Search comes in.
Visual Studio will perform the required search and display the results to you that you can further filter by clicking the Menus, Components, or Templates tabs. Visual Studio performs a fuzzy search, which means that even if you misspell a word, chances are that Visual Studio will know what you intended to type and return the correct results for you.
Solution Filters
You still have full control of the filtered solution from the context menu and can easily load the full solution as needed.
Visual Studio IntelliCode
Visual Studio IntelliCode is a really nice feature that has been added to Visual Studio. Microsoft calls it AI-assisted development because it uses machine learning to figure out what you are most likely to use next and putting that suggestion at the top of your completion list. These are usually displayed as starred recommendations.
Compare this to the Visual Studio completion list in Figure 1-52. You can see that IntelliCode has identified the TrackPackage method as the most likely method that you will want to use.
This means that IntelliCode takes the current context into account when suggesting methods in the completion list. If you would like to view the model generated by IntelliCode, you can head on over to %TEMP%Visual Studio IntelliCode. In one of the created folders, you will find a subfolder called “UsageOutput.” Look for a JSON file in the “UseageOutput” folder. This is where the contents of the extracted data is stored for your model.
It is important to note that Microsoft does not receive any of your code. IntelliCode only uploads data and information about your code to Microsoft’s servers. All your code remains on your computer.
IntelliCode is a productivity feature that will definitely benefit developers on a day-to-day basis.
Visual Studio Live Share
During my years of writing code, I have often had the need to explain some portion of logic or feature of the code I am working with, to another developer. This usually involves them having to get a copy of the code base from source control and us having to direct each other over a Skype call and quote line numbers in order to collaborate properly.
To find out more about Visual Studio Live Share, or to download a copy for Visual Studio Code or Visual Studio 2017, go to https://visualstudio.microsoft.com/services/live-share/.
Visual Studio Live Share is included by default in Visual Studio 2019. Visual Studio Live Share does not require developers to be all “set up” in order to assist each other or to collaborate on projects. This means that a developer running Visual Studio Code on a Linux machine can collaborate with another developer running Visual Studio 2019 on a Windows 10 machine.
From there, I can end the Live Share session, share the terminal, manage shared servers, focus participants, or copy the sharing link again. At any time, I am in total control of what I share. It is also important to note that my code lives on my machine. It is not saved on the participant’s machine.