Visual Studio Code 2019



Learn how to use Visual Studio to develop applications, services. Visual Studio 2019 Release Notes. Improve your Visual Studio skills. Share your apps and code by using Web Deploy, InstallShield, NuGet, Continuous Integration, and more. Visual Studio 2019 (VS 2019) and Visual Studio Code (VS Code) are powerful professional development tools that help you to develop applications for any platform with ease. Whether you want to create web, mobile, or desktop applications, Microsoft Visual Studio is your one-stop solution. Visual Studio IDE Visual Studio for Mac Visual Studio Code. To continue downloading, click here. Visual Studio Community 2019 – Free IDE and Developer Tools 2020-12-14T11:03:28-08:00. Visual Studio Community. A fully-featured, extensible, free IDE for creating modern applications for Android, iOS, Windows, as well as web applications.

-->

In this tutorial for Visual Basic (VB), you'll use Visual Studio to create and run a few different console apps and explore some features of the Visual Studio integrated development environment (IDE) while you do so.

If you haven't already installed Visual Studio, go to the Visual Studio downloads page to install it for free.

Visual Studio Code 2019

If you haven't already installed Visual Studio, go to the Visual Studio downloads page to install it for free.

Create a project

First, we'll create a Visual Basic application project. The project type comes with all the template files you'll need, before you've even added anything!

  1. Open Visual Studio 2017.

  2. From the top menu bar, choose File > New > Project.

  3. In the New Project dialog box in the left pane, expand Visual Basic, and then choose .NET Core. In the middle pane, choose Console App (.NET Core). Then name the project WhatIsYourName.

Add a workload (optional)

If you don't see the Console App (.NET Core) project template, you can get it by adding the .NET Core cross-platform development workload. You can add this workload in one of the two following ways, depending on which Visual Studio 2017 updates are installed on your machine.

Option 1: Use the New Project dialog box

  1. Click the Open Visual Studio Installer link in the left pane of the New Project dialog box.

  2. The Visual Studio Installer launches. Choose the .NET Core cross-platform development workload, and then choose Modify.

Option 2: Use the Tools menu bar

  1. Cancel out of the New Project dialog box and from the top menu bar, choose Tools > Get Tools and Features.

  2. The Visual Studio Installer launches. Choose the .NET Core cross-platform development workload, and then choose Modify.

Note

Some of the screenshots in this tutorial use the dark theme. If you aren't using the dark theme but would like to, see the Personalize the Visual Studio IDE and Editor page to learn how.

  1. Open Visual Studio 2019.

  2. On the start window, choose Create a new project.

  3. In the Create a new project window, choose Visual Basic from the Language list. Next, choose Windows from the Platform list and Console from the project types list.

    After you apply the language, platform, and project type filters, choose the Console Application template, and then choose Next.

    Note

    If you do not see the Console Application template, you can install it from the Create a new project window. In the Not finding what you're looking for? message, choose the Install more tools and features link.

    Then, in the Visual Studio Installer, choose the .NET Core cross-platform development workload.

    After that, choose the Modify button in the Visual Studio Installer. You might be prompted to save your work; if so, do so. Next, choose Continue to install the workload. Then, return to step 2 in this 'Create a project' procedure.

  4. In the Configure your new project window, type or enter WhatIsYourName in the Project name box. Then, choose Next.

  5. In the Additional information window, .NET Core 3.1 should already be selected for your target framework. If not, select .NET Core 3.1. Then, choose Create.

    Visual Studio opens your new project.

Create a 'What Is Your Name' application

