tfs version control tips and practices for developers version control tips and tricks... ·...

83
TFS Version Control tips and practices for developers 2014

Upload: others

Post on 27-Jul-2020

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: TFS Version Control tips and practices for developers version control tips and tricks... · practices for developers 2014. SharePoint User Experience Data & Business Intelligence

TFS Version Control tips and

practices for developers2014

Page 2: TFS Version Control tips and practices for developers version control tips and tricks... · practices for developers 2014. SharePoint User Experience Data & Business Intelligence

SharePointUser

Experience

Data &

Business

Intelligence

Agile & Lean

ConsultingVisual Studio Cloud Services

Application

Lifecycle

Management

Custom

Development

World-Class Solutions for World-Class Organizations

Ideas transformed into reality through technology.

Imaginet powers North America’s top organizations

Page 3: TFS Version Control tips and practices for developers version control tips and tricks... · practices for developers 2014. SharePoint User Experience Data & Business Intelligence

application lifecycle managementImaginet ALM Adoption Framework

Industry-wide demand for improved software

delivery processes / frameworks to be used

across the Enterprise

Imaginet ALM Adoption Services is proven

approach with concrete phases and objectives

Embodies the patterns that have proven most

successful in increasing team and organization

maturity

Page 4: TFS Version Control tips and practices for developers version control tips and tricks... · practices for developers 2014. SharePoint User Experience Data & Business Intelligence

Who am I?Senior ALM Consultant Imaginet

ALM MVP (9 years)

ALM UG Leader (Montreal 5 years)

Page 5: TFS Version Control tips and practices for developers version control tips and tricks... · practices for developers 2014. SharePoint User Experience Data & Business Intelligence

Agenda

• TFS tour

• Version control operations

• Branching and merging

• Shared Components

• Deployments

Page 6: TFS Version Control tips and practices for developers version control tips and tricks... · practices for developers 2014. SharePoint User Experience Data & Business Intelligence

Team Foundation Server

Page 7: TFS Version Control tips and practices for developers version control tips and tricks... · practices for developers 2014. SharePoint User Experience Data & Business Intelligence
Page 8: TFS Version Control tips and practices for developers version control tips and tricks... · practices for developers 2014. SharePoint User Experience Data & Business Intelligence

Version Control operations

• Workspace

• Get Latest / Specific Versions /Check-out / Check-in

• What happens when I do a check-in?

• How should I use version control properly?

• Pending changes

• Check-in policies

• Shelves

• Changeset

• RollBack

Page 9: TFS Version Control tips and practices for developers version control tips and tricks... · practices for developers 2014. SharePoint User Experience Data & Business Intelligence

What is version control?

• Central repository to manage project components

• You make Workspace in order to work with those components

until they are ready to check-in.

• A working copy of you code is into that workspace

• Supports operations like Add, Check-in, Check-out and history

• Ability to Branch and Merge componants

• All version control operations are atomic and creates Changesets

• The default work mode is shared extract of files

Page 10: TFS Version Control tips and practices for developers version control tips and tricks... · practices for developers 2014. SharePoint User Experience Data & Business Intelligence

Choices with TFS

• Either TFSVC or Git

• Chosen at project create time

• Can’t be changed after

• TFSVC more adoption, more feature complete

• Git gradual adoption, limited features, can use open source

options since it’s the full Git implementation

• Tonight we’ll focus on TFSVC

Page 11: TFS Version Control tips and practices for developers version control tips and tricks... · practices for developers 2014. SharePoint User Experience Data & Business Intelligence

Distributed version control system (DVCS) and Git

Page 12: TFS Version Control tips and practices for developers version control tips and tricks... · practices for developers 2014. SharePoint User Experience Data & Business Intelligence

Version control operations

Page 13: TFS Version Control tips and practices for developers version control tips and tricks... · practices for developers 2014. SharePoint User Experience Data & Business Intelligence

How to create a workspace?

Page 14: TFS Version Control tips and practices for developers version control tips and tricks... · practices for developers 2014. SharePoint User Experience Data & Business Intelligence

How to create a workspace?

