Microsoft Visual Studio is an Integrated Development Environment (IDE) from Microsoft. Over its more than twenty-year history, it has been used by developers to develop all kinds of computer programs, web applications, web APIs, and mobile apps. A 2019 survey by Stack Overflow found Visual Studio and its cousin, Visual Studio Code (VS Code), to be two of the most popular development environments among all survey respondents (see https://insights.stackoverflow.com/survey/2019):
Note on Stack Overflow 2020 survey results
Although Stack Overflow's 2020 survey results were available at the time of writing, they did not seem to include the same specific question on development environments.
Visual Studio provides robust coding and debugging capabilities as well as extensive integration for deployment and source control needs. You can use it to program anything from a desktop business application, to a web site, mobile application, or Unity game.
If you are new to programming or .NET development, it is important to understand that there are several options to consider before starting. This chapter's primary focus is to cover some key factors you should consider when deciding which product "flavor" of Visual Studio is right for you, including the following:
- Primary operating system (Windows, macOS, or Linux)
- Target framework (.NET full framework, .NET Core)
- Team size and budget
- Application type (Windows, web, mobile, server, or console)
- Cross-platform portability requirements
- Chosen programming language (such as C#, VB, Python, Ruby, or NodeJS)
The reason why we must examine the aforementioned points in detail is because Microsoft has combined what are actually multiple, separate, products under a single marketing umbrella. This can make choosing between these products confusing and so we will take a moment to clearly identify each version, differentiate their features, and provide some guidance on which version may be best for your purposes.
The code for this book is available on GitHub at: https://github.com/PacktPublishing/Visual-Studio-2019-Tricks-and-Techniques/tree/main/.
Please check the following link for CiA videos: http://bit.ly/3oxE5QM.
Quick reference cheat sheet
With so many options, how does a developer know which version to use? The following is a list of simplified suggestions to help you choose a particular flavor:
- If you are using a PC and are brand new to software development, start with VS 2019 Community.
- If you are using a PC as an experienced developer, or have a well-funded company footing the bill, consider the VS 2019 Professional or VS 2019 Enterprise editions.
- If you're primarily a web developer planning to use NodeJS and TypeScript, try VS Code.
- If you're developing cross-platform iOS/Android mobile apps, consider using VS for Mac.
Have you already decided on which version to use?
If you have already figured out which version of Visual Studio is right for you, then feel free to skip this chapter's content. Alternatively, if you are an experienced developer, skim this material looking for new tidbits, such as GitHub Codespaces.
For those readers that need more information to decide, let's begin digging into the details of the most long-lived product flavor, Visual Studio for Windows.
Visual Studio 2019 (Windows)
Different tiers of features are offered, depending on your needs and budget. Current versions of VS 2019 include a free Community edition as well as paid Professional, Enterprise, and Test Professional versions. The Community and Professional editions are nearly identical when it comes to operational features and, for most development tasks, any version of Visual Studio will work.
The Community version is depicted in the screenshot that follows and you will find virtually no difference between its appearance and that of the other versions:
Even with multiple options, choosing a Visual Studio edition is much easier today than in the past. Previously, certain project types could only be loaded in one edition or another, and many add-ins would not run in certain editions. Complex licensing issues compounded these problems, making it more difficult to choose.
Today, even the free Community edition is a powerful environment with much to offer. Many of the popular features, such as peeking at definitions, multi-targeting of release targets, and refactoring are supported in all editions.
More succinctly, the major versions of VS 2019 are as follows:
- Community – Free for students, open source contributors, and individuals
- Professional – The best choice for small teams
- Test Professional – An option for dedicated Quality Assurance (QA) roles
- Enterprise – Offers extra features (mentioned later in this chapter) and works well for teams of any size
In the past, the Community version, originally labeled "Express," was a very limited version that allowed only basic application development but would not allow for particular target types (such as Visual Studio plugins), and would also not allow a number of plugins to run. While some of these limitations seemed minor, they were enough to create negative perceptions of the platform among some developers and sour development community sentiment on the Community version. In recent years, Microsoft has removed many of the original restrictions and enabled so much functionality in this version that the experience is now very similar to the Professional version.
Traditionally, the Professional version was the lowest tier version for "true" developers. Because of the limitations of other versions, this was the only way to do "actual" development. This version tier is (and always has been) a full-featured IDE with all the bells and whistles you would expect in a professional development tool.
A key difference is that VS 2019 Community is free, while the Professional version retails for about $1,199 for the first year's subscription and $799 annually for renewal thereafter. However, there are license restrictions that limit use of Visual Studio Community to teams of less than five developers. Also, it cannot be used by commercial organizations with over $1 million US dollars in annual revenue.
For those whose focus is purely QA, and not development, Test Professional is another option to consider. It provides an integrated testing toolset for QA teams, but does not include an IDE to build applications. Instead, this product flavor focuses on the creation and execution of tests and test suites. It also integrates nicely with Visual Studio Team Foundation Server (VSTFS) and Azure DevOps (ADO).
Finally, the Enterprise version of VS 2019 is available for organizations with more than 25 developers, or those seeking to take advantage of advanced features only available at this highest tier. This level includes advanced functionality such as memory profilers, Snapshot Debugger, Live Unit Testing, architectural layer diagrams, and architecture validation. An overview of some of these capabilities is provided next.
Features of VS 2019 Enterprise edition
The following provides a brief overview of a few features that are specific to the Enterprise version of VS 2019. These items may help you decide whether this is the right flavor of the IDE for your needs:
- Performance profiling tools: VS 2019 provides a dozen or more profiling tools that can help diagnose different kinds of performance issues. Common metrics you may want to analyze include CPU usage, memory usage, and database performance. Some of these tools require the Enterprise edition, and some do not. Use this link to investigate the specific tools that match your needs: https://docs.microsoft.com/en-us/visualstudio/profiling/profiling-feature-tour?view=vs-2019.
- Live Unit Testing: While you are coding, Live Unit Testing automatically runs unit tests in the background and shows your code coverage live in Visual Studio. It provides a line-by-line visual indicator of test coverage as well as the status of passing/failing tests. As you modify code, this feature dynamically executes tests and provides immediate notification when changes cause tests to fail.
- Snapshot Debugger: If you are using Azure Application Insights, the Snapshot Debugger can be used to capture the state of source code and variables from a live, running, application. This can be helpful for troubleshooting exceptions that occur in a production environment. If you do not have the Enterprise edition of Visual Studio, you can view debug snapshots in the online portal, but using the Enterprise edition provides a more robust debugging experience.
- Live Dependency Validation: Another feature, only available in the Enterprise edition, is Live Dependency Validation. This lets teams validate architectural dependencies to ensure that they respect defined architectural constraints. In complex multi-layer applications, this can help ensure code dependencies flow in the right direction, which is important for maintainability. This can be useful on project teams with junior developers who may not fully understand the design. Detailed coverage of the Live Dependency Validation feature is beyond the scope of this chapter, but this video link provides a basic overview: https://channel9.msdn.com/Events/Visual-Studio/Visual-Studio-2017-Launch/T123.
Visual Studio Installer
To use certain features, like Code Map and Live Dependency Validation components, you must run the Visual Studio Installer, select the Individual components tab, and scroll down to the Code tools section. From there, select the Code Map and Live Dependency Validation components, as shown in the following screenshot. When you are ready, click the Modify button:
To be accurate, Visual Studio's Community and Professional editions do allow you to open diagrams that were generated using the Enterprise edition, albeit in read-only mode.
Despite their differences, from a functionality standpoint, the look and feel of all the editions are pretty much the same. Menus, tools, and functional controls are all implemented consistently, perform the same functions, and are mostly indistinguishable from one another.
Use the following link to review specific differences between versions: https://visualstudio.microsoft.com/vs/compare/.
In short, whichever version you choose, the experience should be nearly the same. For most development tasks, it makes no difference which version you are running: they all have the basic software development life cycle tools to create, debug, and run web, mobile, console, library, and just about any other project you can devise.
Visual Studio 2019 for Mac
If Windows isn't your primary operating system, Microsoft also offers Visual Studio for Mac, which unsurprisingly runs on Apple's macOS operating system. Historically, this product evolved from what was known as Xamarin Studio prior to Microsoft's acquisition of Xamarin in 2016.
One notable feature missing from VS 2019 for Mac, VS Code (discussed next), and .NET Core in general, is the ability to create cross-platform desktop applications (such as WPF, Windows Forms, and UWP). While there are several possible alternatives (Electron, Avalonia UI, Uno Platform, and so on), none truly stand out as a native interface like WPF on Windows with Visual Studio.
For convenience, the following figure shows a feature comparison between Visual Studio 2019 for Mac and VS 2019 (Windows). The few differences between these products lie in Mac's lack of support for some types of Windows desktop, Python, and Node.js development:
The full image is available in Chapter 1, Flavors of Visual Studio at https://static.packt-cdn.com/downloads/9781800203525_ColorImages.pdf
Alternatively, use this link to see a comparison between the two versions: https://visualstudio.microsoft.com/vs/mac/#vs_mac_table.
One of the most glaring shortcomings of Visual Studio for Mac is its lack of robust source control integration functionality. Developers often compensate for this using third-party tools such as Litracens, SourceTree, gmaster, and so on. That said, the Visual Studio for Mac experience improves with each release and includes more support for different application types. With the differences between the Mac and Windows versions shrinking, it is conceivable that within a few releases, the Mac and Windows experiences of Visual Studio will become nearly identical to VS Code.
Commonly referred to as VS Code, the Visual Studio Code product had humble beginnings as a text editor with support for optional plugins, similar to Atom or Sublime Text. Many developers consider it a lightweight tool specifically geared toward building and debugging modern web and cloud applications. However, it has grown into a full cross-platform (covering Linux, macOS, and Windows) editor that is free for both private and commercial use. It runs cross-platform, supports multiple programming languages, and has basic features such as syntax highlighting and code-completion aids (IntelliSense), as well as support for more advanced features such as debugging, refactoring, and code snippets, provided by plugins:
Both the popularity and the capabilities of VS Code have increased dramatically since Microsoft open-sourced this product back in late 2015. The integrated terminal is one thing many developers like about VS Code. This feature can be very convenient as you do not have to switch between applications to perform command-line tasks.
The ease of writing plug-ins, such as OmniSharp for debugging support, is credited with evolving this tool into (almost) a full-fledged IDE with support for many C# application types (including .NET Console, .NET Standard, and .NET MVC), as well as a number of other languages such as Java, Python, Ruby, and NodeJS. It supports common development operations including debugging, task running, and version control. It remains simplified to provide just what a developer needs for quick code-build-debug cycles.
The following screenshot depicts VS Code running on Linux, superimposed over a screenshot of VS Code running on macOS. Noteworthy is the striking similarity between the Windows, Mac, and Linux versions of VS Code. This makes for a consistent experience between platforms and makes shifting between them feel quite natural:
Microsoft has really made great strides to achieve a seamless experience here. The plugins are supported on each platform, the "look and feel" is seamless, and the capabilities are identical. With the cross-platform development and deployment features of .NET Core, and the IDE features and debugging of VS Code, many developers have made the switch to use this as their primary development environment. With the strength of the IDE, as well as the availability of strong plugins (see Chapter 12, Overviewing VS Code Extensions) the experience is pleasant, and the tool is very capable as a "daily driver."
Two is better than one
Lots of developers use both the full version of VS 2019 and install VS Code as well. The same code in most solutions can be opened and developed in either application. Some tasks, such as editing web files, may be done in VS Code, whereas the full version may be used for others, such as performing dependency validation.
Code examples in this book will alternate between the use of a "full version of VS 2019 and VS Code. The installation files for all versions described in this chapter can be downloaded from https://visualstudio.microsoft.com/downloads/.
A newcomer to the product flavors worth keeping an eye on is GitHub Codespaces, formerly called Visual Studio Codespaces, which provides cloudpowered development environments. In this case, an environment is considered the backend compute functions associated with software development, such as compiling and debugging. Working with this approach can be done using three possible clients: a browser-based editor, VS Code, or the Visual Studio IDE.
At the time of this writing, Codespaces is currently in beta and more information can be found at https://code.visualstudio.com/docs/remote/codespaces.
The bleeding edge
Like the public preview of GitHub Codespaces, VS 2019 and VS for Mac both have their own preview channels available. These allow developers to see and experiment with features that have not yet been released through the stable public channel. Similarly, VS Code has Insider Edition, a daily build that is essentially equivalent to the preview channels of the other flavors.
In this chapter, we overviewed the many flavors of Visual Studio that are available. We outlined the key differences between the various products Microsoft offers under the Visual Studio marketing umbrella to enable you to make an informed choice about which version will work best for you.
VS 2019 (Windows) is a very popular choice of IDE and has evolved considerably over its more than twenty-year existence. Simplified version differences and improved capabilities have made the Community version a usable tool for individuals and organizations that meet the licensing requirements. For those that don't, the Professional version is a relatively affordable version that is included in a number of Microsoft Developer Network (MSDN) subscriptions.
Visual Studio for Mac is a relatively new introduction but continues to improve with each release. The "look and feel" moves closer to the Windows version with each release, and the functionality continues to grow. For a full-featured IDE, it is becoming a very strong tool for non-Windows developers.
VS Code (Windows, Mac, and Linux versions) has grown into a very capable, useful IDE with support for multiple operating systems, multiple programming languages, and multiple workflows. From .NET to Python, NodeJS, Ruby, Java, and others, the support and strength of the plugins varies, but the core features of VS Code shine through and make the experience pleasant.
Regardless of your choice, operating system, or preferences, each tool comes with an excellent installation experience that makes it very easy for you to get up and running quickly. With Visual Studio now installed, you are ready to get started with keyboard shortcuts in the next chapter.