Let's create an app that prompts you for your name and then displays it along with the date and time. Here's how:

  1. If it is not already open, then open your WhatIsYourName project.

  2. Enter the following Visual Basic code immediately after the opening bracket that follows the Sub Main(args As String()) line and before the End Sub line:

    This code replaces the existing WriteLine, Write, and ReadKey statements.

  3. Use the green Start button, or press F5 to build and run your first app.

  4. When the console window opens, enter your name. Your console window should look similar to the following screenshot:

  5. Press any key to close the console window.

  1. In the WhatIsYourName project, enter the following Visual Basic code immediately after the opening bracket that follows the Sub Main(args As String()) line and before the End Sub line:

    This code replaces the existing WriteLine, Write, and ReadKey statements.

  2. Use the green Start button, or press F5 to build and run your first app.

  3. When the console window opens, enter your name. Your console window should look similar to the following screenshot:

  4. Press any key to close the console window.

Create a 'Calculate This' application

  1. Open Visual Studio 2017, and then from the top menu bar, choose File > New > Project.

  2. In the New Project dialog box in the left pane, expand Visual Basic, and then choose .NET Core. In the middle pane, choose Console App (.NET Core). Then name the file CalculateThis.

  3. Enter the following code between the Module Program line and End Module line:

    Your code window should look like the following screenshot:

  4. Click CalculateThis to run your program. Your console window should look similar to the following screenshot:

  1. On the start window, choose Create a new project.

  2. In the Create a new project window, choose Visual Basic from the Language list. Next, choose Windows from the Platform list and Console from the project types list.

  3. After you apply the language, platform, and project type filters, choose the Console Application template, and then choose Next.

    Then, in the Configure your new project window, type or enter CalculateThis in the Project name box. Then, choose Next.

  4. In the Additional information window, .NET Core 3.1 should already be selected for your target framework. If not, select .NET Core 3.1. Then, choose Create.

  5. Enter the following code between the Module Program line and End Module line:

    Your code window should look like the following screenshot:

  6. Click CalculateThis to run your program. Your console window should look similar to the following screenshot:

Quick answers FAQ

Here's a quick FAQ to highlight some key concepts.

What is Visual Basic?

Visual Basic is a type-safe programming language that's designed to be easy to learn. It is derived from BASIC, which means 'Beginner's All-purpose Symbolic Instruction Code'.

What is Visual Studio?

Visual Studio is an integrated development suite of productivity tools for developers. Think of it as a program you can use to create programs and applications.

What is a console app?

A console app takes input and displays output in a command-line window, also known as a console.

What is .NET Core?

.NET Core is the evolutionary next step of the .NET Framework. Where the .NET Framework allowed you to share code across programming languages, .NET Core adds the ability to share code across platforms. Even better, it's open source. (Both the .NET Framework and .NET Core include libraries of prebuilt functionality as well as a common language runtime (CLR), which acts as a virtual machine in which to run your code.)

Next steps

Congratulations on completing this tutorial! To learn even more, see the following tutorial.

See also

-->

By Rick Anderson

This is the first tutorial of a series that teaches the basics of building an ASP.NET Core Razor Pages web app.

For a more advanced introduction aimed at developers who are familiar with controllers and views, see Introduction to Razor Pages.

Visual Studio Code 2019

At the end of the series, you'll have an app that manages a database of movies.

View or download sample code (how to download).

In this tutorial, you:

  • Create a Razor Pages web app.
  • Run the app.
  • Examine the project files.

At the end of this tutorial, you'll have a working Razor Pages web app that you'll enhance in later tutorials.

Prerequisites

  • Visual Studio 2019 16.8 or later with the ASP.NET and web development workload

The Visual Studio Code instructions use the .NET CLI for ASP.NET Core development functions such as project creation. You can follow these instructions on macOS, Linux, or Windows and with any code editor. Minor changes may be required if you use something other than Visual Studio Code.

