Skip to content

Commit 3afc417

Browse files
authored
Merge pull request #4187 from gregvanl/vssdk-preview
Update your first extension tutorial for Dev16
2 parents 5cde41d + 99488b0 commit 3afc417

File tree

4 files changed

+46
-18
lines changed

4 files changed

+46
-18
lines changed

docs/extensibility/extensibility-hello-world.md

Lines changed: 46 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: "Hello World extension tutorial | Microsoft Docs"
3-
ms.date: "07/10/2017"
3+
ms.date: "03/14/2019"
44
ms.topic: "conceptual"
55
ms.assetid: f74e1ad1-1ee5-4360-9bd5-d82467b884ca
66
author: "gregvanl"
@@ -29,53 +29,75 @@ For this example, you'll use Visual C# to add a custom menu button named "Say He
2929
3030
## Prerequisites
3131

32-
Before you start, make sure you have installed the **Visual Studio extension development** workload which includes the VSIX template you'll need and sample code.
32+
Before you start, make sure you have installed the **Visual Studio extension development** workload, which includes the VSIX template you'll need and sample code.
3333

3434
> [!NOTE]
3535
> You can use any edition of Visual Studio (Community, Professional, or Enterprise) to create a Visual Studio extensibility project.
3636
3737
## Create an extensibility project
3838

39-
Step 1. From the **File** menu, click **New Project**. At the bottom of the screen, enter the name of your project.
39+
::: moniker range="vs-2017"
40+
41+
Step 1. From the **File** menu, select **New Project**.
4042

41-
Step 2. From the **Templates** menu, click **Visual C#**, click **Extensibility**, and then click **VSIX Project**.
43+
Step 2. In the search box in the upper right, type "vsix" and select the Visual C# **VSIX Project**. Enter "HelloWorld" for the **Name** at the bottom of the dialog and select **OK**.
4244

4345
![new project](media/hello-world-new-project.png)
4446

4547
You should now see the Getting Started page and some sample resources.
4648

47-
::: moniker range="vs-2017"
48-
4949
If you need to leave this tutorial and come back to it, you can find your new HelloWorld project on the **Start Page** in the **Recent** section.
5050

5151
::: moniker-end
5252

53+
::: moniker range=">=vs-2019"
54+
55+
Step 1. From the **File** menu, select **New Project**. Search for "vsix" and select the Visual C# **VSIX Project** and then **Next**.
56+
57+
Step 2. Enter "HelloWorld" for the **Project name** and select **Create**.
58+
59+
![new project](media/hello-world-new-project-2019.png)
60+
61+
You should now see the HelloWorld project in **Solution Explorer**.
62+
63+
::: moniker-end
64+
5365
## Add a custom command
5466

55-
Step 1. If you select the manifest, you can see what options are changeable, for instance, metadata, description, and version.
67+
Step 1. If you select the *.vsixmanifest* manifest file, you can see what options are changeable, such as description, author, and version.
5668

57-
Step 2. Right-click the project (not the solution). On the context menu, click **Add**, and then click **New Item**.
69+
Step 2. Right-click the project (not the solution). On the context menu, select **Add**, and then **New Item**.
5870

59-
Step 3. Select the **Extensibility** section, and then click **Custom Command**.
71+
Step 3. Select the **Extensibility** section, and then choose **Custom Command**.
6072

61-
Step 4. In the **Name** field at the bottom, give it a name, for instance *Command.cs*.
73+
Step 4. In the **Name** field at the bottom, enter a filename such as *Command.cs*.
6274

6375
![custom command](media/hello-world-custom-command.png)
6476

65-
Your new command is listed in **Solution Explorer** under the **Resources** branch. This is also where you'll find other files related to your command, such as the PNG and ICO files if you wish to modify the image.
77+
Your new command file is visible in **Solution Explorer**. Under the **Resources** node, you'll find other files related to your command. For example, if you wish to modify the image, the PNG file is here.
6678

6779
## Modify the source code
6880