Page 15: TFS Version Control tips and practices for developers version control tips and tricks... · practices for developers 2014. SharePoint User Experience Data & Business Intelligence

Why should we create multiple workspaces

• Task separations

• Code verification

• Fix bugs

• R&D

Page 16: TFS Version Control tips and practices for developers version control tips and tricks... · practices for developers 2014. SharePoint User Experience Data & Business Intelligence

Server workspaces

VC Repository$/xxxx

Dev 2 Workspace$/xxxx/yy

Server

Client

C:\WS\xxxx\yy\a.cs...

D:\xxxx\yy\a.cs...

Dev1 Workspace$/xxxx/yy

Ge

t/C

he

ck-o

ut

Che

ck-in

Ge

t/C

he

ck-o

ut

Page 17: TFS Version Control tips and practices for developers version control tips and tricks... · practices for developers 2014. SharePoint User Experience Data & Business Intelligence

Server workspaces (what not to do…)

VC Repository$/xxxx

Server

Client

C:\WS\xxxx\yy\a.cs...

Dev1 Workspace$/xxxx/yy

Ge

t L

ate

st

Windows explorer Delete

?

Page 18: TFS Version Control tips and practices for developers version control tips and tricks... · practices for developers 2014. SharePoint User Experience Data & Business Intelligence

New workspace type: Local

• No locks on files (R/W)

• Can use other tools to manage files

• Can work offline more easily

• .tfignore to ignore certain files in workspace

Page 19: TFS Version Control tips and practices for developers version control tips and tricks... · practices for developers 2014. SharePoint User Experience Data & Business Intelligence

How to set a local workspace?

Page 20: TFS Version Control tips and practices for developers version control tips and tricks... · practices for developers 2014. SharePoint User Experience Data & Business Intelligence

Local workspaces

Page 21: TFS Version Control tips and practices for developers version control tips and tricks... · practices for developers 2014. SharePoint User Experience Data & Business Intelligence

What happens when you check-in to TFS

12V5912

412

Changeset 12

WorkItem 158

Validate

Policies 1

Checkin Policy

Engine

Ch

eckin

Te

sts

Wo

rk Ite

ms

Cu

sto

m P

olic

y

Sta

tic A

na

lysis

Commit

Changes

2

Checkin Event

Update

Work Items

3

Checkin Mail

4

Artifact

Link

Workspace

Page 22: TFS Version Control tips and practices for developers version control tips and tricks... · practices for developers 2014. SharePoint User Experience Data & Business Intelligence

Efficient storate in TFS VC

9 11

12 15

17 17

“The Deltafier”

File Cache

File Store

Do

wn

load

Ha

nd

ler

Up

loa

d

Ha

nd

ler

Compression + Delta Storage ≈ 70% Space Savings!

Get foo.bmp;12

9 12 15 12

Commitfoo.bmp bar.vb

Check-in

.NET Compression (GZip)

BDC

Page 23: TFS Version Control tips and practices for developers version control tips and tricks... · practices for developers 2014. SharePoint User Experience Data & Business Intelligence

How should I use version control properly?

• Get Latest code you want to work on(GL)

• Compile and execute unit tests (if you have any) (CT)

• Check-out (CO) – Don’t do get latest until way later

• Edit– Edit the code (ED)

– Compile and execute unit tests (if you have any) (CT)

– Repeat until done (No GL)

• Get Latest Code (GL) – Bring changes from others into our workspace.– Merge if necessary

• Compile and execute unit tests (if you have any) (CT)

• Check-in (CI)

Page 24: TFS Version Control tips and practices for developers version control tips and tricks... · practices for developers 2014. SharePoint User Experience Data & Business Intelligence

Concept: Pending Changes

Page 25: TFS Version Control tips and practices for developers version control tips and tricks... · practices for developers 2014. SharePoint User Experience Data & Business Intelligence

Concept: Check-in policy

Page 26: TFS Version Control tips and practices for developers version control tips and tricks... · practices for developers 2014. SharePoint User Experience Data & Business Intelligence

Concept: Shelves

