简体   繁体   中英

Visual Studio Code - C# Console Application

Possibly a repeat or very basic question...

I have recently downloaded Visual Studio Code on Windows and tried to open my existing "Hello World!!" console application.

I have downloaded the C# extension for the same.

Could you please point me to documentation where I can find step-by-step guide for configuring VS Code so that I can open existing console app and debug/ run the same.

Currently when I opened my existing C# project written using VS2013 and tried to debug/ run, it is not working. I'm getting following error. "The preLaunchTask 'build' terminated with exit code 1."

Or am I trying to do something which is not correct at all??

The Answer is NO

VS Code does not support debugging applications running on the Desktop .NET Framework.

VS Code is optimized for cross-platform .NET Core development Due to this focus, many standard C# project types are not recognized by VS Code.

A non-supported project type is an

  • ASP.NET MVC Application
  • Console application
  • WPF
  • Anything on Desktop .NET Framework.

VS Code supports debugging of C# applications running on either .NET Core or Mono

VS Code only supports a limited set of project types (primarily .NET Core) . For full .NET project support, use Visual studio community

The answer is No

First things first - VS 2013 and VS code are 2 different IDEs .

Visual Studio Code - is a source code editor developed by Microsoft for Windows, Linux and OS X. It includes support for debugging, embedded Git control, syntax highlighting, intelligent code completion, snippets, and code refactoring.

You cannot open VS 2013 projects in VS code.

I would suggest -See some tutorial on using VS Code IDE. here's the link Getting Started

Also here's the link for the question asked Console application using C#

Hope this helps

to build your own Console Application with .NET Core folow this path:

  1. create the project folder
  2. go to the folder created
  3. On a CMD (Windows) or Terminal (Linux) tap - "dotnet console"
  4. Tap the command "dotnet restore" to restore dependecies for the projet

That's it! Your console application project is ready to be edited! To see it runnin tap "dotnet run"!!!

You can debug your code in "Debug" painel (select it at the left side bar menu).

I hope it was helpfull.

Try This

using System;
namespace HelloWorld
{
    class Hello 
    {
        static void Main() 
        {
            Console.WriteLine("Hello World!");

            // Keep the console window open in debug mode.
            Console.WriteLine("Press any key to exit.");
            Console.ReadKey();
        }
    }
}

You can use .NET Core. Here are some instructions to run a basic C# console app in Visual Studio Code.

  1. Download Visual Studio Code and install it.
  2. Go to the Extensions, download the C# extension.

在此处输入图片说明

  1. Download .NET Core here and install it. https://dotnet.microsoft.com/download

  2. Open command prompt, and change to the folder where you want to create your app.

  3. Run:

dotnet new console -o myapp

Replace myapp with your app name.

  1. Go to Visual Studio Code, and open the folder you just created (example: myapp)

  2. Open the program.cs file, this is your main code.

在此处输入图片说明

  1. Click on Run to run your code.

在此处输入图片说明

  1. You will see your code output in the Console window at the bottom:

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM