Visual Studio has always been a good friend to .NET developers, although VS Code can do .NET Core development, VS is still having a lot advantages. Let's see how to make Visual Studio more handy for .NET Core development.
First, please be advised, not all versions of Visual Studio supports .NET Core development, even some early version of VS2017. Some people may mistake for any VS2017 can do .NET Core development, which your code won't be able to compile on unsupported versions.
For example, as for .NET Core 2.1, the minimal VS2017 version should be 15.7. Current release of .NET Core is 2.2, so I would suggest you always update VS to latest version.
Search for "Visual Studio Installer" in start menu
If there is an update, you can click "Update" button to update your Visual Studio.
In addition, make sure you select " .NET Core cross-platform development" in the workload.
As time goes, you may find there are a lot of different versions of .NET Core SDK on your machine that were introduced via each VS update, my recommendation is to keep the latest one for both current (2.2) and LST (2.1), and you can uninstall other SDKs manually.
You may notice an SDK versioned 2.1.202, this is by default installed with VS2017, and it is for .NET Core 2.0. If you don't do development on 2.0, you can uninstall it. 2.1.503 is for .NET Core 2.1.7, 2.2.103 is for .NET Core 2.2.1. These are usually security updates.
If you want to check all the SDKs and runtime installed on your machine, use "
dotnet --info" command:
My personal favorite is ReSharper, it is a paid extension, but has a very complete and powerful functions, such as batch renaming, arrange namespaces, suggest new C# syntax. It already supports .NET Core.
Product link: https://www.jetbrains.com/resharper
One good example in .NET Core is that we usually write dependency injections. With ReSharper, you can let the extension automatically generate constructor injection in 1 second.
Another suite of extensions is Web Essentials. In VS2017, it is a set of small extensions which any individual extension can also be installed separately.
In Tools -> Extensions and Updates -> Online, search for "Web Essentials", and you can install from here.
There are so many child extensions under Web Essentials. I picked a few most useful extensions to introduce.
Bundle & Minifier
This is an extension for compress and bundle JS/CSS files. It uses bunduleconfig.json file to define the rules under your web projects. The bundled or minified files will be automatically refreshed once you save the source file or compile the project.
Outside of VS, such as CI environments, it can also do it's job. Just "Enable bundle on build".
This command is actually adding a NuGet tool into your project file:
<PackageReference Include="BuildBundlerMinifier" Version="2.8.391" />
Open Command Line
In .NET Core development, we usually perform some operations under CLI, such as using libman. This plugin can open CMD or PowerShell window under the selected path.
Visual Studio default theme is a blue light style, many people change it to dark, not only for making your computer looks cool, but also has a certain reason.
Please take careful look at the red marked interfaces, this is under dark theme:
And this is under the default (blue) theme, you can't tell which is interface and which is class:
.NET Core uses a lot dependency injections, which means you can't just igore interfaces. So I suggest to use dark theme.
The Annoying Active Item Tracking
In .NET Core projects, VS will automatically select current opened files in Solution Explorer, which can cause trouble for us. Especially when you are editing files very near under a same folder, and you need to check another file from another directory. This tracking makes us have to drag the scroll bar very often. I intent to disable it.
In "Project and Solutions", uncheck "Track Active Item in Solution Explorer"
Automatically Word Wrap
Not all programmers can write code in good format, and we somtimes encounter the generated code which is very long and we have to drag the horizontal scroll bar, it is inconvenient. I always turn on word wrap in VS.
Under "Text Editor > All Languages", select "Word wrap".
This is all I want to share for making VS more handy in .NET Core development. Thank for reading, and you are welcomed to add additional VS tricks in comments.