Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio Code, C# support on Windows

Tags:

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

like image 449
pfedotovsky Avatar asked Jun 09 '15 09:06

pfedotovsky


People also ask

Can I use Visual Studio Code for C?

C/C++ support for Visual Studio Code is provided by a Microsoft C/C++ extension to enable cross-platform C and C++ development on Windows, Linux, and macOS.

Is Visual Studio C free?

Visual Studio Community. A fully-featured, extensible, free IDE for creating modern applications for Android, iOS, Windows, as well as web applications and cloud services.

Is Visual Studio best for C?

Visual Studio is an excellent IDE for C++. If you know it from C#, it will be comfortably familiar.


1 Answers

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

like image 193
James Vickery Avatar answered Oct 16 '22 13:10

James Vickery