Page 27: TFS Version Control tips and practices for developers version control tips and tricks... · practices for developers 2014. SharePoint User Experience Data & Business Intelligence

Concept: Changeset

Page 28: TFS Version Control tips and practices for developers version control tips and tricks... · practices for developers 2014. SharePoint User Experience Data & Business Intelligence

Concept: Rollbacks

Page 29: TFS Version Control tips and practices for developers version control tips and tricks... · practices for developers 2014. SharePoint User Experience Data & Business Intelligence

How to change your compare tool

Page 30: TFS Version Control tips and practices for developers version control tips and tricks... · practices for developers 2014. SharePoint User Experience Data & Business Intelligence

Version Control

Page 31: TFS Version Control tips and practices for developers version control tips and tricks... · practices for developers 2014. SharePoint User Experience Data & Business Intelligence

Trifecta…

Branch

Builds

Environments

Page 32: TFS Version Control tips and practices for developers version control tips and tricks... · practices for developers 2014. SharePoint User Experience Data & Business Intelligence

Branch and merge

Page 33: TFS Version Control tips and practices for developers version control tips and tricks... · practices for developers 2014. SharePoint User Experience Data & Business Intelligence

Branching and Merging

• Why should we use branches

• The different branching models

• Where do we fix bugs?

• Branch visualization

• Common components

• Multi-Clients

Page 34: TFS Version Control tips and practices for developers version control tips and tricks... · practices for developers 2014. SharePoint User Experience Data & Business Intelligence

Why should we use branches

• It’s a solution for managing parallel development

• It’s a solution to help work on features or bug fixes separately

from the main codebase

• It’s a solution to isolate and stabilize code

• Merging is a mechanism to reintegrate code that was previously

isolated and refactored

Page 35: TFS Version Control tips and practices for developers version control tips and tricks... · practices for developers 2014. SharePoint User Experience Data & Business Intelligence

The different isolation mechanisms

Version

• Version changes are isolated one from another

Features

• Experimental and large changes are isolated from the mainline to avoid big disruption

Team

• Isolate team so they don’t interfere between one another

Integration

• Large merge are isolated from the rest of the mainline to avoid disruption.

Page 36: TFS Version Control tips and practices for developers version control tips and tricks... · practices for developers 2014. SharePoint User Experience Data & Business Intelligence

No branching

Page 37: TFS Version Control tips and practices for developers version control tips and tricks... · practices for developers 2014. SharePoint User Experience Data & Business Intelligence

Simple Branching

Page 38: TFS Version Control tips and practices for developers version control tips and tricks... · practices for developers 2014. SharePoint User Experience Data & Business Intelligence

The model I use

Page 39: TFS Version Control tips and practices for developers version control tips and tricks... · practices for developers 2014. SharePoint User Experience Data & Business Intelligence

Standard branching

Page 40: TFS Version Control tips and practices for developers version control tips and tricks... · practices for developers 2014. SharePoint User Experience Data & Business Intelligence

Branching per features

Page 41: TFS Version Control tips and practices for developers version control tips and tricks... · practices for developers 2014. SharePoint User Experience Data & Business Intelligence

Staircase branching

Page 42: TFS Version Control tips and practices for developers version control tips and tricks... · practices for developers 2014. SharePoint User Experience Data & Business Intelligence

Multi-customers (version) to maintain

• Usual for ISV that needs to maintain the « same » application for

multiple customers

• We try and maintain a base version and then « copy » it. Does

that work for you?

• How do we add features to the base that we want to share to

multiple but not necessarily all our customers

Page 43: TFS Version Control tips and practices for developers version control tips and tricks... · practices for developers 2014. SharePoint User Experience Data & Business Intelligence

Multi-customers (version) to maintain

• We branch from MAIN to MAIN between customers (or version)

• We then use the standard model to start starting from the new MAIN in client 1

• Try and start from the BASE unless your new customer is closer to and existing modified customers

Page 44: TFS Version Control tips and practices for developers version control tips and tricks... · practices for developers 2014. SharePoint User Experience Data & Business Intelligence

Multi-customers (version) to maintain

