Skip to content

Commit 9b5083d

Browse files
author
Kraig Brockschmidt
authored
Merge branch 'master' into master
2 parents 26e065d + 389d6d1 commit 9b5083d

11 files changed

+195
-4
lines changed

docs/ide/TOC.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# [Visual Studio IDE Overview](visual-studio-ide.md)
2-
# IDE Quickstarts
2+
# Quickstarts
33
## [First Look at the Visual Studio IDE](quickstart-ide-orientation.md)
4+
## [Projects and Solutions](quickstart-projects-solutions.md)
45
## [Personalizing Theme and Text Colors](quickstart-personalize-the-ide.md)
56
## [Coding in the Editor](quickstart-editor.md)
67
# [Get Started Developing with Visual Studio](get-started-developing-with-visual-studio.md)
Loading
47.5 KB
Loading
Loading
Loading
Loading
Loading

docs/ide/quickstart-editor.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ You've completed this quickstart for the Visual Studio editor! Next you might tr
152152

153153
[Quickstart: first look at the Visual Studio IDE](../ide/quickstart-ide-orientation.md)
154154
[Quickstart: personalize the Visual Studio IDE and Editor](../ide/quickstart-personalize-the-ide.md)
155+
[Quickstart: projects and solutions](../ide/quickstart-projects-solutions.md)
155156
[Code snippets](../ide/code-snippets.md)
156157
[Outlining](../ide/outlining.md)
157158
[Go To Definition and Peek Definition](../ide/go-to-and-peek-definition.md)

docs/ide/quickstart-ide-orientation.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ manager: ghogen
1414
---
1515
# Quickstart: first look at the Visual Studio IDE
1616

17-
In this 5-10 minute introduction to the Visual Studio integrated development environment (IDE), we'll take a tour of the some of the windows, menus, and other UI features.
17+
In this 5-10 minute introduction to the Visual Studio integrated development environment (IDE), we'll take a tour of some of the windows, menus, and other UI features.
1818

1919
## Start Page
2020

@@ -90,8 +90,10 @@ We've looked at just a few of the features of the Visual Studio IDE to get acqua
9090

9191
- Browse the General User Interface Elements section of the VS documentation, which goes into more depth about windows such as the [Error List](../ide/reference/error-list-window.md), [Output window](../ide/reference/output-window.md), [Properties window](../ide/reference/properties-window.md), and [Options dialog box](../ide/reference/options-dialog-box-visual-studio.md)
9292

93-
- Take a more in depth tour of the IDE, and even dabble in debugging, in [Overview of the Visual Studio IDE](../ide/visual-studio-ide.md)
93+
- Take a more in-depth tour of the IDE, and even dabble in debugging, in [Overview of the Visual Studio IDE](../ide/visual-studio-ide.md)
9494

9595
## See also
9696

97-
[Quickstart: personalizing the IDE](../ide/personalizing-the-visual-studio-ide.md)
97+
[Quickstart: personalizing the IDE](../ide/personalizing-the-visual-studio-ide.md)
98+
[Quickstart: coding in the editor](../ide/quickstart-editor.md)
99+
[Quickstart: projects and solutions](../ide/quickstart-projects-solutions.md)

docs/ide/quickstart-personalize-the-ide.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ We explored just a couple ways of customizing the colors in Visual Studio. We ho
9494
## See also
9595

