Skip to content

Commit e0520bb

Browse files
authored
Merge pull request #2833 from corob-msft/cr-1794
Fix 1794 Confusion between solution and project directories
2 parents 1f2c29d + 89decc7 commit e0520bb

2 files changed

Lines changed: 53 additions & 34 deletions

File tree

docs/build/vscpp-step-1-create.md

Lines changed: 40 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
---
22
title: Create a C++ console app project
3-
description: "Create a Hello World console app in Visual C++"
3+
description: "Create a Hello World console app using Microsoft C++ in Visual Studio."
44
ms.custom: "mvc"
5-
ms.date: 04/02/2019
5+
ms.date: 04/20/2020
66
ms.topic: "tutorial"
7-
ms.devlang: "cpp"
87
ms.assetid: 45138d70-719d-42dc-90d7-1d0ca31a2f54
98
---
109
# Create a C++ console app project
@@ -17,24 +16,26 @@ The usual starting point for a C++ programmer is a "Hello, world!" application t
1716

1817
## Create your app project
1918

20-
Visual Studio uses *projects* to organize the code for an app, and *solutions* to organize your projects. A project contains all the options, configurations, and rules used to build your apps, and manages the relationship between all the project's files and any external files. To create your app, first, you'll create a new project and solution.
19+
Visual Studio uses *projects* to organize the code for an app, and *solutions* to organize your projects. A project contains all the options, configurations, and rules used to build your apps. It manages the relationship between all the project's files and any external files. To create your app, first, you'll create a new project and solution.
2120

2221
::: moniker range=">=vs-2019"
2322

24-
1. In Visual Studio, open the **File** menu and choose **New** > **Project** to open the **Create a new Project** dialog. Select the **Console App** template, and then choose **Next**.
23+
1. In Visual Studio, open the **File** menu and choose **New > Project** to open the **Create a new Project** dialog. Select the **Console App** template that has **C++**, **Windows**, and **Console** tags, and then choose **Next**.
2524

2625
![Create a new project](media/vs2019-choose-console-app.png "Open the Create a new project dialog")
2726

2827
1. In the **Configure your new project** dialog, enter *HelloWorld* in the **Project name** edit box. Choose **Create** to create the project.
2928

3029
![Name and create the new project](media/vs2019-configure-new-project-hello-world.png "Name and create the new project")
3130

32-
Visual Studio creates a new project, ready for you to add and edit your source code. By default, the Console App template fills in your source code with a "Hello World" app:
31+
Visual Studio creates a new project. It's ready for you to add and edit your source code. By default, the Console App template fills in your source code with a "Hello World" app:
3332

3433
![Hello World project in the IDE](media/vs2019-hello-world-code.png "Hello World project in the IDE")
3534

3635
When the code looks like this in the editor, you're ready to go on to the next step and build your app.
3736

