{"id":6350,"date":"2016-09-06T14:18:04","date_gmt":"2016-09-06T14:18:04","guid":{"rendered":"https:\/\/ushipblogsubd.wpengine.com\/?p=6350"},"modified":"2025-09-03T15:59:29","modified_gmt":"2025-09-03T15:59:29","slug":"visual-studioresharper-level-productivity-in-vscode","status":"publish","type":"post","link":"https:\/\/ushipblogsubd.wpengine.com\/shipping-code\/visual-studioresharper-level-productivity-in-vscode\/","title":{"rendered":"Visual Studio+ReSharper-level Productivity in VSCode"},"content":{"rendered":"<p><strong>Update 2017-05-22<\/strong>: This post originally written for a project.json .NET Core project. It has been edited for a .csproj .NET Core project.<\/p>\n<p><a href=\"https:\/\/code.visualstudio.com\" target=\"_blank\" rel=\"noopener\">Visual Studio Code<\/a> (aka VSCode) is a lightweight text editor from Microsoft. Many people think just because it is a \u201ctext-editor\u201d, they will be missing the features they are used to from an IDE like Visual Studio. With the proper configuration, VSCode can be a very powerful tool.<\/p>\n<h2><a id=\"Setup_3\"><\/a>Setup<\/h2>\n<p>VSCode by default doesn\u2019t come with the tools necessary to build .NET Core projects. The following setup will be necessary to get the editor, compiler, and extension necessary to get you closer to an IDE experience.<\/p>\n<ul>\n<li><a href=\"https:\/\/code.visualstudio.com\/docs\/setup\/setup-overview\" target=\"_blank\" rel=\"noopener\">VSCode Installation<\/a>\n<ul>\n<li>This is the vanilla text-editor. Installation of extensions and other software may be required for your language to get an IDE-like experience.<\/li>\n<\/ul>\n<\/li>\n<li><a href=\"https:\/\/www.microsoft.com\/net\/core\" target=\"_blank\" rel=\"noopener\">.NET Core SDK Installation<\/a>\n<ul>\n<li>Provides .NET runtime, framework, compiler, and other tooling<\/li>\n<li>Bleeding edge builds can be found on <a href=\"https:\/\/github.com\/dotnet\/cli\" target=\"_blank\" rel=\"noopener\">the project\u2019s GitHub<\/a><\/li>\n<\/ul>\n<\/li>\n<li><a href=\"https:\/\/code.visualstudio.com\/docs\/languages\/csharp\" target=\"_blank\" rel=\"noopener\">C# VSCode Extension<\/a>\n<ul>\n<li>Powered by <a href=\"https:\/\/github.com\/dotnet\/roslyn\" target=\"_blank\" rel=\"noopener\">Roslyn<\/a> and <a href=\"http:\/\/www.omnisharp.net\/\" target=\"_blank\" rel=\"noopener\">OmniSharp<\/a><\/li>\n<li>Allows for Intellisense, Debugging, and other features expected from an IDE<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>To install an extension, open the Command Palette (<code>cmd+shift+p<\/code>), remove the <code>&gt;<\/code>, and run <code>ext install csharp<\/code>.<\/p>\n<p>Note: While this tutorial is cross-platform , all given commands are using Mac OS X key bindings. For Windows and Linux, replace <code>cmd<\/code> with <code>ctrl<\/code>.<\/p>\n<h2><a id=\"Key_Bindings_19\"><\/a>Key Bindings<\/h2>\n<h3><a id=\"Command_Palette_21\"><\/a>Command Palette<\/h3>\n<p>The most important key binding in VSCode is <code>cmd+shift+p<\/code>, which brings up the Command Palette, similar to <a href=\"https:\/\/www.sublimetext.com\/\" target=\"_blank\" rel=\"noopener\">Sublime Text<\/a>. Why is it so important? Hitting those keys brings up a search box that allows you to start typing a command like \u201cext\u201d for \u201cExtensions: Install Extensions\u201d or \u201cbuild\u201d for \u201cTasks: Run Build Task\u201d.<\/p>\n<h3><a id=\"Shell_24\"><\/a>Shell<\/h3>\n<p>You will frequently need to run shell commands within VSCode. <code>ctrl+`<\/code> toggles an in-editor shell.<\/p>\n<h3><a id=\"ReSharper_Bindings_27\"><\/a>ReSharper Bindings<\/h3>\n<p>Where would each of us be without <code>alt+enter<\/code>, ReSharper\u2019s quick fix and context actions key binding? Just because you don\u2019t have ReSharper doesn\u2019t mean your life is over (even though some people might think that). Common ReSharper operations are supported in VSCode, and these operations can be bound to custom key bindings, which allows us to roughly mirror the ReSharper plugin in VSCode. The below are the most common ReSharper key bindings I use. You can use the Command Palette to search for \u201cPreferences: Open Keyboard Shortcuts\u201d.<\/p>\n<pre class=\"theme:twilight lang:js decode:true \">[\r\n\t{ \"key\": \"alt+enter\",                 \"command\": \"editor.action.quickFix\",\r\n                                     \"when\": \"editorTextFocus\" },\r\n\t{ \"key\": \"cmd+b\",               \"command\": \"editor.action.goToDeclaration\",\r\n                                     \"when\": \"editorTextFocus\" },\r\n\t{ \"key\": \"alt+f7\",               \"command\": \"editor.action.referenceSearch.trigger\",\r\n                                     \"when\": \"editorTextFocus\" },\r\n\t{ \"key\": \"cmd+shift+alt+n\",                 \"command\": \"workbench.action.showAllSymbols\" },\r\n\t{ \"key\": \"cmd+n\",                 \"command\": \"workbench.action.quickOpen\" },\r\n\t{ \"key\": \"cmd+shift+n\",                 \"command\": \"workbench.action.quickOpen\" },\t\t\t\r\n\t{ \"key\": \"cmd+f12\",\t\t\t\"command\": \"workbench.action.gotoSymbol\"},\r\n\t{ \"key\": \"cmd+t l\", \t\t\t\"command\": \"workbench.action.tasks.test\"},\r\n\r\n\t{ \"key\": \"cmd+p\",\t\t\t\"command\": \"editor.action.triggerParameterHints\"}\r\n]<\/pre>\n<table class=\"table table-striped table-bordered\">\n<thead>\n<tr>\n<th>Command<\/th>\n<th>ReSharper<\/th>\n<th>VSCode default<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Quick Fix<\/td>\n<td>alt+enter<\/td>\n<td>cmd+.<\/td>\n<\/tr>\n<tr>\n<td>Go to anything<\/td>\n<td>cmd+n<\/td>\n<td>cmd+p<\/td>\n<\/tr>\n<tr>\n<td>Go to symbol<\/td>\n<td>cmd+shift+alt+n<\/td>\n<td>cmd+t<\/td>\n<\/tr>\n<tr>\n<td>Go to declaration<\/td>\n<td>cmd+b<\/td>\n<td>f12<\/td>\n<\/tr>\n<tr>\n<td>Go to file<\/td>\n<td>cmd+n<\/td>\n<td>cmd+p<\/td>\n<\/tr>\n<tr>\n<td>Go to file member<\/td>\n<td>cmd+f12<\/td>\n<td>shift+cmd+o<\/td>\n<\/tr>\n<tr>\n<td>Parameter info<\/td>\n<td>cmd+p<\/td>\n<td>shift+cmd+space<\/td>\n<\/tr>\n<tr>\n<td>Find usages<\/td>\n<td>alt+f7<\/td>\n<td>shift+f12<\/td>\n<\/tr>\n<tr>\n<td>Run all tests<\/td>\n<td>cmd+t l<\/td>\n<td>N\/A<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>VSCode key bindings reference: <a href=\"https:\/\/code.visualstudio.com\/docs\/customization\/keybindings\" target=\"_blank\" rel=\"noopener\">https:\/\/code.visualstudio.com\/docs\/customization\/keybindings<\/a><br \/>\nReSharper key bindings reference: <a href=\"https:\/\/www.jetbrains.com\/resharper\/docs\/ReSharper_DefaultKeymap_IDEAscheme.pdf\" target=\"_blank\" rel=\"noopener\">https:\/\/www.jetbrains.com\/resharper\/docs\/ReSharper_DefaultKeymap_IDEAscheme.pdf<\/a><\/p>\n<h2><a id=\"Building_and_Debugging_NET_Core_Applications_63\"><\/a>Building and Debugging .NET Core Applications<\/h2>\n<p>This is it. The moment you\u2019ve been waiting for. Using VSCode as an IDE.<\/p>\n<h3><a id=\"Creating_a_NET_Core_Project_66\"><\/a>Creating a .NET Core Project<\/h3>\n<p>VSCode doesn\u2019t have a UI to create new projects, since it is file and folder based. However, we can use the in-editor shell to create a project after creating a folder.<\/p>\n<pre class=\"theme:twilight lang:sh decode:true \">mkdir my_project\r\ncode my_project<\/pre>\n<p>Note that the above requires <code>code<\/code> to be in your path. You can do this via searching \u201cPATH\u201d in the Command Palette.<\/p>\n<p>Once we are in VSCode, run the following in the in-editor shell to create a new .NET Core command line project<\/p>\n<pre class=\"theme:twilight lang:sh decode:true \">dotnet new\r\n# Run `dotnet new -h` to see your available options.\r\n# Some templates that are available: Console (the default), Web (ASP.NET Core MVC), Lib (class library), xunittest and nunittest (XUnit and NUnit test projects)<\/pre>\n<p>You might see: \u201cRequired assets to build and debug are missing from your project. Add them?\u201d Select \u201cYes\u201d.<\/p>\n<h3><a id=\"Building_and_Debugging_85\"><\/a>Building and Debugging<\/h3>\n<p><a href=\"https:\/\/code.visualstudio.com\/docs\/customization\/keybindings#_debug\" target=\"_blank\" rel=\"noopener\">The building and debugging key bindings<\/a> are the typical bindings from Visual Studio.<\/p>\n<p>To debug, set a breakpoint and hit F5. It\u2019s really that easy!<\/p>\n<h2><a id=\"NuGet_90\"><\/a>NuGet<\/h2>\n<p>Now that we are able to debug a .NET Core application, let\u2019s walk through the common task of adding a NuGet dependency.<\/p>\n<p>VSCode doesn\u2019t come with a NuGet client by default, so let\u2019s install one via <code>ext install vscode-nuget-package-manager<\/code>.<\/p>\n<p>To install a NuGet package:<\/p>\n<ul>\n<li>Open the Command Palette and search for \u201cNuGet Package Manager: Add Package\u201d and hit enter<\/li>\n<li>Enter a search term and hit enter (e.g. \u201cjson\u201d)<\/li>\n<li>Select a package from the list and hit enter (e.g. \u201cNewtonsoft.Json\u201d)<\/li>\n<li>Select a version from the list and hit enter (e.g. 9.0.1)<\/li>\n<li>Select a project to add the reference to<\/li>\n<li>Run <code>dotnet restore<\/code> in the in-editor shell as prompted by the NuGet extension<\/li>\n<\/ul>\n<p>Alternatively, you can use the dotnet NuGet commands directly:<\/p>\n<pre class=\"theme:twilight lang:sh decode:true \">dotnet add path\/to\/your_project package Example.Package -v 1.0\r\n<\/pre>\n<p>Be aware that not all NuGet packages are compatible with .NET Core. See <a href=\"https:\/\/github.com\/thangchung\/awesome-dotnet-core\" target=\"_blank\" rel=\"noopener\">this awesome list<\/a> of packages that support .NET Core. Hint: your favorite packages are probably there.<\/p>\n<h2><a id=\"Testing_104\"><\/a>Testing<\/h2>\n<p>\u201cThe code is not done until the tests run\u201d &#8211; A person<\/p>\n<p>Now that we have a .NET Core project with a NuGet package reference, let\u2019s add a test.<\/p>\n<h3><a id=\"Set_up_109\"><\/a>Set up<\/h3>\n<p>We need to install the following NuGet packages:<\/p>\n<ul>\n<li>NUnit<\/li>\n<li>NUnit3TestAdapter, at least version 3.8.0-alpha1<\/li>\n<\/ul>\n<p>The following will have to be added to .vscode\/tasks.json:<\/p>\n<pre class=\"theme:twilight lang:js decode:true \">{\r\n\t\"taskName\": \"test\",\r\n\t\"args\": [],\r\n\t\"isTestCommand\": true,\r\n\t\"problemMatcher\": \"$msCompile\"\r\n}<\/pre>\n<p>Note: You may be able to run <code>dotnet new -t xunittest<\/code> or <code>dotnet new -t nunittest<\/code> depending on what version of <code>dotnet<\/code> you have installed. The bleeding edge can be installed from <a href=\"https:\/\/github.com\/dotnet\/cli\" target=\"_blank\" rel=\"noopener\">the GitHub page<\/a>.<\/p>\n<h3><a id=\"Running_the_Test_131\"><\/a>Running the Test<\/h3>\n<p>Now we can add the simplest failing test:<\/p>\n<pre class=\"theme:twilight lang:c# decode:true \">using NUnit.Framework;\r\n\r\n[TestFixture]\r\npublic class ProgramTests\r\n{\r\n\t[Test]\r\n\tpublic void Should_fail()\r\n\t{\r\n\t\tAssert.Fail(\"This is a failure!\");\r\n\t}\r\n}<\/pre>\n<p>Now when we hit <code>cmd+t l<\/code>, our test will fail!<\/p>\n<h3><a id=\"Debugging_the_Test_149\"><\/a>Debugging the Test<\/h3>\n<p>If you prefer to use xUnit (see: <a href=\"https:\/\/github.com\/xunit\/dotnet-test-xunit\" target=\"_blank\" rel=\"noopener\">dotnet-test-xunit<\/a>) you can easily run or debug the test by simply selecting the corresponding option in the editor. Unfortunately, debugging with NUnit isn\u2019t quite as simple yet, and currently requires a convoluted process. See <a href=\"https:\/\/github.com\/nunit\/dotnet-test-nunit\/issues\/73\" target=\"_blank\" rel=\"noopener\">this GitHub issue<\/a> that addresses this.<\/p>\n<h2><a id=\"Conclusion_152\"><\/a>Conclusion<\/h2>\n<p>VSCode out-of-the-box won\u2019t give you everything you need to be fully productive with .NET Core, but with some setup you should be up and running in no time. Do you have any VSCode tips and tricks of your own that I didn\u2019t mention? Please comment below and share.<\/p>\n<h2><a id=\"Summary_of_Setup_155\"><\/a>Summary of Setup<\/h2>\n<ul>\n<li><a href=\"https:\/\/code.visualstudio.com\/docs\/setup\/setup-overview\" target=\"_blank\" rel=\"noopener\">VSCode Installation<\/a><\/li>\n<li><a href=\"https:\/\/www.microsoft.com\/net\/core\" target=\"_blank\" rel=\"noopener\">.NET Core SDK Installation<\/a><\/li>\n<li>ext install csharp<\/li>\n<li>ext install vscode-nuget-package-manager<\/li>\n<\/ul>\n<p>[amp-cta id=&#8217;8486&#8242;]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Update 2017-05-22: This post originally written for a project.json .NET Core project. It has been edited for a .csproj .NET Core project. Visual Studio Code (aka VSCode) is a lightweight text editor from Microsoft. Many people think just because it is a \u201ctext-editor\u201d, they will be missing the features they are used to from an&#8230;<a class=\"read-more\" href=\"https:\/\/ushipblogsubd.wpengine.com\/shipping-code\/visual-studioresharper-level-productivity-in-vscode\/\"> Read More<\/a><\/p>\n","protected":false},"author":7,"featured_media":6363,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[295,2],"tags":[61,261,54,260,297,262,259,258],"class_list":["post-6350","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-shipping-code","category-company-news","tag-net-core","tag-asp-net-core","tag-c","tag-resharper","tag-shipping-code","tag-visual-studio","tag-visual-studio-code","tag-vscode"],"acf":{"blog_post_content":[{"acf_fc_layout":"blog_post_entry_footer","blog_post_entry_footer_cta":[{"blog_post_entry_footer_cta_url":"https:\/\/www.uship.com\/","blog_post_entry_footer_cta_text":"Ready to Ship Something?","blog_post_entry_footer_onclick":""}]}]},"_links":{"self":[{"href":"https:\/\/ushipblogsubd.wpengine.com\/wp-json\/wp\/v2\/posts\/6350","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ushipblogsubd.wpengine.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ushipblogsubd.wpengine.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ushipblogsubd.wpengine.com\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/ushipblogsubd.wpengine.com\/wp-json\/wp\/v2\/comments?post=6350"}],"version-history":[{"count":0,"href":"https:\/\/ushipblogsubd.wpengine.com\/wp-json\/wp\/v2\/posts\/6350\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ushipblogsubd.wpengine.com\/wp-json\/wp\/v2\/media\/6363"}],"wp:attachment":[{"href":"https:\/\/ushipblogsubd.wpengine.com\/wp-json\/wp\/v2\/media?parent=6350"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ushipblogsubd.wpengine.com\/wp-json\/wp\/v2\/categories?post=6350"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ushipblogsubd.wpengine.com\/wp-json\/wp\/v2\/tags?post=6350"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}