9696
[Quickstart: first look at the Visual Studio IDE](../ide/quickstart-ide-orientation.md)
97+
[Quickstart: coding in the editor](../ide/quickstart-editor.md)
98+
[Quickstart: projects and solutions](../ide/quickstart-projects-solutions.md)
9799
[Personalize the Visual Studio IDE](../ide/personalizing-the-visual-studio-ide.md)
98100
[Customizing the Editor](../ide/customizing-the-editor.md)
99101
[Visual Studio IDE Overview](../ide/visual-studio-ide.md)
Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
---
2+
title: "Introduction to projects and solutions in Visual Studio | Microsoft Docs"
3+
ms.custom: ""
4+
ms.date: "12/11/2017"
5+
ms.reviewer: ""
6+
ms.suite: ""
7+
ms.technology: vs-ide-general
8+
ms.tgt_pltfrm: ""
9+
ms.topic: "quickstart"
10+
author: "gewarren"
11+
ms.author: "gewarren"
12+
manager: ghogen
13+
---
14+
# Quickstart: projects and solutions
15+
16+
In this 10-minute quickstart, we'll explore what it means to create a solution and a project in Visual Studio. We'll look at the properties of a project and some of the files it can contain. We'll also create a reference to a second project.
17+
18+
> [!TIP]
19+
> We'll be constructing a solution and project from scratch in this quickstart, as an educational exercise to understand the concept of a project. In your general use of Visual Studio, you will most likely use the many project templates that Visual Studio offers when you are creating a new project.
20+
21+
> [!NOTE]
22+
> Solutions and projects are not required to develop apps in Visual Studio. You can also just open a folder that contains code, and start coding, building, and debugging. For example, if you clone a GitHub repo, it might not contain Visual Studio projects and solutions. For more information, see [Develop code in Visual Studio without projects or solutions](../ide/develop-code-in-visual-studio-without-projects-or-solutions.md).
23+
24+
## Solutions
25+
26+
Solutions are containers used by Visual Studio to organize one or more related projects. When you open a solution in Visual Studio, it will automatically load all the projects it contains.
27+
28+
### Create a solution
29+
30+
We'll start our exploration by creating an empty solution. After you get to know Visual Studio, you probably won't find yourself creating empty solutions too often. When you create a new project in Visual Studio, it automatically creates a solution to house the project if there's not a solution already open.
31+
32+
1. Start Visual Studio.
33+
34+
Visual Studio opens, and you'll likely see the **Start Page** taking up most of the window's real estate.
35+
36+
1. On the menu bar, choose **File** > **New** > **Project...**.
37+
38+
The **New Project** dialog box opens.
39+
40+
1. In the left pane, expand **Other Project Types**, then choose **Visual Studio Solutions**. In the center pane, choose **Blank Solution**. Name your solution "QuickSolution", then choose **OK**.
41+
42+
![Blank Solution Template](media/quickstart-projects-new-solution.png)
43+
44+
The **Start Page** closes, and a solution appears in **Solution Explorer** on the right side of the Visual Studio window. You'll probably use **Solution Explorer** often, to browse the contents of your projects.
45+
46+
### Add a project
47+
48+
Now let's add our first project to the solution. We'll start with an empty project and add the items we need to the project.
49+
50+
1. From the right-click or context menu of **Solution 'QuickSolution'** in **Solution Explorer**, choose **Add** > **New Project...**.
51+
52+
The **Add New Project** dialog box opens.
53+
54+
1. In the left pane, expand **Visual C#** and choose **Windows Classic Desktop**. Then, in the middle pane, choose **Empty Project (.NET Framework)**. Name the project "QuickDate", then choose the **OK** button.
55+
56+
A project named "QuickDate" appears beneath the solution in **Solution Explorer**. Currently it contains a single file called **App.config**.
57+
58+
> [!NOTE]
59+
> If you don't see **Visual C#** in the left pane of the dialog box, you need to install the **.NET desktop development** workload. An easy way to do this is to click the **Open Visual Studio Installer** link at the bottom of that left pane. The **Visual Studio Installer** opens, and from there you can choose the correct workload and then the **Modify** button.
60+
61+
![Open Visual Studio Installer link](media/quickstart-projects-open-installer.png)
62+
63+
## Add an item to the project
64+
65+
We have an empty project—let's add a code file.
66+
67+
1. From the right-click or context menu of **QuickDate** in **Solution Explorer**, choose **Add** > **New Item...**.
68+
69+
The **Add New Item** dialog box opens.
70+
71+
1. Expand **Visual C# Items**, then choose **Code**. In the middle pane choose **Class**. Name the class "Calendar", and then choose the **Add** button.
72+
73+
A file named "Calendar.cs" is added to the project. The **.cs** on the end is the file extension that is given to C# code files. The file appears in the visual project hierarchy in **Solution Explorer**, and its contents are opened in the editor.
74+
75+
1. Replace the contents of the **Calendar.cs** file with the following code.
76+
77+
```csharp
78+
using System;
79+
80+
namespace QuickDate
81+
{
82+
internal class Calendar
83+
{
84+
static void Main(string[] args)
85+
{
86+
DateTime now = GetCurrentDate();
87+
Console.WriteLine($"Today's date is {now}");
88+
Console.ReadLine();
89+
}
90+
91+
internal static DateTime GetCurrentDate()
92+
{
93+
return DateTime.Now.Date;
94+
}
95+
}
96+
}
97+
```
98+
99+
You don't need to understand what the code does, but if you want, you can run the program and see that it prints today's date to the console window.
100+
101+
## Add a second project
102+
103+
It is common for solutions to contain more than one project, and often these projects reference each other. Some projects in a solution might be class libraries, some executable applications, and some might be unit test projects or web sites.
104+
105+
Let's add a unit test project to our solution. This time we'll start from a project template, so we don't have to add an additional code file to the project.
106+
107+
1. From the right-click or context menu of **Solution 'QuickSolution'** in **Solution Explorer**, choose **Add** > **New Project...**.
108+
109+
The **Add New Project** dialog box opens.
110+
111+
1. In the left pane, expand **Visual Basic** and choose the **Test** category. In the middle pane, choose **Unit Test Project (.NET Framework)**. Name the project "QuickTest", and then choose the **OK** button.
112+
113+
A second project is added to **Solution Explorer**, and a file named **UnitTest1.vb** opens in the editor. **.vb** is the file extension that is given to Visual Basic code files.
114+
115+
![Solution Explorer with two projects](media/quickstart-projects-solution-explorer.png)
116+
117+
## Add a project reference
118+
119+
We're going to use the new unit test project to test our method in the **QuickDate** project, so we need to add a reference to that project. This creates a build dependency between the two projects, meaning **QuickDate** will be built before **QuickTest** when the solution is built.
120+
121+
1. Choose the **References** node in the **QuickTest** project, and from the right-click or context menu, choose **Add Reference...**.
122+
123+
![Add Reference menu](media/quickstart-projects-add-reference.png)
124+
125+
The **Reference Manager** dialog box opens.
126+
127+
1. In the left pane, expand **Projects** and choose **Solution**. In the middle pane, choose the checkbox next to **QuickDate**, and then choose the **OK** button.
128+
129+
A reference to the **QuickDate** project is added.
130+
131+
## Add test code
132+
133+
1. Now we'll add test code to the Visual Basic code file. Replace the contents of **UnitTest1.vb** with the following code.
134+
135+
```vb
136+
<TestClass()> Public Class UnitTest1
137+
138+
<TestMethod()> Public Sub TestGetCurrentDate()
139+
Assert.AreEqual(DateTime.Now.Date, QuickDate.Calendar.GetCurrentDate())
140+
End Sub
141+
142+
End Class
143+
```
144+
145+
You'll see a red "squiggly" under some of the code. We'll fix this error by making the test project a [friend assembly](/dotnet/csharp/programming-guide/concepts/assemblies-gac/friend-assemblies) to the **QuickDate** project.
146+
147+
1. Back in the **QuickDate** project, open the **Calendar.cs** file if it's not already open, and add the following using statement and <xref:System.Runtime.CompilerServices.InternalsVisibleToAttribute> attribute, to resolve the error in the test project.
148+
149+
```csharp
150+
using System.Runtime.CompilerServices;
151+
152+
[assembly: InternalsVisibleTo("QuickTest")]
153+
```
154+
155+
The code file should look like this.
156+
157+
![CSharp code](media/quickstart-projects-cs-code.png)
158+
159+
## Project properties
160+
161+
The line in the C# code file that contains the <xref:System.Runtime.CompilerServices.InternalsVisibleToAttribute> attribute references the assembly name of the **QuickTest** project. The assembly name might not always be the same as the project name. To find the assembly name of a project, open the project properties.
162+
163+
1. In **Solution Explorer**, select the **QuickTest** project. From the right-click or context menu, select **Properties**, or just press **Alt**+**Enter**.
164+
165+
The property pages for the project open on the **Application** tab. Notice that the assembly name of the **QuickTest** project is indeed "QuickTest". If you wanted to change it, this is where you would change it. Then, when you build the test project, the name of the resulting executable file would change from **QuickTest.exe** to whatever you chose.
166+
167+
![Project properties](media/quickstart-projects-properties.png)
168+
169+
1. Explore some of the other tabs of the project's property pages, such as **Compile** and **Settings**. These tabs will be different depending on the type of project.
170+
171+
## Next steps
172+
173+
If you want to check that your unit test is working, choose **Test** > **Run** > **All Tests** from the menu bar. A window called **Test Explorer** opens, and you should see that the **TestGetCurrentDate** test passes.
174+
175+
Congratulations on completing this quickstart! Next, you might want to explore some of the other quickstarts for Visual Studio, or learn more about [creating projects and solutions](../ide/creating-solutions-and-projects.md).
176+
177+
## See also
178+
179+
[Quickstart: first look at the Visual Studio IDE](../ide/quickstart-ide-orientation.md)
180+
[Quickstart: personalize the Visual Studio IDE and editor](../ide/quickstart-personalize-the-ide.md)
181+
[Quickstart: coding in the editor](../ide/quickstart-editor.md)
182+
[Managing project and solution properties](../ide/managing-project-and-solution-properties.md)
183+
[Managing references in a project](../ide/managing-references-in-a-project.md)
184+
[Develop code in Visual Studio without projects or solutions](../ide/develop-code-in-visual-studio-without-projects-or-solutions.md)
185+
[Visual Studio IDE overview](../ide/visual-studio-ide.md)

0 commit comments

Comments
 (0)