Create a Razor Pages web app

  1. Start Visual Studio and select Create a new project. For more information, see Create a new project in Visual Studio.

  2. In the Create a new project dialog, select ASP.NET Core Web Application, and then select Next.

  3. In the Configure your new project dialog, enter RazorPagesMovie for Project name. It's important to name the project RazorPagesMovie, including matching the capitalization, so the namespaces will match when you copy and paste example code.

  4. Select Create.

  5. In the Create a new ASP.NET Core web application dialog, select:

    1. .NET Core and ASP.NET Core 5.0 in the dropdowns.
    2. Web Application.
    3. Create.

    The following starter project is created:

  1. Open the integrated terminal.

  2. Change to the directory (cd) which will contain the project.

  3. Run the following commands:

    • The dotnet new command creates a new Razor Pages project in the RazorPagesMovie folder.
    • The code command opens the RazorPagesMovie folder in the current instance of Visual Studio Code.
  1. Select File > New Solution.

  2. In Visual Studio for Mac earlier than version 8.6, select .NET Core > App > Web Application > Next. In version 8.6 or later, select Web and Console > App > Web Application > Next.

  3. In the Configure the new Web Application dialog:

    1. Confirm that Authentication is set to No Authentication.
    2. If presented an option to select a Target Framework, select the latest .NET 5.x version.
    3. Select Next.
  4. Name the project RazorPagesMovie and select Create.

Run the app

  • Press Ctrl+F5 to run without the debugger.

    Visual Studio displays the following dialog:

    Select Yes if you trust the IIS Express SSL certificate.

    The following dialog is displayed:

    Select Yes if you agree to trust the development certificate.

    For information on trusting the Firefox browser, see Firefox SEC_ERROR_INADEQUATE_KEY_USAGE certificate error.

    Visual Studio starts IIS Express and runs the app. The address bar shows localhost:port# and not something like example.com. That's because localhost is the standard hostname for the local computer. Localhost only serves web requests from the local computer. When Visual Studio creates a web project, a random port is used for the web server.

  • Trust the HTTPS development certificate by running the following command:

    The preceding command doesn't work on Linux. See your Linux distribution's documentation for trusting a certificate.

    The preceding command displays the following dialog:

  • Select Yes if you agree to trust the development certificate.

    See Trust the ASP.NET Core HTTPS development certificate for more information.

For information on trusting the Firefox browser, see Firefox SEC_ERROR_INADEQUATE_KEY_USAGE certificate error.

  • Press Ctrl-F5 to run without the debugger.

    Visual Studio Code starts Kestrel, launches a browser, and navigates to http://localhost:5001. The address bar shows localhost:port# and not something like example.com. That's because localhost is the standard hostname for local computer. Localhost only serves web requests from the local computer.

Visual Studio for Mac displays the following popup:

Select Yes if you trust the development certificate.

The following dialog is displayed:

Enter your password and select OK

Select Yes if you agree to trust the development certificate.

See Trust the ASP.NET Core HTTPS development certificate for more information

  • From Visual Studio, press Opt-Cmd-Return to run without the debugger. Alternatively, navigate to the menu bar and go to Run>Start Without Debugging.

    Visual Studio starts Kestrel, launches a browser, and navigates to http://localhost:5001.

Examine the project files

Here's an overview of the main project folders and files that you'll work with in later tutorials.

Pages folder

Contains Razor pages and supporting files. Each Razor page is a pair of files:

  • A .cshtml file that has HTML markup with C# code using Razor syntax.
  • A .cshtml.cs file that has C# code that handles page events.

Visual Studio Code 2019 Windows

Supporting files have names that begin with an underscore. For example, the _Layout.cshtml file configures UI elements common to all pages. This file sets up the navigation menu at the top of the page and the copyright notice at the bottom of the page. For more information, see Layout in ASP.NET Core.

wwwroot folder

Contains static assets, like HTML files, JavaScript files, and CSS files. For more information, see Static files in ASP.NET Core.

appsettings.json

Contains configuration data, like connection strings. For more information, see Configuration in ASP.NET Core.

Program.cs

Contains the entry point for the app. For more information, see .NET Generic Host in ASP.NET Core.

Startup.cs

Contains code that configures app behavior. For more information, see App startup in ASP.NET Core.

Next steps

This is the first tutorial of a series that teaches the basics of building an ASP.NET Core Razor Pages web app.

