18
Distribute your code with NUget and build vNext Gian Maria Ricci

Distribute your code with NUget and build vNext

Embed Size (px)

Citation preview

Page 1: Distribute your code with NUget and build vNext

Distribute your code with NUget and build vNext

Gian Maria Ricci

Page 2: Distribute your code with NUget and build vNext

Semantic versioning in

• http://semver.org/• Version with three number, MAJOR, MINOR,

PATCH• It enforces a string behavior for Public API• It can be used with less stringent behavior for a

product without public API

Page 3: Distribute your code with NUget and build vNext

MAJOR, MINOR, PATCH

• PATCH number is incremented only when there are bugfix or modification done maintaining full compatibility

• MINOR number is incremented when new functionalities are introduced in a backward compatible way

• MAJOR number is incremented when something about public API changes

Page 4: Distribute your code with NUget and build vNext

GIT AND GITFLOWA successful branch model used with Git to simplify workflow

Page 5: Distribute your code with NUget and build vNext

GitFlow basic

• CheatSheet here: http://danielkummer.github.io/git-flow-cheatsheet/

• Detailed explanation here: http://nvie.com/posts/a-successful-git-branching-model/

• There are two major branches– Master: is the stable and released branch– Develop: is the integration branch, represents stable branch

for development• And some “Support Branches”

– Features– Releases– Hotfixes

Page 6: Distribute your code with NUget and build vNext

Support branches: Release

• Release: used to prepare new release– they allow for

stabilization before merge to master.

– Allow further development on develop without risk

– They start from develop and are merged to master and back to develop

Page 7: Distribute your code with NUget and build vNext

Support branches: Hotfix

• Hotfix: fix severe bugs in production– Allow to quickly fix

production bugs– Starts from master and

merge back in master and develop

– Usually there is only a single hotfix branch at a given time

Page 8: Distribute your code with NUget and build vNext

GitFlow + SemVer = Gitversion.exe

• Gitversion.exe is a simple tools that determine SemVer for a Git Repo

• It walks the history and gives names depending on branch name, commits, tag, etc

• Basically it is a much more evolved version of “git describe”

Page 9: Distribute your code with NUget and build vNext

Build vNext

• Giversion.exe natively integrates with build vNext• I prefer using a PowerShell Script– Can be used by developer– Can be used in a “local build”– Better flexibility on how to use and parse semantic

versioning• Invoke a Gitversion.exe and grab SemVer to

versioning assemblies.

Page 10: Distribute your code with NUget and build vNext

DEMO:

Gitversion.exe simple demo

Page 11: Distribute your code with NUget and build vNext

SemVer for product / applications

• If you do not expose public API SemVer can be simple used to manage versions

• You decide how to handle MAJOR, MINOR, PATCH• GitVersion gives you high flexibility on how it

determine SemVer number

Page 12: Distribute your code with NUget and build vNext

SemVer for NuGet

• A NuGet Package should implement SemVer• NuGet package allows also for “unstable or

prerelease” version• GitVersion natively supports this– You create stable package from master– You create Beta version from hotfixes or releases– You create Unstable version from develop

Page 13: Distribute your code with NUget and build vNext

VSTS package management

• Extension of Visual Studio Team Services• Allows for creation of private NuGet feeds• Still in preview, it offers less management features

than NuGet or MyGet

Page 14: Distribute your code with NUget and build vNext

Automate publishing with a build

• Determine version with GitVersion• Modify AssemblyInfo.cs and AssemblyInfo.vb with

new SemVer Number• Compile, run test• Create Nuget Packages• Publish Nuget Packages

Page 15: Distribute your code with NUget and build vNext

DEMO:

Create build to Pack and Publish NuGet package

Page 16: Distribute your code with NUget and build vNext

Use Chocolatey to distribute an application

• Chocolatey is a package manager for Windows based on NuGet

• It uses NuGet package to package an application• Installation is done with PowerShell scripts

Page 17: Distribute your code with NUget and build vNext

Script preparation

• Carefully manage published artifacts– Pack everything with a script– Prefer uploading a zipped file containing

everything• Create Installer with PowerShell– PowerShell script will accept the zip artifacts as

input– Install your application with whatever you want

(imperative, DSC, etc)• Include zip and script in NuGet package and you’re

done

Page 18: Distribute your code with NUget and build vNext

DEMO:

Create chocolatey package with build vNext