Page 45: TFS Version Control tips and practices for developers version control tips and tricks... · practices for developers 2014. SharePoint User Experience Data & Business Intelligence

Concept: Branch visualisation

Page 46: TFS Version Control tips and practices for developers version control tips and tricks... · practices for developers 2014. SharePoint User Experience Data & Business Intelligence

Concept: Branches are bidirectional

Page 47: TFS Version Control tips and practices for developers version control tips and tricks... · practices for developers 2014. SharePoint User Experience Data & Business Intelligence

Bug fixes - Simple Branching

?

Page 48: TFS Version Control tips and practices for developers version control tips and tricks... · practices for developers 2014. SharePoint User Experience Data & Business Intelligence

Where do we fix bugs?

Page 49: TFS Version Control tips and practices for developers version control tips and tricks... · practices for developers 2014. SharePoint User Experience Data & Business Intelligence

Where do we fix bugs?

?

Page 50: TFS Version Control tips and practices for developers version control tips and tricks... · practices for developers 2014. SharePoint User Experience Data & Business Intelligence

Where do we fix bugs?

Page 51: TFS Version Control tips and practices for developers version control tips and tricks... · practices for developers 2014. SharePoint User Experience Data & Business Intelligence

Where do we fix bugs? (hotfix)

Page 52: TFS Version Control tips and practices for developers version control tips and tricks... · practices for developers 2014. SharePoint User Experience Data & Business Intelligence

Concept: Merging

Page 53: TFS Version Control tips and practices for developers version control tips and tricks... · practices for developers 2014. SharePoint User Experience Data & Business Intelligence

Concept: Conflits

Page 54: TFS Version Control tips and practices for developers version control tips and tricks... · practices for developers 2014. SharePoint User Experience Data & Business Intelligence

Concept: Track Changeset

Page 55: TFS Version Control tips and practices for developers version control tips and tricks... · practices for developers 2014. SharePoint User Experience Data & Business Intelligence

Concept: Merges are unidirectionnal

Page 56: TFS Version Control tips and practices for developers version control tips and tricks... · practices for developers 2014. SharePoint User Experience Data & Business Intelligence

There are costs to using branches• Merging suggests efforts, you need more

expertise and the necessary skills to resolve potential conflicts and to fix bugs resulting from the merge

• Merging add risk of losing fixes when wrong decisions are made at merge time.

Page 57: TFS Version Control tips and practices for developers version control tips and tricks... · practices for developers 2014. SharePoint User Experience Data & Business Intelligence

Latency• The time it takes to move changes between

branches

• Latency depends on…

– Merge frequency

– Depth vs. breadth

– Merge criterias

Page 58: TFS Version Control tips and practices for developers version control tips and tricks... · practices for developers 2014. SharePoint User Experience Data & Business Intelligence

Branching and merging

Page 59: TFS Version Control tips and practices for developers version control tips and tricks... · practices for developers 2014. SharePoint User Experience Data & Business Intelligence

Dependencies

Page 60: TFS Version Control tips and practices for developers version control tips and tricks... · practices for developers 2014. SharePoint User Experience Data & Business Intelligence

Typical scenario 1

• “lib” repository in you version control structure from which you

reference you common components

– Pros

• Only one location to find common components in you project structure

– Cons

• When a common component is changed all application that reference it are

potentially affected and should be retested.

Page 61: TFS Version Control tips and practices for developers version control tips and tricks... · practices for developers 2014. SharePoint User Experience Data & Business Intelligence

Typical scenario 2

• 3rd party repository (might be another project) which we

“branch” into are other projects

– Pro

• Only one location of your common components for multiple projects

– Cons

• Difficult to know which version we have in which projects

Page 62: TFS Version Control tips and practices for developers version control tips and tricks... · practices for developers 2014. SharePoint User Experience Data & Business Intelligence

Nuget

• What is Nuget?

– Nuget is a Visual Studio Extension that lets us add, update or delete

common libraries (can be our own) into projects that use .NET

• Why use Nuget to manage common components

– All the infrastructrure is in place in Visual Studio to deploy and update

Nuget

– Need to write a few PowerShell scripts to integrate with Team Build.

