23

I want to try out a new editor from Microsoft - Visual Studio Code. I want to implement a simple app (like Hello, World) and be able to debug it. But after a lot of googling and trying, I didn't manage to do that. Is that possible? I have Windows 10 with Visual Studio 2015 installed.

What I've tried to do:

1) Uncomment the following in the tasks.json file:

{ "version": "0.1.0", "command": "msbuild", "args": [ // Ask msbuild to generate full paths for file names. "/property:GenerateFullPaths=true" ], "taskSelector": "/t:", "showOutput": "silent", "tasks": [ { "taskName": "build", // Show the output window only if unrecognized errors occur. "showOutput": "silent", // Use the standard MS compiler pattern to detect errors, warnings // and infos in the output. "problemMatcher": "$msCompile" } ] 

But compiling (ctrl-shift-b) fails with the error: "Failed to launch external program msbuild . spawn msbuild ENOENT"

2) Read this article: http://michaelcrump.net/creating-and-debugging-console-apps-with-vscode/, but I don't have any project.json file, also "dnx . run" fails with the error "System.InvalidOperationException: Unable to resolve project"

Is there a simple way to run simple C# app in VS Code? I'm wondering why it's so complicated. Probably, I'm missing something, any ideas are welcome.

Update 1: Adding msbuild to path helps

8
  • VS Code still has limited features. It will be much easier to run your simple C# app in Visual Studio 2015. Commented Jun 10, 2015 at 6:28
  • Did you get any further with this? I also just found VSC and it would be a great quick alternative to VS for small changes, but i get the same error. Commented Jul 28, 2015 at 13:53
  • @svanelten, unfortunately, no. But I used old version of VS Code, which version do you have? Commented Jul 28, 2015 at 17:19
  • The current version, 0.5.0. I'm really looking forward to it maturing to replace sublime Text for me. Commented Jul 28, 2015 at 20:20
  • 1
    @pfedotovsky Hi, it actually works now - i added msbuild to my user PATH, restarted and it works. Previously i had only added it to the system path. Commented Jul 30, 2015 at 9:31

3 Answers 3

7

The C# support in VS Code is optimized for cross platform .NET development (DNX) (see working with ASP.NET 5 and VS Code for another relevant article. Our focus with VS Code is to be a great editor for cross platfrom C# development - for instance many Unity developers have been enjoying using VS Code in place of Mono Develop.

We support debugging of C# apps cross platfrom via Mono (see Mono Debugging).

Due to this focus many standard C# project types are not recognised by VS Code. An example of a non-supported project type is an ASP .NET MVC Application. In these cases if you simply want to have a lightweight tool to edit a file - VS Code has you covered. If you want the best possible experience for those projects, and development on Windows in general we recomend you use Visual Studio Community.

from: code.visualstudio.com/Docs/languages/csharp


Update, June 2017:

C# is supported in Visual Studio Code using Microsoft's VS Code C# extension: https://marketplace.visualstudio.com/items?itemName=ms-vscode.csharp

This can be installed by searching for 'C#' in Extensions: Install Extension. Alternatively, opening a .cs file should prompt to install extension.

This extension supports debugging of C# applications running on .NET Core or Mono, however does not support debugging applications running on the Desktop .NET Framework - Visual Studio Community is still recommended for full .NET project support.

For more info regarding VS Code's C# support, see https://code.visualstudio.com/docs/languages/csharp

For the marketplace page for the VS Code C# extension, see https://marketplace.visualstudio.com/items?itemName=ms-vscode.csharp

Sign up to request clarification or add additional context in comments.

Comments

6

You can set up msbuild for building full .NET apps just fine, note you either have to have msbuild on path or provide full path to it in command property. This is what example build task (bound to ctrl + shift + b) looks like:

{ // See https://go.microsoft.com/fwlink/?LinkId=733558 // for the documentation about the tasks.json format "version": "0.1.0", "command": "MSBuild.exe", "args": [ // $msCompile requires GenerateFullPaths=true, rest is optional. I set it to build Debug/Any CPU and use parallel project build "${workspaceRoot}/src/ExampleSolution.sln", "/p:Configuration=Debug;Platform=Any CPU;GenerateFullPaths=true", "/m" ], "taskSelector": "/t:", "showOutput": "silent", "echoCommand": true, "tasks": [ { "taskName": "Rebuild", // Required if you want "Rebuild", not build as your target and still use ctrl + shift + b hotkey "isBuildCommand": true, // Show the output window only if unrecognized errors occur. "showOutput": "silent", // Use the standard MS compiler pattern to detect errors, warnings and infos "problemMatcher": "$msCompile" } ] } 

UPD: If you want to set up both building and unit test running, you can use something like this (uses nunit console runner and cmd as a task to hack around vscode limitation of supporting only single task):

{ "version": "0.1.0", "command": "cmd", "args": [ "/c" ], "showOutput": "always", "echoCommand": true, "tasks": [ { "isBuildCommand": true, "taskName": "MSBuild.exe", "args": [ "${workspaceRoot}/src/Example.sln", "/t:Rebuild", "/p:Configuration=Debug;Platform=Any CPU;GenerateFullPaths=true", "/m" ], "showOutput": "always", "problemMatcher": "$msCompile" }, { "taskName": "nunit3-console.exe", "args": [ "${workspaceRoot}/src/Example.sln" ], "showOutput": "always" } ] } 

Comments

2

Had the same problem. Changed direct path to msbuild fixed it:

{ // See https://go.microsoft.com/fwlink/?LinkId=733558 // for the documentation about the tasks.json format "version": "0.1.0", "windows": { "command": "C:\\Program Files (x86)\\MSBuild\\14.0\\Bin\\MSBuild.exe" }, // "command": "msbuild", "args": [ // Ask msbuild to generate full paths for file names. "/property:GenerateFullPaths=true" ], "taskSelector": "/t:", "showOutput": "silent", "tasks": [ { "taskName": "build", // Show the output window only if unrecognized errors occur. "showOutput": "silent", // Use the standard MS compiler pattern to detect errors, warnings and infos "problemMatcher": "$msCompile" } ] } 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.