Skip to content

Updating CLI golden path documents for preview 3 #1243

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

Merged
merged 9 commits into from
Nov 17, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
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
24 changes: 24 additions & 0 deletions docs/core/preview3/tutorials/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
title: .NET Core Tutorials (Tooling Preview 3)
description: .NET Core Tutorials (Tooling Preview 3)
keywords: .NET, .NET Core
author: beleroy
manager: wpickett
ms.date: 06/24/2016
ms.topic: article
ms.prod: .net-core
ms.technology: .net-core-technologies
ms.devlang: dotnet
ms.assetid: f6f654b1-1d2c-4105-8376-7c1959e23803
---

# .NET Core Tutorials (Tooling Preview 3)

The following tutorials are available for learning about .NET Core using Preview 3 of the tooling.

- [Getting started with .NET Core on Windows/Linux/macOS using the command line (SDK Preview 3)](using-with-xplat-cli-msbuild.md)
- [Organizing and testing projects with the .NET Core command line (SDK Preview 3)](using-with-xplat-cli-msbuild-folders.md)
- [Getting started with .NET Core on Windows, using Visual Studio 2017](using-on-windows-vs-2017.md)
- [Building a complete .NET Core solution on Windows, using Visual Studio 2017](using-on-windows-vs-2017-full-solution.md)

For tutorials about developing ASP.NET Core web applications, we suggest you head over to [ASP.NET Core documentation](https://docs.asp.net).
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
---
title: Building a complete .NET Core solution on Windows, using Visual Studio 2017
description: Building a complete .NET Core solution on Windows, using Visual Studio 2017
keywords: .NET, .NET Core
author: bleroy
manager: wpickett
ms.date: 11/16/2016
ms.topic: article
ms.prod: .net-core
ms.technology: .net-core-technologies
ms.devlang: dotnet
ms.assetid: d743134a-08a3-4ff6-aab7-49f71f0568c3
---

# Building a complete .NET Core solution on Windows, using Visual Studio 2017

by [Bertrand Le Roy](https://github.com/bleroy) and [Phillip Carter](https://github.com/cartermp)

Visual Studio 2017 provides a full-featured development environment for developing .NET Core applications. The procedures in this document describe the steps necessary to build a typical .NET Core solution that includes reusable libraries, testing, and using third-party libraries.

## Prerequisites

Follow the instructions on [our prerequisites page](../windows-prerequisites.md) to update your environment.

# A solution using only .NET Core projects

## Writing the library

1. In Visual Studio, choose **File**, **New**, **Project**. In the **New Project** dialog, expand the **Visual C#** node and choose the **.NET Core** node, and then choose **Class Library (.NET Standard)**.

2. Name the project "Library" and the solution "Golden". Leave **Create directory for solution** checked. Click **OK**.

3. In Solution Explorer, open the context menu for the **Dependencies** node and choose **Manage NuGet Packages**.

4. Choose "nuget.org" as the **Package source**, and choose the **Browse** tab. Browse for **Newtonsoft.Json**. Click **Install**, and accept the license agreement. The package should now appear under **Dependencies/NuGet** and be automatically restored.

5. Rename the `Class1.cs` file to `Thing.cs`. Accept the rename of the class. Add a method: `public int Get(int number) => Newtonsoft.Json.JsonConvert.DeserializeObject<int>($"{number}");`

7. On the **Build** menu, choose **Build Solution**.

The solution should build without error.

### Writing the test project

1. In Solution Explorer, open the context menu for the **Solution** node and choose **Add**, **New Project**. In the **New Project** dialog, under **Visual C# / .NET Core**, choose **Unit Test Project (.NET Core)**. Name it "TestLibrary" and click OK.

2. In the **TestLibrary** project, open the context menu for the **Dependencies** node and choose **Add Reference**. Click **Projects**, then check the Library project and click OK. This adds a reference to your library from the test project.

3. Rename the `UnitTest1.cs` file to `LibraryTests.cs` and accept the class rename. Add `using Library;` to the top of the file, and replace the `TestMethod1` method with the following code:
```csharp
[TestMethod]
public void ThingGetsObjectValFromNumber()
{
Assert.AreEqual(42, new Thing().Get(42));
}
```

You should now be able to build the solution.

4. On the **Test** menu, choose **Windows**, **Test Explorer** in order to get the test explorer window into your workspace. After a few seconds, the `ThingGetsObjectValFromNumber` test should appear in the test explorer. Choose **Run All**.

The test should pass.

### Writing the console app

1. In Solution Explorer, open the context menu for the solution, and add a new **Console App (.NET Core)** project. Name it "App", and set the location to `Golden\src`.

2. In the **App** project, open the context menu for the **Dependencies** node and choose **Add**, **Reference**.

3. In the **Reference Manager** dialog, check **Library** under the **Projects**, **Solution** node, and then click **OK**

6. Open the context menu for the **App** node and choose **Set as StartUp Project**. This ensures that hitting F5 or CTRL+F5 will start the console app.

7. Open the `Program.cs` file, add a `using Library;` directive to the top of the file, and then add `Console.WriteLine($"The answer is {new Thing().Get(42)}");` to the `Main` method.

8. Set a breakpoint after the line that you just added.

9. Press F5 to run the application..

The application should build without error, and should hit the breakpoint. You should also be able to check that the application output "The answer is 42.".
45 changes: 45 additions & 0 deletions docs/core/preview3/tutorials/using-on-windows-vs-2017.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
title: Getting started with .NET Core on Windows, using Visual Studio 2017
description: Getting started with .NET Core on Windows, using Visual Studio 2017
keywords: .NET, .NET Core
author: bleroy
manager: wpickett
ms.date: 11/16/2016
ms.topic: article
ms.prod: .net-core
ms.technology: .net-core-technologies
ms.devlang: dotnet
ms.assetid: d743134a-08a3-4ff6-aab7-49f71f0568c3
---

# Getting started with .NET Core on Windows, using Visual Studio 2017

by [Bertrand Le Roy](https://github.com/bleroy) and [Phillip Carter](https://github.com/cartermp)

Visual Studio 2017 provides a full-featured development environment for developing .NET Core applications. The procedures in this document describe the steps necessary to build a very simple console application, using Visual Studio and .NET Core.

## Prerequisites

Follow the instructions on [our prerequisites page](../windows-prerequisites.md) to update your environment.

## Getting Started

The following steps will set up Visual Studio 2017 for .NET Core console application development:

1. Open Visual Studio, and on the **File** menu, choose **New**, **Project**.

2. In the **New Project** dialog, in the **Templates** list, expand the **Visual C#** node and choose **.NET Core**. You should see three four project templates for **Console App (.NET Core)**, **Unit Test Project (.NET Core)**, **Class Library (.NET Core)**, and **ASP.NET Core Web Application (.NET Core)**. Choose **Console App (.NET Core)**, type a name for your project, pick a location, then click OK.

![New project: console app](media/new-project-console-app.png)

3. The resulting project has a single C# file that will output "Hello World" to the console.

![The console app project](media/console-app-solution.png)

You may run this application in debug mode using F5, or in release mode using CTRL+F5. You may also set breakpoints to interrupt execution and inspect variables, or start writing more interesting code.

Happy coding!

## What to do next

After this simple introduction, you're probably wondering how to build more advanced solutions, with reusable libraries and tests. The [Building a complete .NET Core solution on Windows, using Visual Studio 2017](using-on-windows-vs-2017-full-solution) topic will show you how to do that.
Loading