power up productivity with visual studio extensions

15
Power Up Productivity with Visual Studio Extensions PRESENTED BY: ERIC W. GREENE

Upload: eric-greene

Post on 26-Jun-2015

179 views

Category:

Software


1 download

DESCRIPTION

Visual Studio Extensions are a great way to enhance Visual Studio to perform useful, frequently executed tasks thereby saving time, reducing the risk of human error and contributing to a more efficient and enjoyable software development experience. Extensions are quite simple to create, publish and distribute to other members of your team. The demonstration tonight will show the basics of code and debug an extension, how to interact with the Visual Studio API as well as how to distribute it via a private Extension Gallery.

TRANSCRIPT

Page 1: Power Up Productivity with Visual Studio Extensions

Power Up Productivity with Visual Studio ExtensionsPRESENTED BY: ERIC W. GREENE

Page 2: Power Up Productivity with Visual Studio Extensions

What are Visual Studio Extensions?

Visual Studio Extensions are applications that integrate with Visual Studio to extend the functionality of

Visual Studio.

Page 3: Power Up Productivity with Visual Studio Extensions

Many Types of Extensions…

Templates – adds project templates exactly like the many templates that you see in Visual Studio when you create a new project.

Controls – adds controls to use in your applications.

Tools – applications that run within the Visual Studio environment to directly enhance the development experience of Visual Studio.

Shell (Integrated/Isolated) – Create applications that use Visual Studio as their framework.

There are also SDKs, samples and many other ways to extend Visual Studio too..

Page 4: Power Up Productivity with Visual Studio Extensions

Our focus today… We will be focusing on Tool Extensions. From this point forward when I refer to extensions I am referring to Tool Extensions like Resharper, Mindscape Web Workbench, VS10x Code Map, SlowCheetah, etc…

Page 5: Power Up Productivity with Visual Studio Extensions

Some confusion… Visual Studio Extensions

VS Extensions add capabilities to Visual Studio.

VS Extensions are NOT NuGet Packages

NuGet Packages

NuGet Packages add code libraries and in some cases development aids to your applications.

NuGet Package Manager is actually a tool extension itself…

both enhance the development experienceboth are distributed through galleries

in some cases certain technologies are distributedvia VS Extensions and NuGet Packages – such as SlowCheetah.

But… VS Extensions and NuGet Packages are not the same thing…

Page 6: Power Up Productivity with Visual Studio Extensions

Useful Tips and Links…Visual Studio Extensions in Visual Studio

To see the extensions you have installed, to install/update new extensions or to remove extensions click ‘Tools’ on the menu bar then click ‘Extensions and Updates’.

Also, under ‘Tools’ -> ‘Options’ there is a section named “Environment\Extensions and Updates’. Here you can configure some options concerning the management of extensions with your Visual Studio.

Page 7: Power Up Productivity with Visual Studio Extensions

Useful Tips and Links…Visual Studio Extension Gallery

http://visualstudiogallery.msdn.microsoft.com/

Visual Studio Extension Development Documentation

SDK Docs: http://msdn.microsoft.com/en-us/library/bb166441.aspx

VSPackages Walkthroughs: http://msdn.microsoft.com/en-us/library/cc138565.aspx

Page 8: Power Up Productivity with Visual Studio Extensions

What do you need? To write Visual Studio Tool Extensions you need the following:

Visual Studio – Professional Edition or greater… Express Edition cannot be used.

Visual Studio SDK – This is a free library but is downloaded separately from Visual Studio.

VS SDK 2012 – http://www.microsoft.com/en-us/download/details.aspx?id=30668

VS SDK 2013- http://www.microsoft.com/en-us/download/details.aspx?id=40758

Page 9: Power Up Productivity with Visual Studio Extensions

After installing…Once the installs are complete its time to create a new project…

The SDK installed a number of new project types which you can see when you click ‘File’ -> ‘New’ -> ‘Project’.

In the Project Templates tree look under ‘Templates’ -> ‘Visual C#’ -> ‘Extensibility’ and you will see lots of project templates…

We will be using the ‘Visual Studio Package’ project template. I do not know the details of the other project templates but you can find out more here…

http://msdn.microsoft.com/en-us/library/dd885119.aspx

Page 10: Power Up Productivity with Visual Studio Extensions

A caution… When working on the extensions and looking up information you will see the term “addins” in some documentation referring to Visual Studio Extensions. “Addins” are no longer supported, only VS Packages are supported. That being said most addin code example will work as is but like most things there is probably a “newer, better” way to do the code in the latest Visual Studio.

In the course of building my extension I ran into lots of code examples for “old” ways and “new” ways and most of the time both worked fine. The key is pay attention to which version the documentation or code example is referring to. And if its older then try to cross reference against code referring to the newest version to see if something has changed.

Page 11: Power Up Productivity with Visual Studio Extensions

Development work flow…

The development work flow is very simple…

1. Write the code for the extensions.

2. Run the extension in debug mode (F5) like any other program…

3. When it runs, an experimental version of Visual Studio is loaded up and your extension is installed behind the scenes.

4. With Visual Studio running you can use your extension. If your extension needs a project loaded, then load the project as normal and use your extension.

5. To debug your extension simply set breakpoints in your source code and as you interact with your extension in the experimental Visual Studio execution will stop at the breakpoints set in your source code in your main development Visual Studio.

Actually, the process is very intuitive and simple to follow.

Page 12: Power Up Productivity with Visual Studio Extensions

Let’s write a simple extension..

1. Create a new VS Package project called ‘SampleTool’.

2. Review the project files created for us.

3. Add a little code to see it do something and debug it.◦ - Look at the API for a Solution and its Projects and learn about the

‘GetService’ method.◦ - Adding options to the Tools -> Options window and set/get those values.◦ - Output information to the ‘Output’ window.◦ - Update a project item through code.

4. Discuss versioning and packaging.

5. Create a VISX and install the VISX from File Explorer.

7. Install the VISX from a Private Gallery.

Page 13: Power Up Productivity with Visual Studio Extensions

Important Concepts DTE or DTE2? Automation Objects with numbers in the names?

http://msdn.microsoft.com/en-us/library/t6d9sf9k.aspx

GetService – Gets you access to the Visual Studio API…

http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.shell.package.getservice.aspx

Page 14: Power Up Productivity with Visual Studio Extensions

Distributing your control…

In the output folder, you will see a number of files and a .VSIX file. The VSIX file is the file to distribute. When you run it the Visual Studio VISX installer run and install the extension.

If you use a program like 7-Zip, you can extract the VISX file and you will see that it is really just an archive of the other files in the bin folder.

Page 15: Power Up Productivity with Visual Studio Extensions

Three ways to distribute… Give people the VSIX file - They can simply run it on their

machine and the extension will be installed. Public Galleries – You can post your extension in the public

gallery for everyone to download and use. If you add some licensing capability to it you could even sell it.

Private Galleries – On a local web server you can drop an atom.xml file and the VSIX file and create a private gallery. Be sure to add MIME type for VSIX file. Simple add the gallery via ‘Tool’ -> ‘Options’ through ‘Environment’ -> ‘Extensions and Updates’ and you can easily distribute the control (plus updates) to your whole team. (http://msdn.microsoft.com/en-us/library/hh266746.aspx)