Coding Faster: Getting More Productive with Microsoft® Visual Studio® Covers Microsoft® Visual Studio® 2005, 2008, and 2010 Zain Naboulsi Sara Ford Published with the authorization of Microsoft Corporation by: O’Reilly Media, Inc. 1005 Gravenstein Highway North Sebastopol, California 95472 Copyright © 2011 by Zain Naboulsi and Sara Ford All rights reserved. No part of the contents of this book may be reproduced or transmitted in any form or by any means without the written permission of the publisher. ISBN: 978-0-7356-4992-7 1 2 3 4 5 6 7 8 9 M 6 5 4 3 2 1 Printed and bound in the United States of America. Microsoft Press books are available through booksellers and distributors worldwide. If you need support related to this book, email Microsoft Press Book Support at [email protected]. Please tell us what you think of this book at http://www.microsoft.com/learning/booksurvey. Microsoft and the trademarks listed at http://www.microsoft.com/about/legal/en/us/IntellectualProperty/ Trademarks/EN-US.aspx are trademarks of the Microsoft group of companies. All other marks are property of their respective owners. The example companies, organizations, products, domain names, email addresses, logos, people, places, and events depicted herein are fictitious. No association with any real company, organization, product, domain name, email address, logo, person, place, or event is intended or should be inferred. This book expresses the author’s views and opinions. The information contained in this book is provided without any express, statutory, or implied warranties. Neither the authors, O’Reilly Media, Inc., Microsoft Corporation, nor its resellers, or distributors will be held liable for any damages caused or alleged to be caused either directly or indirectly by this book. Acquisitions and Developmental Editor: Russell Jones Production Editor: Adam Zaremba Technical Reviewer: Kevin Stevens Copyeditor: Richard Carey Indexer: Ron Strauss Proofreader: Nancy Sixsmith Cover: Karen Montgomery Compositor: Ron Bilodeau Illustrator: Robert Romano First and foremost to God and Jesus Christ for making this all possible. To my mom, Helen Naboulsi, for always encouraging me to go above and beyond to reach my goals, and to Russell Chandler for being the greatest nephew anyone could ever have. Zain Naboulsi Senior Developer Evangelist, Microsoft To my parents, Jane and Louie Smolensky, for encouraging me to program on the computer when I was 5 years old, and to Beulah Bourgeois and Annabelle Fayard for being the best babysitters a little girl could ever hope for. Sara Ford Contents at a Glance Part I Productivity Techniques 1 Getting Started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 2 Projects and Items . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43 3 Getting to Know the Environment . . . . . . . . . . . . . . . . . . . . . . . . . 83 4 Working with Documents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153 5 Finding Things . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171 6 Writing Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209 > m 7 Debugging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291 o c k. o o b e Part II Extensions for Visual Studio w o w 8 Visual Studio Extensions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 385 w. w w < k o o B e w! o W m o d fr a o nl w o D v Table of Contents Foreword . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xxiii Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxvii Part I Productivity Techniques 1 Getting Started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 01 .01 Running Multiple Versions of Visual Studio Side-By-Side . . . . . . . . . . . . . .3 01 .02 Getting Table of Contents in Visual Studio 2010 Online Help . . . . . . . . . . .4 Online Help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4 Using Classic View . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5 01 .03 Exporting Your Environment Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6 01 .04 Remove Projects from the Recent Projects List . . . . . . . . . . . . . . . . . . . . . . .9 01 .05 AutoRecover . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .10 01 .06 Improving Performance by Changing the Visual Experience in Visual Studio 2010 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .12 01 .07 Change Tool Window Animations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .14 01 .08 Importing or Changing Your Environment Settings . . . . . . . . . . . . . . . . . .14 01 .09 Change Your Visual Studio Color Scheme . . . . . . . . . . . . . . . . . . . . . . . . . . .17 Seeing What You Like . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .18 Getting the Goods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .18 Changing Your Colors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .21 Resetting the Colors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .24 01 .10 Reset All Your Development Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .25 01 .11 Customize Your Toolbars in Visual Studio 2010: Toolbars Tab . . . . . . . . .27 Custom Toolbars . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .28 01 .12 Customize Your Toolbars in Visual Studio 2010: Commands Tab . . . . . . .30 Rearrange . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .32 Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .32 Buttons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 Modify Selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .34 01 .13 Visual Studio Logging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .37 01 .14 Visual Studio Safe Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .38 01 .15 The ResetSettings Switch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .39 Two Different Machines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .39 Same Machine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .40 vii viii Table of Contents 2 Projects and Items . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43 02 .01 Search for Project Templates in the New Project Dialog Box . . . . . . . . . .43 Good News . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .44 Bad News . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .44 More Good News . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .44 02 .02 Recent Project Templates in the New Project Dialog Box . . . . . . . . . . . . .45 02 .03 Using Older Frameworks with Multi-Targeting . . . . . . . . . . . . . . . . . . . . . .45 02 .04 Create Web Application or Virtual Directory in IIS . . . . . . . . . . . . . . . . . . .46 02 .05 Multiple Startup Projects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .48 02 .06 Change the Default New Project Location . . . . . . . . . . . . . . . . . . . . . . . . . .50 02 .07 Track Active Item in Solution Explorer . . . . . . . . . . . . . . . . . . . . . . . . . . . . .51 02 .08 Type-Ahead Selection Support in Solution Explorer . . . . . . . . . . . . . . . . . .52 02 .09 Using Solution Folders . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .54 Adding Solution Folders . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .54 Removing Solution Folders . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .55 02 .10 Navigating Property Tabs in the Project Properties . . . . . . . . . . . . . . . . . .55 02 .11 Pin a Project to the Recent Projects List . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55 02 .12 Creating Temporary Projects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .56 02 .13 Create Your Own Item Template . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .57 02 .14 Roll Your Own Project Template with the Export Template Wizard . . . . .64 02 .15 Organizing Your Custom Item Templates . . . . . . . . . . . . . . . . . . . . . . . . . . .68 02 .16 Organizing Your Custom Project Templates . . . . . . . . . . . . . . . . . . . . . . . . .71 02 .17 Reorganize the Default Item Templates . . . . . . . . . . . . . . . . . . . . . . . . . . . .74 02 .18 Reorganize the Default Project Templates . . . . . . . . . . . . . . . . . . . . . . . . . .77 02 .19 Change the Templates that Appear in the New Project or Item Dialog Boxes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .80 3 Getting to Know the Environment . . . . . . . . . . . . . . . . . . . . . . . . . 83 03 .01 Rearrange Windows in Visual Studio 2010 Using the Guide Diamond . .83 03 .02 Dock a Floating Tool Window Back to Its Previous Location . . . . . . . . . .85 03 .03 Cycle Through Your Open Tool Windows . . . . . . . . . . . . . . . . . . . . . . . . . . .86 03 .04 Closing Tool Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .87 03 .05 Expand and Collapse All in the Toolbox . . . . . . . . . . . . . . . . . . . . . . . . . . . .87 03 .06 Searching in the Toolbox . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .88 03 .07 Navigate Among Tabs in the Toolbox . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .89