Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VS2017 RTM initial update #1663

Merged
merged 6 commits into from
Mar 8, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
renames
  • Loading branch information
mairaw committed Mar 7, 2017
commit 6b31e5ac23af009261f22346c021407cb9e330c2
5 changes: 5 additions & 0 deletions .openpublishing.redirection.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
"source_path": "docs/csharp/features.md",
"redirect_url": "/dotnet/articles/csharp/concepts"
},
{
"source_path": "docs/csharp/getting-started/with-visual-studio-2017.md",
"redirect_url": "/dotnet/articles/getting-started/with-visual-studio",
"redirect_document_id": true
},
{
"source_path": "docs/csharp/getting-started/library-with-visual-studio_2017.md",
"redirect_url": "/dotnet/articles/csharp/getting-started/library-with-visual-studio-2017"
Expand Down
2 changes: 1 addition & 1 deletion docs/core/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Install .NET Core on [Windows](https://www.microsoft.com/net/core#windows).

You can get started developing .NET Core apps by following these step-by-step tutorials.

* [Building a C# Hello World Application with .NET Core in Visual Studio 2017](../csharp/getting-started/with-visual-studio-2017.md) - Learn to to build, debug, and publish a simple .NET Core console application using Visual Studio 2017.
* [Building a C# Hello World Application with .NET Core in Visual Studio 2017](../csharp/getting-started/with-visual-studio.md) - Learn to to build, debug, and publish a simple .NET Core console application using Visual Studio 2017.
* [Building a class library with C# and .NET Core in Visual Studio 2017](../csharp/getting-started/library-with-visual-studio-2017.md) - Learn how to build a class library written in C# using Visual Studio 2017
* [Get started with Visual Studio Code using C# and .NET Core on Windows](https://channel9.msdn.com/Blogs/dotnet/Get-started-with-VS-Code-using-CSharp-and-NET-Core) - This [Channel9](https://channel9.msdn.com) video shows you how to install and use [Visual Studio Code](https://www.visualstudio.com/products/code-vs), Microsoft's lightweight cross-platform code editor, to create your first console application in .NET Core.
* [Getting started with .NET Core using the command-line](tutorials/using-with-xplat-cli.md) - Use any code editor with the [.NET Core cross-platform command-line interface (CLI)](tools/index.md).
Expand Down
2 changes: 1 addition & 1 deletion docs/core/tutorials/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ The following tutorials are available for learning about .NET Core.

## Building applications with Visual Studio 2017

- [Building a C# Hello World application](../../csharp/getting-started/with-visual-studio-2017.md)
- [Building a C# Hello World application](../../csharp/getting-started/with-visual-studio.md)
- [Debugging your C# Hello World application](../../csharp/getting-started/debugging-with-visual-studio-2017.md)
- [Publishing your C# Hello World application](../../csharp/getting-started/publishing-with-visual-studio-2017.md)
- [Building a C# class library](../../csharp/getting-started/library-with-visual-studio-2017.md)
Expand Down
2 changes: 1 addition & 1 deletion docs/core/tutorials/netcore-hosting.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ This article gives an overview of the steps necessary to start the .NET Core run

Because hosts are native applications, this tutorial will cover constructing a C++ application to host .NET Core. You will need a C++ development environment (such as that provided by [Visual Studio](https://www.visualstudio.com/downloads/)).

You will also want a simple .NET Core application to test the host with, so you should install the [.NET Core SDK](https://www.microsoft.com/net/core) and [build a small .NET Core test app](https://github.com/dotnet/docs/blob/master/docs/csharp/getting-started/with-visual-studio.md) (such as a 'Hello World' app). The 'Hello World' app created by the new .NET Core console project template is sufficient.
You will also want a simple .NET Core application to test the host with, so you should install the [.NET Core SDK](https://www.microsoft.com/net/core) and [build a small .NET Core test app](../../csharp/getting-started/with-visual-studio.md) (such as a 'Hello World' app). The 'Hello World' app created by the new .NET Core console project template is sufficient.

This tutorial and its [associated sample](https://github.com/dotnet/docs/tree/master/samples/core/hosting) build a Windows host, but please see the notes at the end of this article about hosting on Unix.

Expand Down
2 changes: 1 addition & 1 deletion docs/core/tutorials/using-on-windows.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ redirect_url: /dotnet/articles/csharp/getting-started/with-visual-studio-2017

## Content retired!

For a getting started tutorial on .NET Core and Visual Studio 2017, see [(Building a C# Hello World application with .NET Core in Visual Studio 2017](../../csharp/getting-started/with-visual-studio-2017.md).
For a getting started tutorial on .NET Core and Visual Studio 2017, see [(Building a C# Hello World application with .NET Core in Visual Studio 2017](../../csharp/getting-started/with-visual-studio.md).
Binary file removed docs/csharp/getting-started/media/breakpoint.jpg
Binary file not shown.
Binary file modified docs/csharp/getting-started/media/codewindow.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file modified docs/csharp/getting-started/media/console.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file modified docs/csharp/getting-started/media/vs_devenv.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
5 changes: 1 addition & 4 deletions docs/csharp/getting-started/toc.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
## [Building a class library with C# and .NET Core in Visual Studio 2017](library-with-visual-studio-2017.md)
### [Testing a class library with .NET Core in Visual Studio 2017](testing-library-with-visual-studio.md)
### [Consuming a class library with .NET Core in Visual Studio 2017](consuming-library-with-visual-studio-2017.md)
## [Getting started with Visual Studio 2015](with-visual-studio.md)
### [Debugging your Hello World application with Visual Studio 2015](debugging-with-visual-studio.md)
### [Publishing your Hello World application with Visual Studio 2015](publishing-with-visual-studio.md)
## [Getting started with Visual Studio Code](with-visual-studio-code.md)
## [🔧 Getting started with cross-platform tools](with-cross-platform-tools.md)
## [🔧 Getting started with C# Interactive](with-csharp-interactive.md)
## [🔧 Getting started with C# Interactive](with-csharp-interactive.md)
89 changes: 0 additions & 89 deletions docs/csharp/getting-started/with-visual-studio-2017.md

This file was deleted.

88 changes: 84 additions & 4 deletions docs/csharp/getting-started/with-visual-studio.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,89 @@
---
redirect_url: /dotnet/articles/csharp/getting-started/with-visual-studio-2017
title: Building a C# Hello World Application with .NET Core in Visual Studio 2017
description: Learn how to build a simple .NET Core console application using Visual Studio 2017.
keywords: .NET Core, .NET Core console application, Visual Studio 2017
author: stevehoag
ms.author: shoag
ms.date: 03/07/2016
ms.topic: article
ms.prod: .net-core
ms.technology: devlang-csharp
ms.devlang: csharp
ms.assetid: 97aa50bf-bdf8-416d-a56c-ac77504c14ea
---

# Building a C# Hello World Application with .NET Core in Visual Studio 2015 #
# Building a C# Hello World application with .NET Core in Visual Studio 2017 #

## Content retired!
This topic provides a step-by-step introduction to building, debugging, and publishing a simple .NET Core console application using Visual Studio 2017. Visual Studio 2017 provides a full-featured development environment for building .NET Core applications. As long as the application does not have any platform-specific dependencies, the application itself can run on any platform that .NET Core targets and on any system that has .NET Core installed.

For a getting started tutorial on .NET Core and Visual Studio 2017, see [(Building a C# Hello World application with .NET Core in Visual Studio 2017](with-visual-studio-2017.md).
## Prerequisites ##

- [Visual Studio 2017](https://www.visualstudio.com/downloads/) with the ".NET Core cross-platform development" workload installed.

For more information, see the [Visual Studio 2017](../../core/windows-prerequisites.md) section on the Windows prerequisites topic.

## A simple "Hello World" application ##

Let's begin by creating a simple "Hello World" console application. Here are the steps:

1. Launch Visual Studio and, on the **File** menu, choose **New**, **Project**. In the **New Project** dialog, expand the **Visual C#** node in the left-hand pane, then choose the **.NET Core** node.

2. In the right-hand pane, choose **Console App (.NET Core)**. Enter the name of the project, `HelloWorld`, and make sure that the **Create directory for solution** box is checked, as the following figure shows.

![Screenshot showing the New Project dialog with Console App selected](./media/vs_newproject_2017.jpg)

3. Choose the **OK** button. Visual Studio displays its development environment with its code window, as the following figure shows. The C# Console Application template for .NET Core automatically defines a class, `Program`, with a single method, `Main`, that takes a @System.String array as an argument. `Main` is the application entry point, the method that is called automatically by the runtime when it launches the application. Any command-line arguments supplied when the application is launched are available in the *args* array.

![Visual Studio and the new HelloWorld project](./media/vs_devenv.jpg)

The template creates a very simple "Hello world" application -- it calls the @System.Console.WriteLine(System.String) method to display the literal string "Hello world!" to the console window. By selecting the "HelloWorld" button with the green arrow on the toolbar, you can run the program in Debug mode now. If you do, though, the console window is visible for only a very brief time interval before it closes. This occurs because the `Main` terminates and the application ends as soon as the single statement in the `Main` method executes.

4. Let's have our existing application pause before it closes the console window. Add the following code immediately after the call to the @System.Console.WriteLine(System.String) method:

```cs
Console.Write("Press any key to continue...");
Console.ReadKey(true);
```
This code prompts the user to press any key and then pauses the program until a key is pressed.

5. On the menu bar, choose **Build**, **Build Solution**. This compiles your program to IL, an intermediate language that is then converted to binary code by a just-in-time (JIT) compiler.

6. Run the program by selecting the "HelloWorld" button with the green arrow on the toolbar. The result is shown in the following figure.

![Image](./media/simple_hello.jpg)

7. Press any key to close the window.

## Enhancing the "Hello World" application ##

Let's enhance our application to prompt the user for his or her name and then display it along with the date and time to the console window. To modify and test the program, do the following:

1. Enter the following C# code in the code window immediately after the opening bracket that follows the `public static void Main(string[] args)` line and before the first closing bracket.

[!CODE [GettingStarted#1](../../../samples/snippets/csharp/getting_started/with_visual_studio/helloworld.cs#1)]

The following figure shows the resulting code window.

![The modified program running](./media/codewindow.jpg)

This code displays "What is your name?" to the console and waits until the user enters a string followed by the Enter key. It stores this string to a variable named `name`. It also retrieves the value of the @System.DateTime.Now property, which contains the current local time, and assigns it to a variable named `date`. It then uses a [composite format string](../../standard/base-types/composite-format.md) to display these values to the console.

2. Compile the program by choosing **Build**, **Build Solution**. This compiles your program to IL, an intermediate language that is then converted to binary code by a just-in-time (JIT) compiler.

3. Run the program in debug mode in Visual Studio by selecting the green arrow on the toolbar, pressing F5, or choosing the **Debug**, **Start Debugging** menu item. After you respond to the prompts by entering a name and pressing the Enter key, the console window should look something like the following:

![The modified program running](./media/console.jpg)

4. Press any key to close the console window. This ends debug mode.

You've now created and run your simple application. To develop a professional application, there are still some additional steps that you can take to make your application ready for release:

- For information on debugging your application, see [Debugging the Hello World Application](debugging-with-visual-studio-2017.md)

- For information on developing a publishing a distributable version of your application, see [Publishing the Hello World application](publishing-with-visual-studio-2017.md).

## Related topics ##

Instead of a console application, you can also build a class library with .NET Core and Visual Studio 2017. For a step-by-step introduction, see [Building a class library with C# and .NET Core in Visual Studio 2017](../../core/tutorials/library-with-visual-studio-2017.md).

You can also develop a .NET Core console app on Mac, Linux, and Windows by using Visual Studio Code, a freely downloadable code editor. For a step-by-step tutorial, see [Getting Started with Visual Studio Code](with-visual-studio-code.md).more changes
2 changes: 1 addition & 1 deletion styleguide/template.md
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ You can see an example of buttons in action at the [Intune docs](https://docs.mi

> [!div class="op_single_selector"]
- [macOS](../docs/core/tutorials/using-on-macos.md)
- [Windows](../docs/csharp/getting-started/with-visual-studio-2017.md)
- [Windows](../docs/csharp/getting-started/with-visual-studio.md)

You can see an example of selectors in action at the [Intune docs](https://docs.microsoft.com/en-us/intune/deploy-use/what-to-tell-your-end-users-about-using-microsoft-intune#how-your-end-users-get-their-apps).

Expand Down