Building .NET Apps in VSCode (Not .NetCore)

Building .NET Apps in VSCode (Not .NetCore)

11/17/2016 10:09:50

With all the fanfare around .NET Core and VS Code, you might have been lead to believe that you can't build your boring old .NET apps inside of VS Code, but that's not the case.

You can build your plain old .NET solutions (PONS? Boring old .NET projects? BONPS? God knows) by shelling out using the external tasks feature of the editor (http://code.visualstudio.com/docs/editor/tasks).

First, make sure you have a couple of plugins available

  • C# for Visual Studio Code (powered by OmniSharp)
  • MSBuild Tools (for syntax highlighting)
Now, "Open Folder" on the root of your repository and press CTRL+SHIFT+B.

VS Code will complain that it can't build your program, and open up a file it generates .vs\tasks.json in the editor.  It'll be configured to use msbuild, but won't work unless MSBuild is in your path, with a trivial edit to correct the path, you'll be building straight away:

{ // See https://go.microsoft.com/fwlink/?LinkId=733558 // for the documentation about the tasks.json format "version": "0.1.0", "command": "C:\\Program Files (x86)\\MSBuild\\14.0\\Bin\\msbuild.exe", "args": [ "/property:GenerateFullPaths=true" ], "taskSelector": "/t:", "showOutput": "silent", "tasks": [ { "taskName": "build", "showOutput": "silent", "problemMatcher": "$msCompile" } ] }

CTRL+SHIFT+B will now build your code by invoking MSBuild.