Pro NuGet, Second Edition

Book description

Pro NuGet will give you a solid, practical, understanding of both how to keep your software dependencies under control and what best-practices have been developed within the NuGet community to ensure long-term reliability. Whether you’re working entirely with .NET assemblies or also using CSS, HTML and JavaScript files within your applications this book will show you how to manage their requirements smoothly and reliably.

As sponsors of the NuGet project Microsoft have led the way in showing how NuGet can be used to great effect; showing how it is now virtually indispensable to anyone working with MVC and the .NET Framework.

So don’t delay! Learn how to use NuGet effectively today and thank yourself for the time and stress that this powerful free extension will save you.

NuGet is an open-source Visual Studio extension that makes it easy to manage libraries, components and configuration files from within your Visual Studio project. As every developer knows, the more complex your application becomes the more chance there is of a dependency conflict arising within the resources upon which you depend. This situation - known as “dependency hell” - used to be an arduous task to unravel and rectify. NuGet changes this situation completely saving you untold time and stress.

Table of contents

  1. Cover
  2. Title
  3. Copyright
  4. Dedication
  5. Contents at a Glance
  6. Contents
  7. About the Authors
  8. About the Technical Reviewers
  9. Foreword
  10. The Bigger Picture
  11. Chapter 1: Getting Started
    1. Preparing Your Workstation
      1. Supported Development Environments
      2. Installing the Essential Software
    2. Installing NuGet
      1. Installing the NuGet Visual Studio Extension (Visual Studio 2010)
      2. Updating the NuGet Visual Studio Extension (Visual Studio 2012)
      3. Downloading the NuGet Command-Line Tool
      4. Installing NuGet Package Explorer
    3. Downloading Development Builds
    4. Getting Further Information
    5. Summary
  12. Chapter 2: Consuming and Managing Packages in a Solution
    1. Consuming Your First NuGet Package
      1. Integrating Visual Studio and NuGet
      2. Finding the Package You Need
      3. Installing a NuGet Package
      4. Uninstalling a Package
      5. Updating a Package to the Latest Version
    2. Using the Package Manager Console
      1. Finding a Specific Version of a Package
      2. Installing a Specific Version of a Package
      3. Uninstalling a Package
      4. Updating a Package to a Newer Version
      5. Using the Package Manager Console Default Project
      6. Reinstalling Packages
    3. Using the NuGet Command Line
      1. Installing a Package
      2. Updating a Package
      3. Uninstalling a Package
    4. Managing Packages in a Solution
      1. Installing Packages in Multiple Projects
      2. Uninstalling Packages from Multiple Projects
      3. Updating Packages in Multiple Projects
    5. Visualizing Package Dependencies by Using the Package Visualizer
    6. Working with Package Sources and the Package Cache
      1. Managing Package Sources
      2. How the Cache Impacts Package Installation
      3. Authenticating Package Sources
    7. Choosing Stable vs. Prerelease Versions
    8. Summary
  13. Chapter 3: Authoring Packages
    1. Understanding Package Definition Strategies
      1. Creating a Simple Package Manifest
      2. Exposing Package Metadata
      3. Specifying the Package Contents
      4. Package Versioning
      5. Nuspec Inheritance
    2. Creating Packages by Using the NuGet Command Line
      1. Creating a Package from a Convention-Based Directory
      2. Creating a Package from an Assembly
      3. Creating a Package from a Visual Studio Project
    3. Creating Packages by Using NuGet Package Explorer
    4. Creating Localized Packages
      1. Setting the Default Language
      2. Using a Single-Package Approach
      3. Using a Satellite-Package Approach
      4. Comparing Approaches
    5. Adding the Finishing Touches
      1. Provide a Smooth User Experience
      2. Learn from Others by Inspecting Their Packages
      3. Design from a Consumer’s Perspective
      4. Provide a Sample Package
    6. Testing Packages
    7. Summary
  14. Chapter 4: Publishing Packages
    1. Creating a Sample Package
    2. Contributing to nuget.org
      1. Creating an Account
      2. Publishing a NuGet Package
      3. Managing Published Packages
      4. Obtaining an API Key
    3. Publishing Packages by Using the NuGet Command Line
      1. Publishing a Package to a NuGet Feed
      2. Managing API Keys
    4. Publishing Packages by Using NuGet Package Explorer
    5. Publishing a Symbol Package
      1. Configuring Visual Studio
      2. Consuming Symbols for NuGet Packages
      3. Publishing Symbols for Your Own NuGet Packages
    6. Summary
  15. Chapter 5: Hosting Your Own NuGet Server
    1. Why Host Your Own NuGet Feed?
    2. Setting Up a Simple NuGet Package Repository
    3. Creating a Basic NuGet Server
      1. Configuring the Packages’ Location
      2. Setting the API Key
    4. Using the NuGet Gallery
      1. Downloading the Source Code
      2. Creating a SQL Server Database
      3. Configuring NuGet Gallery
      4. Compiling NuGet Gallery
      5. Finalizing Your NuGet Gallery Installation
    5. Using NuGet as a Service: MyGet
      1. Creating a NuGet Feed on MyGet
      2. Mirroring Packages from the Official NuGet Package Source
      3. Applying Security Settings to Your Feed
      4. What Else Is There?
    6. Using ProGet
      1. Downloading and Installing ProGet
      2. Consuming NuGet Packages by Using ProGet
      3. Adding Your Own NuGet Packages
      4. What Else Is There?
    7. Using TeamCity as a NuGet Repository
      1. Pushing Packages to a NuGet Feed
      2. Exposing Build Artifacts by Using TeamCity’s NuGet Feed
    8. Using Other NuGet Repositories
    9. Preventing Disruptions in the Continuum
    10. Summary
  16. Chapter 6: Continuous Package Integration
    1. Using a No-Commit Strategy
      1. Source Control Layout
      2. Exploring Trade-offs
      3. Tracking Package Metadata
      4. Enabling Package Restore
    2. Promoting Packages
      1. Prereleasing Packages
      2. Phasing Out Packages
    3. Summary
  17. Chapter 7: Automated Delivery
    1. Deploying Artifacts with Octopus Deploy
      1. What Is Octopus Deploy?
      2. Installing Octopus Deploy
      3. Deploying a Project by Using Octopus Deploy
    2. Deploying Software with Chocolatey
      1. What Is Chocolatey?
      2. Installing Chocolatey
      3. Using Chocolatey
      4. Distributing Chocolatey Goodness
    3. Summary
  18. Chapter 8: NuGet Recipes
    1. Team Foundation Server/Service
      1. Working with NuGet package restore
      2. Creating and Publishing NuGet packages during a build
    2. TeamCity
      1. Installing NuGet to TeamCity Build Agents
      2. NuGet Build Runners
      3. Enabling the TeamCity NuGet feed
      4. TeamCity and OctopusDeploy
    3. Windows Azure Web Sites and NuGet Package Restore
      1. Creating and Configuring the Windows Azure Web Site for Auto-Deployment from GitHub
      2. Configuring NuGet Package Restore from a Secured Feed
    4. NuGet and MyGet
      1. Using MyGet Build Services
      2. Continuous Delivery of NuGet packages
      3. Working with aggregate feeds
    5. Setting up a Private Symbol Server
      1. Installing prerequisites
      2. Setting up the Symbol Server
      3. Pushing Symbols
      4. Consuming Symbols
    6. Package Source Discovery
    7. Summary
  19. Chapter 9: Extending NuGet
    1. Why Extend NuGet?
    2. Extending the NuGet Command Line
      1. Creating a Custom NuGet Command
      2. Installing a Custom NuGet Command
      3. Creating Custom Package Analysis Rules
    3. Extending the Package Manager Console
      1. Creating and Distributing a Package Manager Console Extension
      2. Adding Tab Expansions to Package Manager Console Extensions
    4. Extending NuGet Package Explorer
      1. Creating a Custom Content Viewer
      2. Creating a Custom Package Validation Rule
      3. Creating a Custom Package Command
    5. Invoking NuGet Services from Inside Visual Studio
    6. Summary
  20. Chapter 10: NuGet as a Protocol
    1. Understanding Protocols
    2. Creating a Pluggable Application by Using NuGet
      1. Defining Architecture and Technologies
      2. Defining the ISearchEngine Interface
      3. Importing Search Engines
      4. Installing Plug-ins into SearchPortal
      5. Loading Installed Plug-ins into MEF’s Catalog
      6. Creating and Publishing Plug-ins
    3. Creating a Self-Updating Application by Using NuGet
      1. The NuGet Command Line as Example
      2. An Application Bootstrapper That Checks for Updates
    4. Summary
  21. Appendix A: Package Manifest Reference
    1. Creating the Metadata Section
      1. Package Manifest Metadata elements
      2. Populating Replacement Tokens
    2. Referencing Dependencies
      1. Specifying Dependencies
      2. Specifying Explicit Assembly References
      3. Specifying Framework Assembly References from the GAC
    3. Specifying Files to Include in a Package
      1. Exploring File Element Examples
      2. Excluding Files from the Package Manifest
  22. Appendix B: NuGet Command-Line Reference
    1. The help Command
    2. The config Command
    3. The delete Command
    4. The install Command
    5. The list Command
    6. The pack Command
    7. The push Command
    8. The restore Command (NuGet >2.7)
    9. The setapikey Command
    10. The sources Command
    11. The spec Command
    12. The update Command
  23. Appendix C: NuGet Package Manager Console PowerShell Reference
    1. Support for Common Parameters
    2. Adding Binding Redirects
    3. Getting a Package or a Set of Packages
    4. Getting Project Information
    5. Installing Packages
    6. Opening Package Pages
    7. Uninstalling Packages
    8. Updating Packages
    9. Chaining PowerShell Cmdlets
  24. Appendix D: NuGet Configuration File Reference
    1. Configuration File Locations
      1. Which File Will NuGet Use?
      2. Useful Scenarios
    2. Configuration File
  25. Index

Product information

  • Title: Pro NuGet, Second Edition
  • Author(s): Maarten Balliauw, Xavier Decoster
  • Release date: October 2012
  • Publisher(s): Apress
  • ISBN: 9781430260028