69-
At this point, the Button you're adding is pretty generic. You'll have to modify the VSCT file and CS file if you want to make changes.
81+
At this point, the command and Button text is auto-generated and not very interesting. You can modify the VSCT file and CS file if you want to make changes.
7082

71-
* The VSCT file is where you can rename your commands, as well as define where they go in the Visual Studio command system. As you explore the VSCT file, you will notice a lot of commented code that explains what each section of code controls.
83+
* The VSCT file is where you can rename your commands, as well as define where they go in the Visual Studio command system. As you explore the VSCT file, you will notice comments that explain what each section of the VSCT code controls.
7284

7385
* The CS file is where you can define actions, such as the click handler.
7486

87+
::: moniker range="vs-2017"
88+
7589
Step 1. In **Solution Explorer**, find the VSCT file for your new command. In this case, it will be called *CommandPackage.vsct*.
7690

7791
![command package vsct](media/hello-world-command-package-vsct.png)
7892

93+
::: moniker-end
94+
95+
::: moniker range=">=vs-2019"
96+
97+
Step 1. In **Solution Explorer**, find the VSCT file for your extension VS package. In this case, it will be called *HelloWorldPackage.vsct*.
98+
99+
::: moniker-end
100+
79101
Step 2. Change the `ButtonText` parameter to `Say Hello World!`.
80102

81103
```xml
@@ -90,14 +112,15 @@ Step 2. Change the `ButtonText` parameter to `Say Hello World!`.
90112
...
91113
```
92114

93-
Step 3. Go back to **Solution Explorer** and find the *Command.cs* file. Change the string `message` for the command `string.Format(..)` to `Hello World!`.
115+
Step 3. Go back to **Solution Explorer** and find the *Command.cs* file. In the `Execute` method, change the string `message` from `string.Format(..)` to `Hello World!`.
94116

95117
```csharp
96118
...
97-
private void MenuItemCallback(object sender, EventArgs e)
119+
private void Execute(object sender, EventArgs e)
98120
{
121+
ThreadHelper.ThrowIfNotOnUIThread();
99122
string message = "Hello World!";
100-
string title = "Command1";
123+
string title = "Command";
101124

102125
// Show a message box to prove we were here
103126
VsShellUtilities.ShowMessageBox(
@@ -117,12 +140,16 @@ Make sure to save your changes to each file.
117140

118141
You can now run the source code in the Visual Studio Experimental Instance.
119142

120-
Step 1. Click **Start** in the Toolbar. This builds your project and starts the debugger, launching a new instance of Visual Studio called the **Experimental Instance**.
143+
Step 1. Press **F5** to run the **Start Debugging** command. This command builds your project and starts the debugger, launching a new instance of Visual Studio called the **Experimental Instance**.
144+
145+
::: moniker range="vs-2017"
121146

122147
You will see the words **Experimental Instance** in the Visual Studio title bar.
123148

124149
![experimental instance title bar](media/hello-world-exp-instance.png)
125150

151+
::: moniker-end
152+
126153
Step 2. On the **Tools** menu of the **Experimental Instance**, click **Say Hello World!**.
127154

128155
![final result](media/hello-world-final-result.png)
@@ -134,5 +161,6 @@ You should see the output from your new custom command, in this case the dialog
134161
Now that you know the basics of working with Visual Studio Extensibility, here's where you can learn more:
135162

136163
* [Start to develop Visual Studio extensions](starting-to-develop-visual-studio-extensions.md) - Samples, tutorials. and publishing your extension
137-
* [What's new in the Visual Studio 2017 SDK](what-s-new-in-the-visual-studio-2017-sdk.md) -New extensibility features in Visual Studio 2017
164+
* [What's new in the Visual Studio 2017 SDK](what-s-new-in-the-visual-studio-2017-sdk.md) - New extensibility features in Visual Studio 2017
165+
* [What's new in the Visual Studio 2019 SDK](whats-new-visual-studio-2019-sdk.md) - New extensibility features in Visual Studio 2019
138166
* [Inside the Visual Studio SDK](internals/inside-the-visual-studio-sdk.md) - Learn the details of Visual Studio Extensibility
Loading
Loading
Loading

0 commit comments

Comments
 (0)