Tutorial - Create your first extension: Hello World

Applies to: yesVisual Studio noVisual Studio for Mac noVisual Studio Code

This Hello World example walks you through creating your first extension for Visual Studio. This tutorial shows you how to add a new command to Visual Studio.

In the process, you will learn how to:

For this example, you'll use Visual C# to add a custom menu button named "Say Hello World!" that looks like this:

Hello World command


This article applies to Visual Studio on Windows. For Visual Studio for Mac, see Extensibility walkthrough in Visual Studio for Mac.


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.


You can use any edition of Visual Studio (Community, Professional, or Enterprise) to create a Visual Studio extensibility project.

Create an extensibility project

Step 1. From the File menu, select New > Project. Search for "vsix" and select the Visual C# VSIX Project and then Next.

Step 2. Enter "HelloWorld" for the Project name and select Create.

new project

You should now see the HelloWorld project in Solution Explorer.

Add a custom command

Step 1. If you select the .vsixmanifest manifest file, you can see what options are changeable, such as description, author, and version.

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

Step 3. Select the Extensibility section, and then choose Command.

Step 4. In the Name field at the bottom, enter a filename such as Command.cs.

custom command

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.

Modify the source code

At this point, the command and Button text are autogenerated and not very interesting. You can modify the VSCT file and CS file if you want to make changes.

  • 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.

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

Step 1. In Solution Explorer, find the VSCT file for your extension VS package. In this case, it will be called HelloWorldPackage.vsct.

Step 2. Change the ButtonText parameter to Say Hello World!.

  <Button guid="guidCommandPackageCmdSet" id="CommandId" priority="0x0100" type="Button">
     <Parent guid="guidCommandPackageCmdSet" id="MyMenuGroup" />
     <Icon guid="guidImages" id="bmpPic1" />
        <ButtonText>Say Hello World!</ButtonText>

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!.

  private void Execute(object sender, EventArgs e)
    string message = "Hello World!";
    string title = "Command";

    // Show a message box to prove we were here

Make sure to save your changes to each file.

Run it

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

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.

Step 2. On the Tools menu of the Experimental Instance, click Say Hello World!.

final result

You should see the output from your new custom command, in this case the dialog in the center of the screen that gives you the Hello World! message.

Next steps

Now that you know the basics of working with Visual Studio Extensibility, here's where you can learn more: