SlideShare a Scribd company logo
1 of 17
www.realdolmen.com




                              NUGET (ANTI-)PATTERNS:
                             TALES FROM THE TRENCHES




JANUARY 16, 2013 | SLIDE 1
WHO AM I?

            Xavier Decoster
            Antwerp, Belgium

            Technical Consultant, RealDolmen
            Co-founder of MyGet.org
            Microsoft Extended Experts Team
            Author of Apress Pro NuGet

            http://www.xavierdecoster.com
            @xavierdecoster


JANUARY 16, 2013 | SLIDE 2
IN THIS SESSION




JANUARY 16, 2013 | SLIDE 3
IN THIS SESSION




JANUARY 16, 2013 | SLIDE 4
#0 – USE PACKAGE RESTORE
        A source repository is for … sources
          What’s a package repository for?


        Impact of package restore
             No more duplication of same binaries
             Less merge conflicts (no binary diff)
             Maintain overview of consumed packages in single place
             Less network I/O (NuGet cache)


        Contra-argument: single point of failure
          Good remark: now deal with it!
          Disconnected from package source(s)?



JANUARY 16, 2013 | SLIDE 5
#1 – USE SEMANTIC VERSIONING
          Major                         Breaking changes
          Minor                         Backwards compatible API additions/changes
          Patch                         Bugfixes not affecting the API
          PreRelease Tag                Alpha, Beta, …, RC1, RC2, …
          Build                         Build stamp, metadata, …

        NuGet versioning algorithm differs from SemVer
          SemVer NuGet

              v              x   SemVer Versioning Scheme    major.minor.patch[-prerelease][+build]

              v              v   NuGet pre-release package   major.minor.patch-prerelease

              v              v   NuGet release package       major.minor.patch

              x              v   Legacy Versioning Scheme    major.minor.build.revision




JANUARY 16, 2013 | SLIDE 6
#2 – DON’T USE 3-DOTS VERSIONING


        Even though NuGet supports it
          Not supported in SemVer
          Not supported in combination with pre-release tag


        Instead use 2-Dots SemVer notation



        Optionally with pre-release tag




JANUARY 16, 2013 | SLIDE 7
#3 – MAINTAIN A SMOOTH UPGRADE PATH
        Don’t change Package ID along the way!
          Your packages will get stuck
          So will your consumers




JANUARY 16, 2013 | SLIDE 8
#3 – MAINTAIN A SMOOTH UPGRADE PATH

                                       MyGet.Core             MyGet.Core
                                                    …
                                 1.0.1-alpha00001       1.0.1-alpha00256


                                      MyGet.Core
                                      1.0.1-alpha


                                      MyGet.Core
                                           1.0.1




        Version Precedence
          1.0.1-alpha00001 < 1.0.1-alpha00256 < 1.0.1-alpha < 1.0.1
          Question: Where does 1.0.1-alpha2 fit?
        Don’t change Package ID along the way!

JANUARY 16, 2013 | SLIDE 9
#4 – SPLIT PACKAGE REPOSITORIES BY AUDIENCE

                                       MyGet.Core             MyGet.Core
                                                    …
                                 1.0.1-alpha00001       1.0.1-alpha00256


                                      MyGet.Core
                                      1.0.1-alpha


                                      MyGet.Core
                                           1.0.1




        Don’t pollute consumers’ repository with your internal
         DEV builds
          MyGet.org is great at this: set up as many feeds as you want and
           promote packages from one to another (including nuget.org!)


JANUARY 16, 2013 | SLIDE 10
#5 – ONCE PUBLISHED, DON’T DELETE PACKAGES
        Unlist packages instead!
          Maintains upgrade path
          Still available through package restore
          Supported by NuGet.org and MyGet.org
        Using own NuGet server or file share?
          Remove user permissions to delete!
        Deleting
          Breaks package restore!
          Forces consumers to upgrade!


  “Attempting to force a user to do something is both an exercise in futility and a
                         great way to guarantee that you have less users overall”
                                                                     - Rob Reynolds


JANUARY 16, 2013 | SLIDE 11
#6 – HAVE A FALLBACK REPOSITORY
        Backup consumed packages
          Mirror them on MyGet.org
          Download them
        Especially when using Package Restore
          From NuGet.org
          From any external feed
        Each consumer has local cache
          %LocalAppData%NuGetCache




JANUARY 16, 2013 | SLIDE 12
#7 – LOOK FOR BINDING REDIRECTS
        Mitigates potential risk for conflicts
          During assembly resolution
          <configuration>
            <runtime>
              <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
                <dependentAssembly>
                  <assemblyIdentity name="myAssembly" publicKeyToken="32ab4ba45e0a69a1"
          culture="neutral" />
                  <bindingRedirect oldVersion="1.0.0.0" newVersion="2.0.0.0"/>
                </dependentAssembly>
              </assemblyBinding>
            </runtime>
          </configuration>

        Investigate why
          Package versions not aligned?

             Package upgrades & version alignment can reduce the
             number of binding redirects


JANUARY 16, 2013 | SLIDE 13
#8 – USE SAMPLE PACKAGE OR README.TXT
        Don’t pollute your actual packages

        Provide a readme.txt
          If you can’t automate the manual instructions
          If you want to have your consumers read some specific info
          Automatically presented to consumer during installation


        Use a sample package when appropriate
          Separate package  Different package ID
          Convention: {packageID}.Sample
                 E.g.: NUnit  NUnit.Sample
          Sample package depends on actual package you want to ship



JANUARY 16, 2013 | SLIDE 14
#8 – USE SAMPLE PACKAGE OR README.TXT




JANUARY 16, 2013 | SLIDE 15
#9 – UNINSTALL SHOULD LEAVE NO TRACES
        Obvious, but often neglected/forgotten
          Be a good citizen


        Uninstall reverses installation + any side-effects
          Unless modifications happened


        Uninstall
          Any files copied (binaries, sources, content, scripts…)
          Tools package: any system modifications (PowerShell modules,
           registry keys, environment variables…)




JANUARY 16, 2013 | SLIDE 16
http://www.xavierdecoster.com
                                                           @xavierdecoster




                                 THANK YOU!
                                              Questions?



                                      Come get your MyGet
                              stickers, you might get lucky!
                                                          


JANUARY 16, 2013 | SLIDE 17

More Related Content

Similar to NuGet (Anti-)Patterns - Tales from the Trenches

NuGet (anti-)patterns - Tales from the Trenches
NuGet (anti-)patterns - Tales from the TrenchesNuGet (anti-)patterns - Tales from the Trenches
NuGet (anti-)patterns - Tales from the TrenchesXavier Decoster
 
Organize your chickens: NuGet for the enterprise
Organize your chickens: NuGet for the enterpriseOrganize your chickens: NuGet for the enterprise
Organize your chickens: NuGet for the enterpriseMaarten Balliauw
 
SDC Sweden - Organize your chickens - NuGet for the Enterprise
SDC Sweden - Organize your chickens - NuGet for the EnterpriseSDC Sweden - Organize your chickens - NuGet for the Enterprise
SDC Sweden - Organize your chickens - NuGet for the EnterpriseMaarten Balliauw
 
An overview of the NuGet ecosystem - Mobel.io
An overview of the NuGet ecosystem - Mobel.ioAn overview of the NuGet ecosystem - Mobel.io
An overview of the NuGet ecosystem - Mobel.ioMaarten Balliauw
 
20111010 agile minds - organize your chickens - nuget for the enterprise
20111010 agile minds - organize your chickens - nuget for the enterprise20111010 agile minds - organize your chickens - nuget for the enterprise
20111010 agile minds - organize your chickens - nuget for the enterpriseXavier Decoster
 
Visug - organize your chickens - nuget for the enterprise
Visug - organize your chickens - nuget for the enterpriseVisug - organize your chickens - nuget for the enterprise
Visug - organize your chickens - nuget for the enterpriseXavier Decoster
 
Organize your chickens: NuGet for the enterprise
Organize your chickens: NuGet for the enterpriseOrganize your chickens: NuGet for the enterprise
Organize your chickens: NuGet for the enterpriseMaarten Balliauw
 
Release management with NuGet/Chocolatey/JIRA
Release management with NuGet/Chocolatey/JIRARelease management with NuGet/Chocolatey/JIRA
Release management with NuGet/Chocolatey/JIRAYaroslav Serhieiev
 
Hosting your own NuGet private repository
Hosting your own NuGet private repositoryHosting your own NuGet private repository
Hosting your own NuGet private repositoryYu GUAN
 
Understanding NuGet implementation for Enterprises
Understanding NuGet implementation for EnterprisesUnderstanding NuGet implementation for Enterprises
Understanding NuGet implementation for EnterprisesJ S Jodha
 
Mvc dev rocks 00 apr 26, 2014 - creating and using nu get in your own house...
Mvc dev rocks 00   apr 26, 2014 - creating and using nu get in your own house...Mvc dev rocks 00   apr 26, 2014 - creating and using nu get in your own house...
Mvc dev rocks 00 apr 26, 2014 - creating and using nu get in your own house...Suthep Sangvirotjanaphat
 
NuGet Packages Presentation (DoT NeT).pptx
NuGet Packages Presentation (DoT NeT).pptxNuGet Packages Presentation (DoT NeT).pptx
NuGet Packages Presentation (DoT NeT).pptxKnoldus Inc.
 
Nuget is easier than you think and you should be using it as both a consumer ...
Nuget is easier than you think and you should be using it as both a consumer ...Nuget is easier than you think and you should be using it as both a consumer ...
Nuget is easier than you think and you should be using it as both a consumer ...Justin James
 
Opendaylight SDN Controller
Opendaylight SDN ControllerOpendaylight SDN Controller
Opendaylight SDN ControllerSumit Arora
 
Full stack development best practice and toolset
Full stack development best practice and toolsetFull stack development best practice and toolset
Full stack development best practice and toolsetReid Lai
 
Using nu get the way you should svcc
Using nu get the way you should   svccUsing nu get the way you should   svcc
Using nu get the way you should svccMaarten Balliauw
 
TDC2016SP - Trilha NoSQL
TDC2016SP - Trilha NoSQLTDC2016SP - Trilha NoSQL
TDC2016SP - Trilha NoSQLtdc-globalcode
 
Meet Magento Spain 2019 - Our Experience with Magento Cloud
Meet Magento Spain 2019 - Our Experience with Magento CloudMeet Magento Spain 2019 - Our Experience with Magento Cloud
Meet Magento Spain 2019 - Our Experience with Magento CloudLyzun Oleksandr
 

Similar to NuGet (Anti-)Patterns - Tales from the Trenches (20)

NuGet (anti-)patterns - Tales from the Trenches
NuGet (anti-)patterns - Tales from the TrenchesNuGet (anti-)patterns - Tales from the Trenches
NuGet (anti-)patterns - Tales from the Trenches
 
Organize your chickens: NuGet for the enterprise
Organize your chickens: NuGet for the enterpriseOrganize your chickens: NuGet for the enterprise
Organize your chickens: NuGet for the enterprise
 
SDC Sweden - Organize your chickens - NuGet for the Enterprise
SDC Sweden - Organize your chickens - NuGet for the EnterpriseSDC Sweden - Organize your chickens - NuGet for the Enterprise
SDC Sweden - Organize your chickens - NuGet for the Enterprise
 
An overview of the NuGet ecosystem - Mobel.io
An overview of the NuGet ecosystem - Mobel.ioAn overview of the NuGet ecosystem - Mobel.io
An overview of the NuGet ecosystem - Mobel.io
 
20111010 agile minds - organize your chickens - nuget for the enterprise
20111010 agile minds - organize your chickens - nuget for the enterprise20111010 agile minds - organize your chickens - nuget for the enterprise
20111010 agile minds - organize your chickens - nuget for the enterprise
 
Unlocked package
Unlocked packageUnlocked package
Unlocked package
 
Visug - organize your chickens - nuget for the enterprise
Visug - organize your chickens - nuget for the enterpriseVisug - organize your chickens - nuget for the enterprise
Visug - organize your chickens - nuget for the enterprise
 
Organize your chickens: NuGet for the enterprise
Organize your chickens: NuGet for the enterpriseOrganize your chickens: NuGet for the enterprise
Organize your chickens: NuGet for the enterprise
 
Release management with NuGet/Chocolatey/JIRA
Release management with NuGet/Chocolatey/JIRARelease management with NuGet/Chocolatey/JIRA
Release management with NuGet/Chocolatey/JIRA
 
