Visual Studio Code - C# Console Application

烂漫一生 提交于 2021-02-07 18:47:53

问题


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??


回答1:


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




回答2:


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




回答3:


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.




回答4:


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();
        }
    }
}



回答5:


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:



来源:https://stackoverflow.com/questions/39694925/visual-studio-code-c-sharp-console-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!