Controlling
Component Chaos
with NuGet and
Versioningby John Williston Perforce Software
Controlling Component Chaos with NuGet and Versioning
John WillistonPerforce Software
Controlling Component Chaos with NuGet and Versioning
• NuGet overview
• Consuming components
• Producing components
• Gotchas and Q&A
Agenda
Controlling Component Chaos with NuGet and Versioning
NuGet Overview
Controlling Component Chaos with NuGet and Versioning
• YAPM: Yet Another Package Manager
• Packages are zip archives
• Originally .NET, now anything
• Discovery, packages, dependencies, updates
What is NuGet?
Controlling Component Chaos with NuGet and Versioning
• Web site/service describes packages
• NuGet.exe and VisualStudio extension:
– Makes packages from specs
– Pulls packages by ID and version
– Pushes packages to publish
How Does It Work?
Controlling Component Chaos with NuGet and Versioning
Nuget.org web site
NuGet package feed(AtomPub)
NuGet.exe Tool
NuGet Extension
NuGet Diagram
Controlling Component Chaos with NuGet and Versioning
Consuming Components
Controlling Component Chaos with NuGet and Versioning
Main NuGet Web Site
Controlling Component Chaos with NuGet and Versioning
Package Details
Controlling Component Chaos with NuGet and Versioning
Managing Packages in a Solution
Controlling Component Chaos with NuGet and Versioning
• Adds new build targets
• Pulls and unzips packages
• Creates/updates configuration files
• Hooks up dependencies
• Runs installer scripts (if any)
How Does It Work?
Controlling Component Chaos with NuGet and Versioning
• How does NuGet track what I’m using?
• How do others get the same packages?
• Do I need to add it to my build process?
Some Obvious Questions
Controlling Component Chaos with NuGet and Versioning
NuGet Folders and Files
Controlling Component Chaos with NuGet and Versioning
Packages.config Contents
Controlling Component Chaos with NuGet and Versioning
• All packages.config files
• The .nuget folder contents
• Nothing else needs to be versioned
What Do I Version?
Controlling Component Chaos with NuGet and Versioning
• Pulls by semantic version
• Update process prefers latest
• Default strategy updates dependencies too
• Update must be used carefully
Component Versions
Controlling Component Chaos with NuGet and Versioning
• Prefer implicit checkout
• Reconcile before and after
• P4 ignore is your friend
• Be sure to use P4VS
• Isolate big NuGet operations
Perforce Tips
Controlling Component Chaos with NuGet and Versioning
Implicit Checkout Means +Allwrite
Controlling Component Chaos with NuGet and Versioning
• Problems installing/updating
• Mark as edit ahead of time
• Seek masochist support group
But I Prefer Explicit Checkout!
Controlling Component Chaos with NuGet and Versioning
• Clean to catch old references
• Different feeds for different builds
• Automate third-party package audits
• Scripting catches multiple versions
DevOps Considerations
Controlling Component Chaos with NuGet and Versioning
Producing Components
Controlling Component Chaos with NuGet and Versioning
• Privacy requires your own NuGet server
• Organizational shift in thinking
• Good naming conventions early
• Understand semantic versioning
Some Assembly Required
Controlling Component Chaos with NuGet and Versioning
• How do I make my own packages?
• Where do I put them?
• And how do I put them there?
Some Obvious Questions
Controlling Component Chaos with NuGet and Versioning
• The *.nuspec file
– Useful metadata
– Content and layout
– Other package dependencies
• NuGet tool creates package
• Push with a new version number
Building a Package
Controlling Component Chaos with NuGet and Versioning
• Understand semantic versioning
• Develop components in isolation
• Careful interface design and versioning
• Unit test at least every public method
• Document all public symbols
Development Best Practices
Controlling Component Chaos with NuGet and Versioning
• Automate push on release and documentation
• Automate labelling for traceability
• Source/symbol serving is your friend
• Version all the things! (if you wish)
DevOps Considerations
Controlling Component Chaos with NuGet and Versioning
Gotchas and Q&A
Controlling Component Chaos with NuGet and Versioning
• Pre-configure Visual Studio
• Relative paths for source server
• NuGet extension problem with P4VS
• Update versioning strategy
• Soft dependencies can hurt
Common Gotchas
Controlling Component Chaos with NuGet and Versioning
THANK YOU!!!
John Williston, Ph.D
@p4jbw
P4Ideax Forums