Navigate back to the homepage

Optimize Visual Studio Code for C# .NET Core development

Dominic Böttger
May 10th, 2020 · 1 min read

Visual Studio Code is my favorite Code Editor and I like that it’s so lightweight and also wanted to use it for C# development instead of the full-blown Visual Studio experience.

Some time ago I tried to use Visual Studio Code instead but I was missing some things to improve the development workflow. I wanted to have features like live unit testing and better guidance while coding C#. I tested some plugins and some configurations and now I think I found a solution to fulfill my needs.

Some of the extensions I use:

  1. C# - This is THE C# extension for Visual Studio Code powered by OmniSharp.

  2. .NET Core Test Explorer - An important extension to have live testing while coding in VScode.

  3. Auto-using - Automatically adds the dependencies with using in the head of the current file.

  4. C# FixFormat - It helps to automatically format the code. With the right settings, the code is also formatted when saving the file.

  5. Coverage Gutters - Show the code coverage visualized with color in the editor.

  6. .NET Core Extension Pack - Bundle of helpful extensions.

  7. .NET Core Snippet Pack - A pack of around 120 snippets for .NET Core.

  8. Fakesharper - Integrates Resharper into VSCode

  9. EditorConfig - Overwrites the VScode settings with the settings provided in the .editorconfig file.

The extensions were one part of the solution.

The other part was the settings. I provide the settings for VSCode with every project to install the recommended modules, activate the Roslyn Analyzer feedback ( which provides the StyleCop information,… ), activate the TestExplorer to use the Live Testing feature and activate the automatic format of the code.

The important settings in my .vscode/settings.json in the project are typically the following:

1"dotnet-test-explorer.testProjectPath": "**/*Test.csproj",
2 "dotnet-test-explorer.autoWatch": true,
3 "dotnet-test-explorer.testArguments": "/p:CollectCoverage=true /p:CoverletOutputFormat=lcov /p:CoverletOutput=./",
4 "cSpell.words": [
5 "Xunit"
6 ],
7 "omnisharp.enableRoslynAnalyzers": true,
8 "csharpfixformat.sort.usings.enabled": true,
9 "csharpfixformat.sort.usings.systemFirst": false,
10 "": false,
11 "": false,
12 "": false,
13 "editor.formatOnSave": true,
14 "[csharp]": {
15 "editor.defaultFormatter": "Leopotam.csharpfixformat"
16 }

If you add StyleCop.Analyzers via NuGet to your projects the “omnisharp.enableRoslynAnalyzers”: true - setting will provide this information in the editor.

To adjust the StyleCop ruleset and use the Ruleset in the root folder append the path to the ruleset in the csproj of all projects.

2 <CodeAnalysisRuleSet>..\StyleCop.ruleset</CodeAnalysisRuleSet>

To get the coverage statistics working it’s also needed to add the coverlet.msbuild package to the Test project.

A complete example template is available under

More articles from Dominic Böttger

Pretty Windows Terminal and PowerShell Setup

My Windows Terminal and PowerShell configuration. It includes modules like git-posh and oh-my-posh to beautify the command-line experience.

April 13th, 2020 · 2 min read

Securely fight COVID-19 in a Windows Sandbox

A simple script which installs the Folding@Home client into a Windows Sandbox.

April 12th, 2020 · 1 min read
© 2020 Dominic Böttger
Link to $ to $ to $