Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a .NET Core 3 console application with Visual Studio 2019 Community?

Things are moving so fast nowadays that it's hard for tutorials and blog posts to keep up.

It also doesn't help when your products have extremely similar names.

Since Visual Studio 2019 came out a few days ago I want to try to make a simple console application on .NET Core 3 (not ASP.NET Core).

I installed .NET Core SDK 3.0.100-preview3-010431 from here. However I am having trouble actually creating a project from inside the new VS or by editing the .csproj file, as my application crashes if I do the latter.

What would be the process to either:


1. Create a .NET Core 3 console application
OR
2. Create a .NET Core 3 console application with Visual Studio 2019 Community

like image 710
J. Doe Avatar asked Apr 11 '19 20:04

J. Doe


People also ask

How do I create a console application in Visual Studio?

Open Visual Studio, and choose Create a new project in the Start window. In the Create a new project window, select All languages, and then choose C# from the dropdown list. Choose Windows from the All platforms list, and choose Console from the All project types list.


1 Answers

The simplest way to create a .NET Core console app is from the command line. Navigate to your code folder, and then (assuming your app is named MyApp):

md MyApp
cd MyApp
dotnet new sln
md MyApp
cd MyApp  [now you are in MyApp\MyApp]
dotnet new console
cd ..
dotnet sln add MyApp

This gives you a solution file, MyApp.sln, and a folder MyApp containing MyApp.csproj, which is part of the MyApp solution. Now you can open the solution with Visual Studio 2019 and start coding.

If this doesn't use the right .NET Core version, then from within your root MyApp folder, run

dotnet --version

and see what it says.

like image 96
Ryan Lundy Avatar answered Oct 22 '22 01:10

Ryan Lundy