For a more advanced introduction aimed at developers who are familiar with controllers and views, see Introduction to Razor Pages.

At the end of the series, you'll have an app that manages a database of movies.

View or download sample code (how to download).

In this tutorial, you:

  • Create a Razor Pages web app.
  • Run the app.
  • Examine the project files.

At the end of this tutorial, you'll have a working Razor Pages web app that you'll build on in later tutorials.

Prerequisites

  • Visual Studio 2019 16.4 or later with the ASP.NET and web development workload

The Visual Studio Code instructions use the .NET Core CLI for ASP.NET Core development functions such as project creation. You can follow these instructions on any platform (macOS, Linux, or Windows) and with any code editor. Minor changes may be required if you use something other than Visual Studio Code. For more information on installing Visual Studio Code on macOS, see Visual Studio Code on macOS.

Create a Razor Pages web app

  • From the Visual Studio File menu, select New > Project.

  • Create a new ASP.NET Core Web Application and select Next.

  • Name the project RazorPagesMovie. It's important to name the project RazorPagesMovie so the namespaces will match when you copy and paste code.

  • Select ASP.NET Core 3.1 in the dropdown, Web Application, and then select Create.

The following starter project is created:

  • Open the integrated terminal.

  • Change to the directory (cd) which will contain the project.

  • Run the following commands:

    • The dotnet new command creates a new Razor Pages project in the RazorPagesMovie folder.
    • The code command opens the RazorPagesMovie folder in the current instance of Visual Studio Code.
  • After the status bar's OmniSharp flame icon turns green, a dialog asks Required assets to build and debug are missing from 'RazorPagesMovie'. Add them? Select Yes.

    A .vscode directory, containing launch.json and tasks.json files, is added to the project's root directory.

  • Select File > New Solution.

  • In Visual Studio for Mac earlier than version 8.6, select .NET Core > App > Web Application > Next. In version 8.6 or later, select Web and Console > App > Web Application > Next.

  • In the Configure the new Web Application dialog:

    • Confirm that Authentication is set to No Authentication.
    • If presented an option to select a Target Framework, select the latest 3.x version.

    Select Next.

  • Name the project RazorPagesMovie, and then select Create.

Run the app

  • Press Ctrl+F5 to run without the debugger.

    Visual Studio displays the following dialog:

    Select Yes if you trust the IIS Express SSL certificate.

    The following dialog is displayed:

    Select Yes if you agree to trust the development certificate.

    For information on trusting the Firefox browser, see Firefox SEC_ERROR_INADEQUATE_KEY_USAGE certificate error.

    Visual Studio starts IIS Express and runs the app. The address bar shows localhost:port# and not something like example.com. That's because localhost is the standard hostname for the local computer. Localhost only serves web requests from the local computer. When Visual Studio creates a web project, a random port is used for the web server.

  • Trust the HTTPS development certificate by running the following command:

    The preceding command doesn't work on Linux. See your Linux distribution's documentation for trusting a certificate.

    The preceding command displays the following dialog:

  • Select Yes if you agree to trust the development certificate.

    See Trust the ASP.NET Core HTTPS development certificate for more information.

For information on trusting the Firefox browser, see Firefox SEC_ERROR_INADEQUATE_KEY_USAGE certificate error.

  • Press Ctrl-F5 to run without the debugger.

    Visual Studio Code starts Kestrel, launches a browser, and navigates to http://localhost:5001. The address bar shows localhost:port# and not something like example.com. That's because localhost is the standard hostname for local computer. Localhost only serves web requests from the local computer.

Visual Studio for Mac displays the following popup:

Select Yes if you trust the development certificate.

The following dialog is displayed:

Enter your password and select OK

Select Yes if you agree to trust the development certificate.