Hosting your own NuGet private repository
Hosting your own NuGet private repositoryHosting your own NuGet private repository
Hosting your own NuGet private repository
 
Understanding NuGet implementation for Enterprises
Understanding NuGet implementation for EnterprisesUnderstanding NuGet implementation for Enterprises
Understanding NuGet implementation for Enterprises
 
Mvc dev rocks 00 apr 26, 2014 - creating and using nu get in your own house...
Mvc dev rocks 00   apr 26, 2014 - creating and using nu get in your own house...Mvc dev rocks 00   apr 26, 2014 - creating and using nu get in your own house...
Mvc dev rocks 00 apr 26, 2014 - creating and using nu get in your own house...
 
NuGet Packages Presentation (DoT NeT).pptx
NuGet Packages Presentation (DoT NeT).pptxNuGet Packages Presentation (DoT NeT).pptx
NuGet Packages Presentation (DoT NeT).pptx
 
Nuget is easier than you think and you should be using it as both a consumer ...
Nuget is easier than you think and you should be using it as both a consumer ...Nuget is easier than you think and you should be using it as both a consumer ...
Nuget is easier than you think and you should be using it as both a consumer ...
 
Opendaylight SDN Controller
Opendaylight SDN ControllerOpendaylight SDN Controller
Opendaylight SDN Controller
 
Full stack development best practice and toolset
Full stack development best practice and toolsetFull stack development best practice and toolset
Full stack development best practice and toolset
 
Advanced deployment scenarios
Advanced deployment scenariosAdvanced deployment scenarios
Advanced deployment scenarios
 
Using nu get the way you should svcc
Using nu get the way you should   svccUsing nu get the way you should   svcc
Using nu get the way you should svcc
 
TDC2016SP - Trilha NoSQL
TDC2016SP - Trilha NoSQLTDC2016SP - Trilha NoSQL
TDC2016SP - Trilha NoSQL
 
Meet Magento Spain 2019 - Our Experience with Magento Cloud
Meet Magento Spain 2019 - Our Experience with Magento CloudMeet Magento Spain 2019 - Our Experience with Magento Cloud
Meet Magento Spain 2019 - Our Experience with Magento Cloud
 

