Fernando Espinosa
Fernando Espinosa

Reputation: 4815

TFS: Branch considerations for sharing scripts across Team Projects

We have a bunch of team projects in our organization.

My goal is to have one core team project, let's call it $/Core, containing a $/Core/Scripts folder under which all our common build/deployment/etc.. scripts would live:

$/Core
└───Scripts
    ├───build
    │       build_functions.ps1
    │       build_tasks.ps1
    │       run_build.ps1
    │
    └───deploy
            deploy_functions.ps1
            deploy_functions_configuration.ps1
            deploy_functions_eventlog.ps1
            deploy_functions_web.ps1

I want to have a way to "share" this common trunk into each one of our individual team projects:

$/Foo
└───Scripts

$/Bar
└───Scripts

$/WallaWalla
└───Scripts

$/Cucamonga
└───Scripts

I was thinking of essentially implementing this via branching. These are our premises:

  1. The scripts ARE NOT and WILL NEVER be customized or modified for the specific needs of each project.
  2. The contents of the $/Core/Scripts trunk will always have priority over all the branches.
  3. So, if we spot a bug or have a feature that want to include in any of our scripts, we would go to the $/Core/Scripts location, and merge into all branches.

THE QUESTION:

Source Control Explorer gives me two options:

Branch

This would allow me to select a target:

enter image description here

enter image description here

Convert to Branch...

But I also see this option available. I can select the one of the desired target folders, make it a branch.

enter image description here

enter image description here

At the end of which my target $/Target/Scripts folder looks like this:

enter image description here

What does this mean?

Upvotes: 2

Views: 145

Answers (1)

Dylan Smith
Dylan Smith

Reputation: 22235

I would recommend not using branching at all in this scenario.

Keep the Core\Scripts folder as the place where you do development on the shared scripts. Then simply copy the scripts folder into each Project that needs to use it. Since you are only making changes to the scripts in the one place (Core), there is no need for branching/merging capabilities, a simple copy will do fine. When you want to pull the latest version of the Scripts into a Project, simply re-copy the Scripts folder.

Branching into each Project would accomplish the same thing but there is a big downside to that (and no significant benefits over a simple copy). You can't have a branch within a branch. And I'm assuming at some point you may want to have multiple branches in Project Foo (e.g. MAIN, DEV, HOTFIX, etc). If Project Foo has Scripts as a branch within it, it severely limits your branching options for Foo.

Upvotes: 3

Related Questions