See Trust the ASP.NET Core HTTPS development certificate for more information

  • From Visual Studio, press Opt-Cmd-Return to run without the debugger. Alternatively, navigate to the menu bar and go to Run>Start Without Debugging.

    Visual Studio starts Kestrel, launches a browser, and navigates to http://localhost:5001.

Examine the project files

Here's an overview of the main project folders and files that you'll work with in later tutorials.

Pages folder

Contains Razor pages and supporting files. Each Razor page is a pair of files:

  • A .cshtml file that has HTML markup with C# code using Razor syntax.
  • A .cshtml.cs file that has C# code that handles page events.

Supporting files have names that begin with an underscore. For example, the _Layout.cshtml file configures UI elements common to all pages. This file sets up the navigation menu at the top of the page and the copyright notice at the bottom of the page. For more information, see Layout in ASP.NET Core.

wwwroot folder

Contains static files, like HTML files, JavaScript files, and CSS files. For more information, see Static files in ASP.NET Core.

appSettings.json

Contains configuration data, like connection strings. For more information, see Configuration in ASP.NET Core.

Program.cs

Contains the entry point for the program. For more information, see .NET Generic Host in ASP.NET Core.

Startup.cs

Contains code that configures app behavior. For more information, see App startup in ASP.NET Core.

Next steps

This is the first tutorial of a series. The series teaches the basics of building an ASP.NET Core Razor Pages web app.

Visual studio code 2019 free

For a more advanced introduction aimed at developers who are familiar with controllers and views, see Introduction to Razor Pages.

At the end of the series, you'll have an app that manages a database of movies.

View or download sample code (how to download).

In this tutorial, you:

  • Create a Razor Pages web app.
  • Run the app.
  • Examine the project files.

At the end of this tutorial, you'll have a working Razor Pages web app that you'll build on in later tutorials.

Prerequisites

  • Visual Studio 2019 with the ASP.NET and web development workload

Warning

If you use Visual Studio 2017, see dotnet/sdk issue #3124 for information about .NET Core SDK versions that don't work with Visual Studio.

The Visual Studio Code instructions use the .NET Core CLI for ASP.NET Core development functions such as project creation. You can follow these instructions on any platform (macOS, Linux, or Windows) and with any code editor. Minor changes may be required if you use something other than Visual Studio Code.

Create a Razor Pages web app

  • From the Visual Studio File menu, select New > Project.

  • Create a new ASP.NET Core Web Application and select Next.

  • Name the project RazorPagesMovie. It's important to name the project RazorPagesMovie so the namespaces will match when you copy and paste code.

  • Select ASP.NET Core 2.2 in the dropdown, Web Application, and then select Create.

Visual Studio Code 2019 Offline Installer

The following starter project is created:

  • Open the integrated terminal.

  • Change to the directory (cd) which will contain the project.

  • Run the following commands:

    • The dotnet new command creates a new Razor Pages project in the RazorPagesMovie folder.
    • The code command opens the RazorPagesMovie folder in the current instance of Visual Studio Code.
  • After the status bar's OmniSharp flame icon turns green, a dialog asks Required assets to build and debug are missing from 'RazorPagesMovie'. Add them? Select Yes.

    A .vscode directory, containing launch.json and tasks.json files, is added to the project's root directory.

  • Select File > New Solution.
  • In Visual Studio for Mac earlier than version 8.6, select .NET Core > App > Web Application > Next. In version 8.6 or later, select Web and Console > App > Web Application > Next.

  • In the Configure the new Web Application dialog:

    • Confirm that Authentication is set to No Authentication.
    • If presented an option to select a Target Framework, select the latest 2.x version.

    Select Next.

  • Name the project RazorPagesMovie, and then select Create.

