1 / 75

Visual Studio: Extending Visual Studio With Add-ins And Packages

Visual Studio: Extending Visual Studio With Add-ins And Packages. Philip Taylor ptaylor@microsoft.com TLN404 Program Manager, Visual Studio 2005 SDK Microsoft Corporation. Why Come To This Session?. Visual Studio Extensibility lets you write and add custom tools like

halia
Download Presentation

Visual Studio: Extending Visual Studio With Add-ins And Packages

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Visual Studio: Extending Visual Studio With Add-ins And Packages Philip Taylor ptaylor@microsoft.com TLN404 Program Manager, Visual Studio 2005 SDK Microsoft Corporation

  2. Why Come To This Session? • Visual Studio Extensibility lets you write and add custom tools like • Custom help systems • New languages • New editors • Tool windows • Extensibility fits the tool to the process and not the other way around • Upon completing this session, attendees will have followed the steps for a complete tool window package that extends Visual Studio

  3. Pre-Requirements • Must code • Be familiar with • General use of Visual Studio • COM and C++, or .NET Framework • Automation models in general • Nice to understand • Visual Studio automation model

  4. Agenda • Extensibility Overview • Demo:Writing a ToolWindow • Visual Studio 2005 SDK

  5. Packages Cost of integration Level of integration Add-Ins Macros VS User Customization Visual Studio ExtensibilityOptions for Extending Visual Studio Developer Reach

  6. Extensibility MapHow to Choose

  7. Macros • The Visual Studio automation object model contains >140 objects, allowing control of the IDE from a solution level all the way to a single parameter of a single function • Macros can leverage nearly all of the features of the .NET Framework, as well as most of the automation model • Macros accessed via Tools|Macros • Macros have some limitations • Macros can only be written in the Visual Basic language • Macros cannot be used to implement new tool windows, commands, Tools Options pages

  8. Add-ins • Customize, automate, and extend VS • Provide new VS features • User manageable • Simple to build • Add-in creation wizard • Build in any language which supports COM • Leverage rich Visual Studio object model • Available to all Visual Studio.NET developers • Extensive coverage of VS features

  9. Add-in Features And Limitations • Simple registration using XML ( no more COM registration ) • Unlike macros, Add-ins can implement new tool windows, commands, Tools Options pages • However, Add-ins cannot implement new document types, new project types, new debug engines, etc. which require a package

  10. ToolWindow Demo:Visual Studio UI Elements

  11. ToolWindow Add-in Craig Skibo Software Design Engineer Visual Studio

  12. Packages • Deepest possible integration with VS • Add functionality seamlessly with VS integration packages • Rich access to common shell features • Plus full access to the automation model • Add new features to Visual Studio for • IDE, Debugger, Source Control, Data Sources, etc

  13. Programs And Tools For Package Development • Visual Studio Industry Partner ( VSIP ) program to provide marketing and business support • 1 Free level: Affiliate • 2 Paid levels: Alliance and Premier • Visual Studio 2005 SDK to provide developer tool for package development • Downloads free after brief registration process

  14. Package Extensibility Points • IDE • Project systems, Languages, Editors, ToolWindows, • .NET Designers, Menus and Commands, Toolbox Integration, Tools Options Page, Property Browser • Help Integration, Setup and Deployment • Debugger • Custom Debug Engine • Expression Evaluators • Type Visualizers • Source Control • Project systems enabled to participate in source control • Source Control Provider ( Plug-in or Package ) • Data Sources • Design-time Data Source Drag-n-Drop • Data Source Provider • And More

  15. Package Architecture • Visual Studio 2005 is the platform • Native Interfaces provide extensibility points • Interop Assemblies enable managed code access Your Native Package Your Managed Package or MPF 8.0 Interop Assemblies Native Interfaces Visual Studio 2005 • SDK Provides • Native Interface IDLs • Interop Assemblies • Samples, Doc, templates, etc • Package Wizard

  16. Programming Model • Features added to IDE via VsPackage interface • Logical unit of extensibility consisting of • CoCreate-able COM object - IVsPackage;Initial object created and sited by IDE • Other supporting COM objects • Interactions between IDE and Packages abstracted via COM interfaces • Same architecture is used for MS built features as well as 3rd party extensions! • Package development only available with Visual Studio 2005 SDK installs

  17. Delayed Loading • Fundamental principle • Delay loading code until functionality is needed • Package exposes registry info about functionality so IDE knows when to load it • Registry info enables features to be exposed in UI without loading Package code • Local registry enables multiple SxS versions HKLM/Software/Microsoft/Visual Studio/7.0 ( Visual Studio 2002 ) HKLM/Software/Microsoft/Visual Studio/7.1 ( Visual Studio 2003 ) HKLM/Software/Microsoft/Visual Studio/8.0 ( Visual Studio 2005 ) We call this a “registry hive” • Delayed Loading also helps Visual Studio load performance

  18. IDE Services • Interface contract implemented by a single COM object • Functionality built into the IDE is exposed through Services • Packages can expose new services • Packages can consume functionality from others via Services

  19. IDE Services

  20. Demo DetailsToolWindow with custom Todo List • All 10 Steps, as separate solutions, available at • On Conference DVD • On MSDN dev center http://msdn.microsoft.com/vstudio/extend/ • Custom “todo list” ToolWindow originally published at • http://dotnet.sys-con.com/read/105646_1.htm • Available as article+code • Future article will enhance sample to participate in Visual Studio task list

  21. Demo DetailsToolWindow with custom Todo List • 10 Steps ( 0-9 ) • 0:Run Wizard • 1:Update Wizard Files • 2:Add Todo List UI • 3:Add EventHandler • 4:Add Toolbar • CTC • Resource IDs • Toolbar constructor • 5:Add AddTask dialog form • Add Winform • Set Form properties • 6:Wire up properties in AddTask dialog • 7:Wire up Toolbar button and AddTask method • 8:Static accessor and save package instance • 9:Add delegate+event, EventArgs subclass, event handler, and update AddTask method

  22. ToolWindow Package Philip Taylor Program Manager, VS Extensibility Visual Studio

  23. Visual Studio 2005 SDK • Key Concepts • Development Plan • Release Plan • Community Plan

  24. Key Concepts • Experimental Hive • The SDK creates the separate registry hive to do prototyping work • Samples auto-register in Experimental Hive • The new SDK enables a “reset all” for the experimental hive • DLK and PLK • Developers use the Developer License Key, provided with the SDK • Shipping requires Package Load Key • available from http://www.vsipdev.com/plkregister.aspx • Setup and Deployment • Final product needs to author a setup and deployment project that handles: • Presenting your company EULA • Install • Registration

  25. SDK RTM Features • Reorganized SDK layout and samples • 8 New Reference Implementations • Package, Service, Menu and Commands, ToolWindow • Both Managed and Native versions • Updated Debugger sample • Managed Resources enabled for Managed Packages • CTC file colorizing • Updated Wizard • Using Reference Implementations as basis • Significantly updated Help Documentation • 1st public viewing in Sept preview

  26. Package Sample Source

  27. Sample CTC Files

  28. SDK Release Plan • Goal is Trimester releases • With monthly previews • July and August already available: http://www.vsipdev.com/downloads • On target for Nov 2005 RTM with Visual Studio 2005 • Release schedule possible with Agile methodology

  29. SDK Community Plan • Available Now • Re-vamped download page • New VS SDK Previews as well as “Archive” VSIP SDK • Monthly sprint backlogs and monthly reviews • Transparency into SDK planning process • See: http://www.vsipdev.com/downloads • In Process • Web site for Community developed sample content • MVPs for forums and newsgroups • Post long-term backlog and enable community feedback • The community feedback will be incorporated as part of the weighting used by the SDK team to decide priorities

  30. Community Resources • At PDC • For more information, go see • Labs: TLNHOL16 Visual Studio Add-ins • Labs: TLNHOL01 Visual Studio Packages • Labs: TLNHOL14 Customizing Templates and Starter Kits • Tools and Languages Track lounge: Team will be there • After PDC • If you missed this related session, watch it on the DVD • TLN404: Visual Studio Extensibility • MSDN dev center: http://msdn.microsoft.com/vstudio/extend/ • MSDN Forum: http://forums.microsoft.com/msdn/ShowForum.aspx?ForumID=57 • Downloads: http://www.vsipdev.com/downloads

  31. Call To Action • Explore Extensibility Hands-on Labs • Labs: TLNHOL16 Visual Studio Add-ins • Labs: TLNHOL01 Visual Studio Packages • Labs: TLNHOL14 Customizing Templates and Starter Kits • Work thru the sample Code for demo • Build your own extensibility solutions • Give us feedback on the new SDK!

  32. Q&A • ?

  33. © 2005 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

  34. Appendix

  35. Demo Details:ToolWindow with custom Todo List • All 10 Steps, as separate solutions, available at: • On Conference DVD • on MSDN dev center: http://msdn.microsoft.com/vstudio/extend/ • Custom “todo list” ToolWindow originally published at: • http://dotnet.sys-con.com/read/105646_1.htm • Available as article+code • Future article will enhance sample to participate in Visual Studio task list

  36. Step 0:Generate the ProjectRun the wizard • Update Wizard Settings • Pick toolwindow only • Name PDCToolWindow • cmdidPDCToolWindow

  37. Step 0:Generate the Project Run the wizard

  38. Step 1:Update Wizard FilesRename files • Rename • Vspkg.cs to PDCToolWindowPackage.cs • My tool window.cs to PDCToolWindow.cs • Mycontrol.cs to PDCToolWindowClientarea.cs

  39. Step 1:Update Wizard Files Solution Files • Solution: Tasklist Sample • Project: Tasklist SampleGuids.cs - Contains a list of all GUIDs you generate.Key.snk ` - The key file for signing your assembly.My Tool Window.cs - Subclass of ToolWindowPane. Provides your Tool Window.MyControl.cs - Contains the UI for your Tool Window.PkgCmdID.cs - Contains a list of all Command IDs you generate.ResourcesId.cs - Contains a list of Resource IDs you generate.VsPkg.cs - This is your Package for Visual Studio. This is the heart of your code. Project: Tasklist SampleUIGuids.h - Native equivalent of Guids.cs.PkgCmdID.h - Native equivalent of PkgCmdID.cs.Resource.h - Native equivalent of ResourcesId.cs.Images_24bit.bmp - Provides 24-bit images (true color, with one color used to specify transparency) for use as your tool window icon, and other purposes.Images_32bit.bmp - Provides 32-bit images (true color, with an 8-bit alpha channel) for use in your menu item and in the tool bar we'll add to your tool window.Package.ico - Branding for use in the Help.About dialog.PkgCmd.ctc - Your CommandTable Compiler file. This specifies all of the commands you'll use, and where they appear. We'll go over this soon.Tasklist SampleUI.rc - Native resource file used for specifying your package's icon, output from the CTC compiler, bitmaps, and so forth.

  40. Step 1:Update Wizard Files Solution rename screenshot

  41. Step 2:Add ToolWindow UIAdd the TaskList UI Controls • Open PDCToolWindowClientarea.cs • Delete the button • Add the layout panel ( update properties ) • Columncount=1 • Dock=fill • Add the text box ( update properties ) • Name=txtNewTask • Anchor=top,left,right • Margin=0,0,0,0 • Add listview ( update properties ) • Name=lvwTasks • Anchor=t,b,l,r • Checkboxes=true • Columns • Name=chDescriptin • Text=Description • Name = chPriority • Text = Priority • Fullrowselect=true • Groups, header name=User Tasks • Show groups=true • View=details

  42. Step 2:Add ToolWindow UI TaskList UI InDesigner

  43. Step 3:Text Entry HandlingAdd the event handler • Open PDCToolWindowClientarea.cs and view code • To txtNewTask, using flash button, for KeyDown event • Add private void txtNewTask_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { string newItem = txtNewTask.Text.Trim(); if (newItem == string.Empty) return; AddTask(newItem); txtNewTask.Text = string.Empty; e.Handled = true; } } private void AddTask(string text) { ListViewItem item = new ListViewItem(text); item.Group = lvwTasks.Groups[0]; lvwTasks.Items.Add(item); }

  44. Step 3:Text Entry HandlingAdd the Event Handler

  45. Step 4:Add Menus and ButtonsAdd toolbar to ctc file • Open PkgCmd.ctc file • Add MENUS_BEGIN guidPDCToolWindowCmdSet:ToolbarMenu,/* == Menu */ guidPDCToolWindowCmdSet:ToolbarMenu,/* == Relative to Group*/ 0x0100,/* == Priority */ TOOLWINDOWTOOLBAR, /* == Menu Type*/ "Toolbar"; /* == Text*/ MENUS_END NEWGROUPS_BEGIN guidPDCToolWindowCmdSet:ToolbarMenuGroup, /* == New Group */ guidPDCToolWindowCmdSet:ToolbarMenu, /* == Parent Group*/ 0x0100; /* == Priority */ NEWGROUPS_END BUTTONS_BEGIN guidPDCToolWindowCmdSet:cmdidAddTask, /* == Command */ guidPDCToolWindowCmdSet:ToolbarMenuGroup, /* == Parent Group */ 0x0100, /* == Priority */ guidPDCToolWindowCmdSet:bmpPic2, /* == Image */ BUTTON, /* == Button Type */ , /* == Visibility */ "Add Task"; /* == Text */ BUTTONS_END

  46. Step 4:Add Menus and Buttons Add toolbar to ctc file

  47. Step 4:Menus and Buttons Add toolbar, PkgCmd-ID.h file • Add #define ToolbarMenu 0x1000 #define ToolbarMenuGroup 0x1100 #define cmdidAddTask 0x110

  48. Step 4:Add Menus and Buttons Add toolbar, PkgCmdID.h file

  49. Step 4:Menus and Buttons Add toolbar, PkgCmdID.cs file • Add public const int cmdidAddTask = 0x110; public const int ToolbarMenu = 0x1000; public const int ToolbarMenuGroup = 0x1100;

  50. Step 4:Add Menus and Buttons Add toolbar, PkgCmdID.cs file

More Related