37+
[I ran into a problem.](#create-your-app-project-issues)
38+
3839
::: moniker-end
3940

4041
::: moniker range="<=vs-2017"
@@ -43,21 +44,21 @@ Visual Studio uses *projects* to organize the code for an app, and *solutions* t
4344

4445
![Open the New Project dialog](media/vscpp-file-new-project.gif "Open the New Project dialog")
4546

46-
1. In the **New Project** dialog, select **Installed**, **Visual C++** if it isn't selected already, and then choose the **Empty Project** template. In the **Name** field, enter *HelloWorld*. Choose **OK** to create the project.
47+
1. In the **New Project** dialog, select **Installed > Visual C++** if it isn't selected already, and then choose the **Empty Project** template. In the **Name** field, enter *HelloWorld*. Choose **OK** to create the project.
4748

4849
![Name and create the new project](media/vscpp-concierge-project-name-callouts.png "Name and create the new project")
4950

50-
Visual Studio creates a new, empty project, ready for you to specialize for the kind of app you want to create and to add your source code files. You'll do that next.
51+
Visual Studio creates a new, empty project. It's ready for you to specialize for the kind of app you want to create and to add your source code files. You'll do that next.
5152

5253
[I ran into a problem.](#create-your-app-project-issues)
5354

5455
## Make your project a console app
5556

56-
Visual Studio can create all kinds of apps and components for Windows and other platforms. The **Empty Project** template isn't specific about what kind of app it creates. To create a *console app*, one that runs in a console or command prompt window, you must tell Visual Studio to build your app to use the console subsystem.
57+
Visual Studio can create all kinds of apps and components for Windows and other platforms. The **Empty Project** template isn't specific about what kind of app it creates. A *console app* is one that runs in a console or command prompt window. To create one, you must tell Visual Studio to build your app to use the console subsystem.
5758

5859
1. In Visual Studio, open the **Project** menu and choose **Properties** to open the **HelloWorld Property Pages** dialog.
5960

60-
1. In the **Property Pages** dialog, under **Configuration Properties**, select **Linker**, **System**, and then choose the edit box next to the **Subsystem** property. In the dropdown menu that appears, select **Console (/SUBSYSTEM:CONSOLE)**. Choose **OK** to save your changes.
61+
1. In the **Property Pages** dialog, select **Configuration Properties > Linker > System**, and then choose the edit box next to the **Subsystem** property. In the dropdown menu that appears, select **Console (/SUBSYSTEM:CONSOLE)**. Choose **OK** to save your changes.
6162

6263
![Open the Property Pages dialog](media/vscpp-properties-linker-subsystem.gif "Open the Property Pages dialog")
6364

@@ -106,39 +107,55 @@ When the code looks like this in the editor, you're ready to go on to the next s
106107
> [!div class="nextstepaction"]
107108
> [Build and run a C++ project](vscpp-step-2-build.md)
108109
109-
::: moniker range="<=vs-2017"
110-
111110
## Troubleshooting guide
112111
113112
Come here for solutions to common issues when you create your first C++ project.
114113
115-
### Create your app project issues
114+
### Create your app project: issues
115+
116+
::: moniker range="vs-2019"
116117
117-
If the **New Project** dialog doesn't show a **Visual C++** entry under **Installed**, your copy of Visual Studio probably doesn't have the **Desktop development with C++** workload installed. You can run the installer right from the **New Project** dialog. Choose the **Open Visual Studio Installer** link to start the installer again. If the **User Account Control** dialog requests permissions, choose **Yes**. In the installer, make sure the **Desktop development with C++** workload is checked, and choose **OK** to update your Visual Studio installation.
118+
The **New Project** dialog should show a **Console App** template that has **C++**, **Windows**, and **Console** tags. If you don't see it, there are two possible causes. It might be filtered out of the list, or it might not be installed. First, check the filter dropdowns at the top of the list of templates. Set them to **C++**, **Windows**, and **Console**. The C++ **Console App** template should appear; otherwise, the **Desktop development with C++** workload isn't installed.
119+
120+
To install **Desktop development with C++**, you can run the installer right from the **New Project** dialog. Choose the **Install more tools and features** link at the bottom of the template list to start the installer. If the **User Account Control** dialog requests permissions, choose **Yes**. In the installer, make sure the **Desktop development with C++** workload is checked. Then choose **Modify** to update your Visual Studio installation.
121+
122+
If another project with the same name already exists, choose another name for your project. Or, delete the existing project and try again. To delete an existing project, delete the solution folder (the folder that contains the *helloworld.sln* file) in File Explorer.
123+
124+
[Go back](#create-your-app-project).
125+
126+
::: moniker-end
127+
128+
::: moniker range="vs-2017"
129+
130+
If the **New Project** dialog doesn't show a **Visual C++** entry under **Installed**, your copy of Visual Studio probably doesn't have the **Desktop development with C++** workload installed. You can run the installer right from the **New Project** dialog. Choose the **Open Visual Studio Installer** link to start the installer again. If the **User Account Control** dialog requests permissions, choose **Yes**. Update the installer if necessary. In the installer, make sure the **Desktop development with C++** workload is checked, and choose **OK** to update your Visual Studio installation.
131+
132+
::: moniker-end
133+
134+
::: moniker range="<=vs-2017"
118135
119-
If another project with the same name already exists, choose another name for your project, or delete the existing project and try again. To delete an existing project, delete the solution folder (the folder that contains the helloworld.sln file) in File Explorer.
136+
If another project with the same name already exists, choose another name for your project. Or, delete the existing project and try again. To delete an existing project, delete the solution folder (the folder that contains the *helloworld.sln* file) in File Explorer.
120137
121138
[Go back](#create-your-app-project).
122139
123-
### Make your project a console app issues
140+
### Make your project a console app: issues
124141
125-
If you don't see **Linker** listed under **Configuration Properties**, choose **Cancel** to close the **Property Pages** dialog and then make sure that the **HelloWorld** project is selected in **Solution Explorer**, not the solution or another file or folder, before you try again.
142+
If you don't see **Linker** listed under **Configuration Properties**, choose **Cancel** to close the **Property Pages** dialog. Make sure that the **HelloWorld** project is selected in **Solution Explorer** before you try again. Don't select the **HelloWorld** solution, or another item, in **Solution Explorer**.
126143
127-
The dropdown control does not appear in the **SubSystem** property edit box until you select the property. You can select it by using the pointer, or you can press Tab to cycle through the dialog controls until **SubSystem** is highlighted. Choose the dropdown control or press Alt+Down to open it.
144+
The dropdown control doesn't appear in the **SubSystem** property edit box until you select the property. Click in the edit box to select it. Or, you can press **Tab** to cycle through the dialog controls until **SubSystem** is highlighted. Choose the dropdown control or press **Alt+Down** to open it.
128145
129146
[Go back](#make-your-project-a-console-app)
130147
131-
### Add a source code file issues
148+
### Add a source code file: issues
132149
133-
It's okay if you give the source code file a different name. However, don't add more than one source code file that contains the same code to your project.
150+
It's okay if you give the source code file a different name. However, don't add more than one file that contains the same code to your project.
134151
135-
If you added the wrong kind of file to your project, for example, a header file, delete it and try again. To delete the file, select it in **Solution Explorer** and press the Delete key.
152+
If you added the wrong file type to your project, such as a header file, delete it and try again. To delete the file, select it in **Solution Explorer**. Then press the **Delete** key.
136153
137154
[Go back](#add-a-source-code-file).
138155
139-
### Add code to the source file issues
156+
### Add code to the source file: issues
140157
141-
If you accidentally closed the source code file editor window, to open it again, double-click on HelloWorld.cpp in the **Solution Explorer** window.
158+
If you accidentally closed the source code file editor window, you can easily open it again. To open it, double-click on HelloWorld.cpp in the **Solution Explorer** window.
142159
143160
If red squiggles appear under anything in the source code editor, check that your code matches the example in spelling, punctuation, and case. Case is significant in C++ code.
144161

docs/build/vscpp-step-2-build.md

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,20 @@
22
title: Build and run a C++ console app project
33
description: "Build and run a Hello World console app in Visual C++"
44
ms.custom: "mvc"
5-
ms.date: 12/12/2017
5+
ms.date: 04/20/2020
66
ms.topic: "tutorial"
77
ms.devlang: "cpp"
88
ms.assetid: 45138d71-719d-42dc-90d7-1d0ca31a2f55
99
---
1010
# Build and run a C++ console app project
1111

12-
When you've created a C++ console app project and entered your code, you can build and run it within Visual Studio, and then run it as a stand-alone app from the command line.
12+
You've created a C++ console app project and entered your code. Now you can build and run it within Visual Studio. Then, run it as a stand-alone app from the command line.
1313

1414
## Prerequisites
1515

1616
- Have Visual Studio with the Desktop development with C++ workload installed and running on your computer. If it's not installed yet, follow the steps in [Install C++ support in Visual Studio](vscpp-step-0-installation.md).
1717

18-
- Create a "Hello, World!" project and enter its source code. If you haven't done this yet, follow the steps in [Create a C++ console app project](vscpp-step-1-create.md).
18+
- Create a "Hello, World!" project and enter its source code. If you haven't done this step yet, follow the steps in [Create a C++ console app project](vscpp-step-1-create.md).
1919

2020
If Visual Studio looks like this, you're ready to build and run your app:
2121

@@ -41,11 +41,11 @@ Congratulations! You've created your first "Hello, world!" console app in Visual
4141

4242
Normally, you run console apps at the command prompt, not in Visual Studio. Once your app is built by Visual Studio, you can run it from any command window. Here's how to find and run your new app in a command prompt window.
4343

44-
1. In **Solution Explorer**, select the HelloWorld solution and right-click to open the context menu. Choose **Open Folder in File Explorer** to open a **File Explorer** window in the HelloWorld solution folder.
44+
1. In **Solution Explorer**, select the HelloWorld solution (not the HelloWorld project) and right-click to open the context menu. Choose **Open Folder in File Explorer** to open a **File Explorer** window in the HelloWorld solution folder.
4545

46-
1. In the **File Explorer** window, open the Debug folder. This contains your app, HelloWorld.exe, and a couple of other debugging files. Select HelloWorld.exe, hold down the Shift key and right-click to open the context menu. Choose **Copy as path** to copy the path to your app to the clipboard.
46+
1. In the **File Explorer** window, open the Debug folder. This folder contains your app, *HelloWorld.exe*, and a couple of other debugging files. Hold down the **Shift** key and right-click on *HelloWorld.exe* to open the context menu. Choose **Copy as path** to copy the path to your app to the clipboard.
4747

48-
1. To open a command prompt window, press Windows-R to open the **Run** dialog. Enter *cmd.exe* in the **Open** textbox, then choose **OK** to run a command prompt window.
48+
1. To open a command prompt window, press **Windows+R** to open the **Run** dialog. Enter *cmd.exe* in the **Open** textbox, then choose **OK** to run a command prompt window.
4949

5050
1. In the command prompt window, right-click to paste the path to your app into the command prompt. Press Enter to run your app.
5151

@@ -57,23 +57,25 @@ Congratulations, you've built and run a console app in Visual Studio!
5757

5858
## Next Steps
5959

60-
Once you've built and run this simple app, you're ready for more complex projects. See [Using the Visual Studio IDE for C++ Desktop Development](../ide/using-the-visual-studio-ide-for-cpp-desktop-development.md) for more detailed walkthroughs that explore the capabilities of Visual C++ in Visual Studio.
60+
Once you've built and run this simple app, you're ready for more complex projects. For more information, see [Using the Visual Studio IDE for C++ Desktop Development](../ide/using-the-visual-studio-ide-for-cpp-desktop-development.md). It has more detailed walkthroughs that explore the capabilities of Microsoft C++ in Visual Studio.
6161

6262
## Troubleshooting guide
6363

6464
Come here for solutions to common issues when you create your first C++ project.
6565

66-
### Build and run your code in Visual Studio issues
66+
### Build and run your code in Visual Studio: issues
6767

6868
If red squiggles appear under anything in the source code editor, the build may have errors or warnings. Check that your code matches the example in spelling, punctuation, and case.
6969

7070
[Go back.](#build-and-run-your-code-in-visual-studio)
7171

72-
### Run your code in a command window issues
72+
### Run your code in a command window: issues
7373

74-
You can also navigate to the solution Debug folder at the command line to run your app. You can't run your app from other directories without specifying the path to the app. However, you can copy your app to another directory and run it from there.
74+
If the path shown in File Explorer ends in *\\HelloWorld\\HelloWorld*, you've opened the HelloWorld *project* instead of the HelloWorld *solution*. You'll be confused by a Debug folder that doesn't contain your app. Navigate up a level in File Explorer to get to the solution folder, the first *HelloWorld* in the path. This folder also contains a Debug folder, and you'll find your app there.
7575

76-
If you don't see **Copy as path** in the shortcut menu, dismiss the menu, and then hold down the Shift key while you open it again. This is just for convenience. You can also copy the path to the folder from the File Explorer search bar, and paste it into the **Run** dialog, and then enter the name of your executable at the end. It's just a little more typing, but it has the same result.
76+
You can also navigate to the solution Debug folder at the command line to run your app. Your app won't run from other directories without specifying the path to the app. However, you can copy your app to another directory and run it from there. It's also possible to copy it to a directory specified by your PATH environment variable, then run it from anywhere.
77+
78+
If you don't see **Copy as path** in the shortcut menu, dismiss the menu, and then hold down the **Shift** key while you open it again. This command is just for convenience. You can also copy the path to the folder from the File Explorer search bar, and paste it into the **Run** dialog, and then enter the name of your executable at the end. It's just a little more typing, but it has the same result.
7779

7880
[Go back.](#run-your-code-in-a-command-window)
7981

0 commit comments

Comments
 (0)