Run the app

  • Press Ctrl+F5 to run without the debugger.

    Launching the app with Ctrl+F5 (non-debug mode) allows you to make code changes, save the file, refresh the browser, and see the code changes. Many developers prefer to use non-debug mode to quickly launch the app and view changes.

    Visual Studio displays the following dialog:

    Select Yes if you trust the IIS Express SSL certificate.

    The following dialog is displayed:

    Select Yes if you agree to trust the development certificate.

    For information on trusting the Firefox browser, see Firefox SEC_ERROR_INADEQUATE_KEY_USAGE certificate error.

    Visual Studio starts IIS Express and runs the app. The address bar shows localhost:port# and not something like example.com. That's because localhost is the standard hostname for the local computer. Localhost only serves web requests from the local computer. When Visual Studio creates a web project, a random port is used for the web server.

  • On the app's home page, select Accept to consent to tracking.

    This app doesn't track personal information, but the project template includes the consent feature in case you need it to comply with the European Union's General Data Protection Regulation (GDPR).

    The following image shows the app after consent to tracking is provided:

  • Trust the HTTPS development certificate by running the following command:

    The preceding command doesn't work on Linux. See your Linux distribution's documentation for trusting a certificate.

    The preceding command displays the following dialog:

  • Select Yes if you agree to trust the development certificate.

    See Trust the ASP.NET Core HTTPS development certificate for more information.

For information on trusting the Firefox browser, see Firefox SEC_ERROR_INADEQUATE_KEY_USAGE certificate error.

  • Press Ctrl+F5 to run without the debugger.

    Launching the app with Ctrl+F5 (non-debug mode) allows you to make code changes, save the file, refresh the browser, and see the code changes. Many developers prefer to use non-debug mode to quickly launch the app and view changes.

    Visual Studio Code starts Kestrel, launches a browser, and goes to http://localhost:5001. The address bar shows localhost:port# and not something like example.com. That's because localhost is the standard hostname for the local computer. Localhost only serves web requests from the local computer.

  • On the app's home page, select Accept to consent to tracking.

    This app doesn't track personal information, but the project template includes the consent feature in case you need it to comply with the European Union's General Data Protection Regulation (GDPR).

    The following image shows the app after you give consent to tracking:

Visual Studio for Mac displays the following popup:

Select Yes if you trust the development certificate.

The following dialog is displayed:

Enter your password and select OK

Select Yes if you agree to trust the development certificate.

See Trust the ASP.NET Core HTTPS development certificate for more information

  • Press Cmd-Opt-F5 to run without the debugger.

    Launching the app with Cmd+Opt+F5 (non-debug mode) allows you to make code changes, save the file, refresh the browser, and see the code changes. Many developers prefer to use non-debug mode to quickly launch the app and view changes.

    Visual Studio starts Kestrel, launches a browser, and goes to http://localhost:5001.

  • On the app's home page, select Accept to consent to tracking.

    This app doesn't track personal information, but the project template includes the consent feature in case you need it to comply with the European Union's General Data Protection Regulation (GDPR).

    The following image shows the app after consent to tracking is provided:

Examine the project files

Here's an overview of the main project folders and files that you'll work with in later tutorials.

Pages folder

Contains Razor pages and supporting files. Each Razor page is a pair of files:

  • A .cshtml file that has HTML markup with C# code using Razor syntax.
  • A .cshtml.cs file that has C# code that handles page events.

Supporting files have names that begin with an underscore. For example, the _Layout.cshtml file configures UI elements common to all pages. This file sets up the navigation menu at the top of the page and the copyright notice at the bottom of the page. For more information, see Layout in ASP.NET Core.

Razor Pages are derived from PageModel. By convention, the PageModel-derived class is named <PageName>Model.

wwwroot folder

Contains static files, like HTML files, JavaScript files, and CSS files. For more information, see Static files in ASP.NET Core.

appSettings.json

Contains configuration data, like connection strings. For more information, see Configuration in ASP.NET Core.

Program.cs

Contains the entry point for the program. For more information, see .NET Generic Host in ASP.NET Core.

Startup.cs

Contains code that configures app behavior, such as whether it requires consent for cookies. For more information, see App startup in ASP.NET Core.

Additional resources

Visual Studio Code 2019 C++

Next steps