Page 63: TFS Version Control tips and practices for developers version control tips and tricks... · practices for developers 2014. SharePoint User Experience Data & Business Intelligence

How does it work

Internal Nuget

Server or share

Common components builds

Install in a branch of our projects

Page 64: TFS Version Control tips and practices for developers version control tips and tricks... · practices for developers 2014. SharePoint User Experience Data & Business Intelligence

Trifecta…

Branch

Builds

Environments

Page 65: TFS Version Control tips and practices for developers version control tips and tricks... · practices for developers 2014. SharePoint User Experience Data & Business Intelligence

Builds

Page 66: TFS Version Control tips and practices for developers version control tips and tricks... · practices for developers 2014. SharePoint User Experience Data & Business Intelligence

Concept: Build Triggers

Page 67: TFS Version Control tips and practices for developers version control tips and tricks... · practices for developers 2014. SharePoint User Experience Data & Business Intelligence

Concepts: Gated Check-in

Page 68: TFS Version Control tips and practices for developers version control tips and tricks... · practices for developers 2014. SharePoint User Experience Data & Business Intelligence

Concepts: Build workspace

Page 69: TFS Version Control tips and practices for developers version control tips and tricks... · practices for developers 2014. SharePoint User Experience Data & Business Intelligence

Concepts: Index and symbols

Page 70: TFS Version Control tips and practices for developers version control tips and tricks... · practices for developers 2014. SharePoint User Experience Data & Business Intelligence

Trifecta…

Branch

Builds

Environments

Page 71: TFS Version Control tips and practices for developers version control tips and tricks... · practices for developers 2014. SharePoint User Experience Data & Business Intelligence

Environments

Page 72: TFS Version Control tips and practices for developers version control tips and tricks... · practices for developers 2014. SharePoint User Experience Data & Business Intelligence

So…

Branch Environment!

Page 73: TFS Version Control tips and practices for developers version control tips and tricks... · practices for developers 2014. SharePoint User Experience Data & Business Intelligence

Typical environments

DEV

TEST

UAT

PROD

Page 74: TFS Version Control tips and practices for developers version control tips and tricks... · practices for developers 2014. SharePoint User Experience Data & Business Intelligence

Where do we deploy?

DEV

TEST

UAT

PROD

Page 75: TFS Version Control tips and practices for developers version control tips and tricks... · practices for developers 2014. SharePoint User Experience Data & Business Intelligence

How do we “Tag” builds to environments

Page 76: TFS Version Control tips and practices for developers version control tips and tricks... · practices for developers 2014. SharePoint User Experience Data & Business Intelligence

Build web access

Page 77: TFS Version Control tips and practices for developers version control tips and tricks... · practices for developers 2014. SharePoint User Experience Data & Business Intelligence

One Build, Many Stages

DEV QAINT PRODTeam

FoundationServer

TFS

Build

Page 78: TFS Version Control tips and practices for developers version control tips and tricks... · practices for developers 2014. SharePoint User Experience Data & Business Intelligence

DEV

Release Management Architecture

RM ClientRM Web

QARM Server

Page 79: TFS Version Control tips and practices for developers version control tips and tricks... · practices for developers 2014. SharePoint User Experience Data & Business Intelligence

Release information

Copyright 2011 Fujitsu America, Inc.

Page 80: TFS Version Control tips and practices for developers version control tips and tricks... · practices for developers 2014. SharePoint User Experience Data & Business Intelligence

Satellite components

• The power tools

• The web access

• The security

Copyright 2011 Fujitsu America, Inc.

Page 81: TFS Version Control tips and practices for developers version control tips and tricks... · practices for developers 2014. SharePoint User Experience Data & Business Intelligence

The powers tools

Page 82: TFS Version Control tips and practices for developers version control tips and tricks... · practices for developers 2014. SharePoint User Experience Data & Business Intelligence

The web access

Page 83: TFS Version Control tips and practices for developers version control tips and tricks... · practices for developers 2014. SharePoint User Experience Data & Business Intelligence

Concept: Security• Branches

• Directories

• Files