Showing posts with label TFS2010. Show all posts
Showing posts with label TFS2010. Show all posts

Wednesday, 31 October 2012

TFS Force Update Branch

In Tfs you can force update branch without loosing all history

1, Check out for edit branch that you want to update
2, Override all files from your working branch
3, Open the solution in your VS
4, Build to make sure that is working
5. Commit changes
6, Execute merge command
7, Commit changes

Done

Wednesday, 12 September 2012

TFS select work items for project


Yesterday, I needed to connect to get all work items for project in Team Foundation 
Server. I have seen couple guides, but not easy to find.  
 
 
 
Here is how to get WorkItems Collection: 
 
This is example code and is not fit to be implemented as it is. 
 

 
protected WorkItemCollection ConnectToTFS()
{
 WorkItemCollection workItemCollection = null; 
 try
 {
  // lets define location of tfs server
  var tfsServerUri = new Uri("http://localhost:8080/tfs");
 
  // Account definition
  // var password = "password";
  // var domain = "domain";
  // var userName = "user";
var projectName ="TfsQueryProject";
  Project project = null;  
 
  // needed if you access tfs as user
  // NetworkCredential account = new NetworkCredential(userName, password,domain)
// TeamFoundationServer server = new TeamFoundationServer(tfsServerUri , account);

 
  TeamFoundationServer server = new TeamFoundationServer(tfsServerUri );

  // make sure you can
  server.Authenticate();
 
  // Get access to work items collection for server.
  WorkItemStore store = new WorkItemStore(server); 
 
  // get existing project 
  project = store.Projects[projectName]; 
 
  if (project == null)
   throw new Exception("Project could not found"); 
 
  // now construct query for work items that are in project 
  string querySql = "SELECT [System.Id], [System.Title], [System.Description] " +
     "FROM WorkItems " +
     "WHERE [System.TeamProject] = '" + PROJECT + "' " +; 
 
 //Execute query to get collection with have all the workitems from the project specified. 
 workItemCollection = store.Query(querySql); 
 
 

 }
 catch (Exception ex)
 { 
   // Todo:  handle exception as required.
throw ex;
 }
 
return workItemCollection; 
}