NuGet (Anti-)Patterns - Tales from the Trenches

  • 1. www.realdolmen.com NUGET (ANTI-)PATTERNS: TALES FROM THE TRENCHES JANUARY 16, 2013 | SLIDE 1
  • 2. WHO AM I? Xavier Decoster Antwerp, Belgium Technical Consultant, RealDolmen Co-founder of MyGet.org Microsoft Extended Experts Team Author of Apress Pro NuGet http://www.xavierdecoster.com @xavierdecoster JANUARY 16, 2013 | SLIDE 2
  • 3. IN THIS SESSION JANUARY 16, 2013 | SLIDE 3
  • 4. IN THIS SESSION JANUARY 16, 2013 | SLIDE 4
  • 5. #0 – USE PACKAGE RESTORE  A source repository is for … sources  What’s a package repository for?  Impact of package restore  No more duplication of same binaries  Less merge conflicts (no binary diff)  Maintain overview of consumed packages in single place  Less network I/O (NuGet cache)  Contra-argument: single point of failure  Good remark: now deal with it!  Disconnected from package source(s)? JANUARY 16, 2013 | SLIDE 5
  • 6. #1 – USE SEMANTIC VERSIONING Major Breaking changes Minor Backwards compatible API additions/changes Patch Bugfixes not affecting the API PreRelease Tag Alpha, Beta, …, RC1, RC2, … Build Build stamp, metadata, …  NuGet versioning algorithm differs from SemVer SemVer NuGet v x SemVer Versioning Scheme major.minor.patch[-prerelease][+build] v v NuGet pre-release package major.minor.patch-prerelease v v NuGet release package major.minor.patch x v Legacy Versioning Scheme major.minor.build.revision JANUARY 16, 2013 | SLIDE 6
  • 7. #2 – DON’T USE 3-DOTS VERSIONING  Even though NuGet supports it  Not supported in SemVer  Not supported in combination with pre-release tag  Instead use 2-Dots SemVer notation  Optionally with pre-release tag JANUARY 16, 2013 | SLIDE 7
  • 8. #3 – MAINTAIN A SMOOTH UPGRADE PATH  Don’t change Package ID along the way!  Your packages will get stuck  So will your consumers JANUARY 16, 2013 | SLIDE 8
  • 9. #3 – MAINTAIN A SMOOTH UPGRADE PATH MyGet.Core MyGet.Core … 1.0.1-alpha00001 1.0.1-alpha00256 MyGet.Core 1.0.1-alpha MyGet.Core 1.0.1  Version Precedence  1.0.1-alpha00001 < 1.0.1-alpha00256 < 1.0.1-alpha < 1.0.1  Question: Where does 1.0.1-alpha2 fit?  Don’t change Package ID along the way! JANUARY 16, 2013 | SLIDE 9
  • 10. #4 – SPLIT PACKAGE REPOSITORIES BY AUDIENCE MyGet.Core MyGet.Core … 1.0.1-alpha00001 1.0.1-alpha00256 MyGet.Core 1.0.1-alpha MyGet.Core 1.0.1  Don’t pollute consumers’ repository with your internal DEV builds  MyGet.org is great at this: set up as many feeds as you want and promote packages from one to another (including nuget.org!) JANUARY 16, 2013 | SLIDE 10
  • 11. #5 – ONCE PUBLISHED, DON’T DELETE PACKAGES  Unlist packages instead!  Maintains upgrade path  Still available through package restore  Supported by NuGet.org and MyGet.org  Using own NuGet server or file share?  Remove user permissions to delete!  Deleting  Breaks package restore!  Forces consumers to upgrade! “Attempting to force a user to do something is both an exercise in futility and a great way to guarantee that you have less users overall” - Rob Reynolds JANUARY 16, 2013 | SLIDE 11
  • 12. #6 – HAVE A FALLBACK REPOSITORY  Backup consumed packages  Mirror them on MyGet.org  Download them  Especially when using Package Restore  From NuGet.org  From any external feed  Each consumer has local cache  %LocalAppData%NuGetCache JANUARY 16, 2013 | SLIDE 12
  • 13. #7 – LOOK FOR BINDING REDIRECTS  Mitigates potential risk for conflicts  During assembly resolution <configuration> <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="myAssembly" publicKeyToken="32ab4ba45e0a69a1" culture="neutral" /> <bindingRedirect oldVersion="1.0.0.0" newVersion="2.0.0.0"/> </dependentAssembly> </assemblyBinding> </runtime> </configuration>  Investigate why  Package versions not aligned? Package upgrades & version alignment can reduce the number of binding redirects JANUARY 16, 2013 | SLIDE 13
  • 14. #8 – USE SAMPLE PACKAGE OR README.TXT  Don’t pollute your actual packages  Provide a readme.txt  If you can’t automate the manual instructions  If you want to have your consumers read some specific info  Automatically presented to consumer during installation  Use a sample package when appropriate  Separate package  Different package ID  Convention: {packageID}.Sample  E.g.: NUnit  NUnit.Sample  Sample package depends on actual package you want to ship JANUARY 16, 2013 | SLIDE 14
  • 15. #8 – USE SAMPLE PACKAGE OR README.TXT JANUARY 16, 2013 | SLIDE 15
  • 16. #9 – UNINSTALL SHOULD LEAVE NO TRACES  Obvious, but often neglected/forgotten  Be a good citizen  Uninstall reverses installation + any side-effects  Unless modifications happened  Uninstall  Any files copied (binaries, sources, content, scripts…)  Tools package: any system modifications (PowerShell modules, registry keys, environment variables…) JANUARY 16, 2013 | SLIDE 16
  • 17. http://www.xavierdecoster.com @xavierdecoster THANK YOU! Questions? Come get your MyGet stickers, you might get lucky!  JANUARY 16, 2013 | SLIDE 17

Editor's Notes

  1. Even ifyoudon’tuseyourown package repository, youshould have a fallbackrepositorywithbackup of allused packages…DEMO: package restoreDisable internet connectivityand show how the cache canbeused as a fallbackExplain a fallbackrepositoryshouldbemaintainedifusingprimarilyexternalpackage sources