You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/getting-started/index.md
+4-4
Original file line number
Diff line number
Diff line change
@@ -8,16 +8,16 @@ There goal of the getting started guide is to give you a basic understanding of
8
8
9
9
## Get the tools
10
10
11
-
The journey starts by [installing the right tools](getting-started/get-the-tools.html) into Visual Studio.
11
+
The journey starts by [installing the right tools](get-the-tools.html) into Visual Studio.
12
12
13
13
## Your first extension
14
14
15
-
Next, we're going to [write a simple extension](getting-started/your-first-extension.html) as a starting point for future customizations.
15
+
Next, we're going to [write a simple extension](your-first-extension.html) as a starting point for future customizations.
16
16
17
17
## Extension anatomy
18
18
19
-
It's now time to go over all the [moving parts of an extension](getting-started/extension-anatomy.html). This give you a broader understanding of the extensibility model.
19
+
It's now time to go over all the [moving parts of an extension](extension-anatomy.html). This give you a broader understanding of the extensibility model.
20
20
21
21
## Vocabulary
22
22
23
-
To take full advantage of this cookbook and Visual Studio extensibility in general, you must [know all the names and words](getting-started/vocabulary.html) for things. That's setting you up for future success.
23
+
To take full advantage of this cookbook and Visual Studio extensibility in general, you must [know all the names and words](vocabulary.html) for things. That's setting you up for future success.
Copy file name to clipboardExpand all lines: docs/getting-started/your-first-extension.md
+115-4
Original file line number
Diff line number
Diff line change
@@ -6,12 +6,123 @@ date: 2021-5-24
6
6
7
7
Before we start writing our first Visual Studio extension (it's easy, I promise!), make sure you've got the [tools needed](get-the-tools.md).
8
8
9
+
A Visual Studio extension is written using the .NET Framework and C#.
10
+
If you're already a .NET developer, you will find that writing extensions is similar to writing most other .NET programs and libraries.
11
+
12
+
The extension we'll be writing today adds a command that inserts a new guid into the text editor when executed. It's simple, useful, and provides a good introduction to the various aspects of extension development.
13
+
9
14
## Create the project
15
+
There are several project templates to choose from, so we want to make sure we make the right choice. The templates we use in this cookbook, all have the moniker **(Community)** in the name.
16
+
17
+
This time, we'll select the **VSIX Project w/Command (Community)** template, as shown in the screenshot below.
**InsertGuidPackage.cs** is what we refer to as the Package class. It's `InitializeAsync(...)` method is called by Visual Studio too initialize your extension. It's from here you add event listeners and registers commands, tool windows, settings and other things.
33
+
34
+
**source.extension.vsixmanifest** is the manifest file for your extension. It contains meta data such as title and description, but also information about what the extension contains.
35
+
36
+
**VSCommandTable.vsct** is an XML file where commands and keybindings are declaratively defined, so they can be registered with Visual Studio.
37
+
38
+
**Commands/MyCommand.cs** is the command handler for the command defined in the *VSCommandTable.vsct* file. It controls what happens when the command is executed - aka. the button is clicked.
39
+
40
+
## Modifying the command
41
+
First, we want to make sure our command has the right name, icon, and position within the Visual Studio menu system.
42
+
43
+
Open the *VSCommandTable.vsct* file and find a `<Group>` and a `<Button>`. Notice how the button specifies the group as being its parent and the group's parent is the built-in VSMainMenu/Tools menu.
44
+
45
+
For our extension, we want the *Insert GUID* command button to be under the *Edit* main menu, so we are going to re-parent the group to match.
We're using the `VS` object to get the active document, and then inserts the guid in the selection. There is always a selection in the editor even if it is zero length.
103
+
104
+
The first draft of our extension is now complete and it is time to test it.
105
+
106
+
## Running and debugging
107
+
Running your extension is as easy as running any other .NET project. Simply hit *F5* to run with the debugger attached or *Ctrl+F5* for running without.
108
+
109
+
Doing so will start the Experimental Instance of Visual Studio with your extension installed. The Experimental Instance is your regular version Visual Studio, but with separate settings and extensions installed. It helps keep things separate.
110
+
111
+
When the Experimental Instance starts up, you should see the Insert GUID command in the Edit main menu.
Copy file name to clipboardExpand all lines: docs/publish/index.md
+3-3
Original file line number
Diff line number
Diff line change
@@ -7,10 +7,10 @@ date: 2021-5-25
7
7
This section helps you getting your extension ready to share with your team or the whole world of Visual Studio users.
8
8
9
9
## Check the checklist
10
-
Make sure to check out [the checklist](publish/checklist.html) to ensure your extension follows best practices before you share it with anyone.
10
+
Make sure to check out [the checklist](checklist.html) to ensure your extension follows best practices before you share it with anyone.
11
11
12
12
## Publish to the Marketplace
13
-
Share your fantastic extension with the world, but publishing it to the [Marketplace](publish/marketplace.html).
13
+
Share your fantastic extension with the world, but publishing it to the [Marketplace](marketplace.html).
14
14
15
15
## Publish on a private galleries
16
-
You can also [host your own gallery](publish/private-galleries.html) of extensions either internally in your organization or in public on any web host.
16
+
You can also [host your own gallery](private-galleries.html) of extensions either internally in your organization or in public on any web host.
0 commit comments