Contains notes and lessons in working technology, especially .NET, Azure, DevOps, Agile, and Team Foundation Server.
Wednesday, July 12, 2017
TFS Hosted Build Controller and .NET 4.7
Friday, November 20, 2015
Getting all changesets associated to work items
using (TextWriter tmp = Console.Out)
{
using (var fs = new FileStream("Test.txt", FileMode.Create))
{
using (var sw = new StreamWriter(fs))
{
Console.SetOut(sw);
var workItemIds = new int[] { 1,2,3 };
var collectionUri = new Uri("http://yourtfs/server/");
try
{
using (var tpc = new TfsTeamProjectCollection(collectionUri))
{
var workItemStore = tpc.GetService<WorkItemStore>();
var teamProject = workItemStore.Projects["project-name"];
var versionControlServer = tpc.GetService<VersionControlServer>();
var artifactProvider = versionControlServer.ArtifactProvider;
var workItems = workItemStore.Query(workItemIds, "Select [System.Id], [System.Title] from WorkItems");
var allChangesets = new List<Changeset>();
foreach (WorkItem workItem in workItems)
{
allChangesets.AddRange(
workItem.Links.OfType<ExternalLink>().Select(link => artifactProvider.GetChangeset(new Uri(link.LinkedArtifactUri)))
);
}
var orderedChangesets = allChangesets.OrderByDescending(c => c.CreationDate).ToArray();
foreach (var changeset in orderedChangesets)
{
Console.WriteLine("{0} on {1:MM-dd-yyyy HH:mm} by {2} ({3} change(s))", changeset.ChangesetId, changeset.CreationDate, changeset.Owner, changeset.Changes.Length);
foreach (var change in changeset.Changes)
{
Console.WriteLine(" [{0}] {1}", change.ChangeType, change.Item.ServerItem);
}
Console.WriteLine("-----");
Console.WriteLine();
}
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
sw.Close();
}
}
Console.SetOut(tmp);
Console.WriteLine("Press any key to exit...");
Console.ReadKey();
}
Wednesday, November 11, 2015
Branching
I had a conversation with a co-worker yesterday about when to create branches in TFS and the conversation reflected a confusion surrounding the use of branches. The coworker suggested that a new branch should be created each time code was being pushed to any environment because it’s the only way you can be completely sure the branch isn’t polluted.
To get the obvious out of the way, if a source control system “pollutes” a branch with no human intervention, get a new source control system. The system has failed at its most basic task. It is very likely this is not the case. It is probably how you are executing your branching and merging strategy.
Let’s take a typical branching structure: Dev > QA > Prod; Dev is the parent of QA, which is the parent of Prod. Changes are merged from Dev into QA, then from QA into Prod. You should never get merge conflicts when going from Dev to QA, or QA to Prod. Because of this, merging is clean and no “pollution” can happen.
How is this possible?
The only way a merge conflict happens is when a change has occurred in the target branch you are merging into which has not been integrated in the source branch. But - and this is the critical point - if you are following good merging practices, if a change must be made in QA or Prod, it is immediately merged into the parent branch(es). No exceptions! If I make a change in the QA branch, my next immediate check-in is a merge to the Dev branch from QA. I will resolve any merge conflicts with this merge, ensuring that my change is properly integrated in Dev. The next time Dev is merged into QA, it will already have this change, and so no merge conflicts will occur.
Sunday, April 1, 2012
Team Foundation Server 2010 Security Practices
TFS Security
| Team Project Roles | Sharepoint Roles | Reporting Services Roles |
| Project Administrators Contributors Readers Builders | Full Control Design Contribute Read | Content Manager Browser |
- ProjectName\Project Administrators Members of this group can administer all aspects of the team project, although they cannot create projects.
- ProjectName\Contributors Members of this group can contribute to the project in multiple ways, such as adding, modifying, and deleting code and creating and modifying work items.
- ProjectName\Readers Members of this group can view the project but not modify it.
- ProjectName\Builders Members of this group have build permissions for the project. Members can manage test environments, create test runs, and manage builds.
TFS Security Tools
Configuring Security
- Use Active Directory groups to manage TFS access
- A/D groups for TFS access should reflect team and project structure.
Scenario 1: Multiple Departments, Multiple Products, Not-Shared within an IT organization
- Architects and possibly team leads should have Project Admin rights, and are the ones responsible for builds.
- Developers should be Contributors.
- QA, BA, and managers should have read-only rights to the source control, but be able to manage work items, iterations, areas, etc.
- The PMO office (executives) want to run reports and read access to source is fine.
| A/D Group Name | TFS Team Project Permission | Members |
| TFS.All | – | All TFS.* groups |
| TFS.ProjectName | – | All TFS.ProjectName.* groups |
| TFS.ProjectName.Admins | Project Administrator | Architects, maybe leads |
| TFS.ProjectName.Developers | Contributor | Developers |
| TFS.ProjectName.Editors | Work Item Editor | QA, BAs, Managers |
| TFS.ProjectName.PMO | Reader | PMO office |
Scenario 2: Multiple Departments, Multiple Products, Shared within an IT organization
| A/D Group Name | TFS Team Project Permission | Members |
| TFS.All | – | All TFS.* groups |
| TFS.ProjectName | – | All TFS.ProjectName.* groups |
| TFS.ProjectName.Admins | Project Administrator | Project leads |
| TFS.ProjectName.Editors | Work Item Editor | Managers and BAs |
| TFS.QA | Work Item Editor for all dev projects | QA |
| TFS.Developers | Contributor for all dev projects | Dev, Architects |
Scenario 3: Single Department, Multiple Products
| A/D Group Name | TFS Team Project Permission | Members |
| TFS.All | – | All TFS.* groups |
| TFS.Admins | Project Administrator | Project leads |
| TFS.Managers | Work Item Editor | Managers |
| TFS.Editors | Work Item Editor for all dev projects | QA and BAs |
| TFS.Developers | Contributor for all dev projects | Dev, Architects |
Scenario 4: Multiple Teams, Multiple Products, Some Common, Some Team-Specific
| A/D Group Name | TFS Team Project Permission | Members |
| TFS.All | – | All TFS.* groups |
| TFS.TeamName | – | All TFS.TeamName.* groups |
| TFS.TeamName.Admins | Project Administrator for team-specific and common projects | Project leads |
| TFS.TeamName.Developers | Contributor for team-specific and common projects | Developers |
| TFS.TeamName.Editors | Work Item Editor for team-specific and common projects | Managers, QA, BAs |
