2010年7月29日

How TFS Build Get Associated Changesets/Workitems and Update Workitems

When we queue a build in TFS, if it failed, TFSBuild will create a bug workitem. If it successes, TFSBuild will update associated  workitems.

1 How TFSBuild gets  associated changesets

private void AnalyzeChangesets(Item[] lastItems, Item[] currentItems);

Declaring Type:
Microsoft.TeamFoundation.Build.Tasks.GenCheckinNotesUpdateWorkItems

Assembly:
Microsoft.TeamFoundation.Build.Tasks.VersionControl, Version=9.0.0.0

 
As we know, When we queue a build in TFS, TFSBuild will Label the source code, if the Build successes, TFS will record the Label in Database as the LastGoodBuildLabel of the current Build Definition.And the next time we queue the same build definition, TFSBuild can get LastGoodBuildLabel and CurrentLabel.
The task GenCheckinNotesUpdateWorkItems will get lastItems[] in  LastGoodBuildLabel  and currentItems[] in CurrentLabel.
A If lastItems[i]’s ItemID matches a item in currentItems, like currentItems[j]

Get all changesets between lastItems[i]’s changesetID and currentItems[j]’s changesetID that include this item.

Notice, not all changeset between them include this item

B If lastItems[i]’s ItemID does not match any item in currentItems and does not exist in Latest version

This means that the Item may be deleted in a changeset.Get all changesets between lastItems[i]’s changesetID and VersionSpec.Latest that include this item.

 

C If currentItems[i]’s ItemID does not match any item in lastItems

Get all changesets between ChangesetVersionSpec(1) and currentItems[i]’s changesetID that include this item.

 

2 How TFSBuild get associated WorkItems

Each changesets contains a prroperty WorkItems. In the step1 we can get all associated changesets, and then we can get all WorkItems.

3 How associate a WorkItem to changeset

A In Team Explorer, when you check-in a changeset, you can associate workitems to it.

B in Team Explorer, you can edit a changeset and associate workitems to it.

 

4 How TFSBuild Update WorkItems

TFSBuild will set item["Microsoft.VSTS.Build.IntegrationBuild"] = this.BuildNumber for all associated workitem which have this field.

posted @ 2010-07-29 00:54 Ruiz 阅读(618) 评论(1) 编辑

2010年7月1日

How to set SMTP Port in TFS2010

In TFS2010 Administration Console, you can only set SMTP Server and Email From Address.

image

And in the  TFS Config command line

TFSConfig ConfigureMail /FromEmailAddress:emailAddress /SmtpHost:SMTPHostName

You can not set port. Smtphost:port is not a valid format even though the command could accept it successfully.

In TFS2010, TFSJobAgent is used to send notification. You can edit the TFSJobAgent.exe.config to set the mail port.

Add following script to C:\Program Files\Microsoft Team Foundation Server 2010\Application Tier\TFSJobAgent\TfsJobAgent.exe.config

      `

<?xml version="1.0" encoding="utf-8" ?>
<configuration>

<system.net>
  <mailSettings>
    <smtp >
      <network host="smtpserver" port="26" >
    </smtp>
  </mailSettings>
</system.net>

</configuration>

The host will be ignored but port will be used.

posted @ 2010-07-01 14:24 Ruiz 阅读(461) 评论(0) 编辑

2010年6月1日

Create work item in code editor

摘要: Some developers or testers may find that it will be more convenient that they could create a bug in code editor. Select a method, right click and create a work item. Following steps and sample codes i...阅读全文

posted @ 2010-06-01 11:45 Ruiz 阅读(588) 评论(0) 编辑

2010年3月5日

Listen the Getting event of Version Control

This behavior can be done in many ways, Hongye supplied a solution in http://social.msdn.microsoft.com/Forums/en-US/tfsgeneral/thread/c6a4dc3c-39f9-4e37-9de0-93319273b8bc.

Another way is to use the Getting event of VersionControlServer.

1 Create a Visual Studio Add-in project ListenGetStatus

Add following references

EnvDTE

EnvDTE80

EnvDTE90

Microsoft.TeamFoundation

Microsoft.TeamFoundation.Client

Microsoft.TeamFoundation.VersionControl.Client

Microsoft.VisualStudio.TeamFoundation

Microsoft.VisualStudio.TeamFoundation .Client

Microsoft.VisualStudio.TeamFoundation.VersionControl

2 Implement OnStartupComplete

TeamFoundationServerExt tfsExt;
        VersionControlExt vsExt;
        public void OnStartupComplete(ref Array custom)
        {
            tfsExt = _applicationObject.GetObject("Microsoft.VisualStudio.TeamFoundation.TeamFoundationServerExt") as TeamFoundationServerExt;
            if (tfsExt.ActiveProjectContext.DomainUri == null)
            {
                MessageBox.Show("Error");
                return;
            }


            vsExt = _applicationObject.GetObject("Microsoft.VisualStudio.TeamFoundation.VersionControl.VersionControlExt") as VersionControlExt;

            vsExt.Explorer.Workspace.VersionControlServer.Getting += new GettingEventHandler(VersionControlServer_Getting);
            

        }


        static object locker = new object();
        void VersionControlServer_Getting(object sender, GettingEventArgs e)
        {
            lock (locker)
            {
                FileStream fs = null;
                StreamWriter writer=null;

                try
                {
                    fs = File.Open("C:\\GettingLog.txt", FileMode.Append);

                    writer = new StreamWriter(fs);
                    writer.WriteLine(string.Empty);
                    writer.WriteLine(DateTime.Now.ToString());
                    writer.WriteLine(String.Format("ServerItem={0}", e.ServerItem));
                    writer.WriteLine(String.Format("SourceLocalItem={0}", e.SourceLocalItem));
                    writer.WriteLine(String.Format("ChangeType={0}", e.ChangeType));
                    writer.WriteLine(String.Format("DeletionId={0}", e.DeletionId));
                    writer.WriteLine(String.Format("DiskUpdateAttempted={0}", e.DiskUpdateAttempted));
                    writer.WriteLine(String.Format("IsDelete={0}", e.IsDelete));
                    writer.WriteLine(String.Format("IsLatest={0}", e.IsLatest));
                    writer.WriteLine(String.Format("ItemId={0}", e.ItemId));
                    writer.WriteLine(String.Format("ItemType={0}", e.ItemType));

                    writer.WriteLine(String.Format("Status={0}", e.Status));
                    writer.WriteLine(String.Format("TargetLocalItem={0}", e.TargetLocalItem));
                    writer.WriteLine(String.Format("Version={0}", e.Version));
                    writer.WriteLine(String.Format("Workspace={0}", e.Workspace.DisplayName));

                }
                catch
                {

                }

                finally
                {
                    if (writer != null)
                    {
                        writer.Flush();
                        writer.Close();
                    }
                    if (fs != null)
                    {
                        fs.Flush();
                        fs.Close();
                    }
                }
                

            }

        }

3 In the above code

if (!e.IsDelete && e.IsLatest), so that the item is a new file and latest.

4 Copy the assembly under bin folder and ListenGetStatus.AddIn to My Documents\Visual Studio 2008\Addins

5 Notice that this needs TeamFoundationServer is available OnStartupComplete, you can use a Timer to check it timely if TeamFoundation is not available.

posted @ 2010-03-05 11:11 Ruiz 阅读(191) 评论(0) 编辑

2010年3月3日

How to Enable TFS Email Alert

MSDN has an article about

How to: Configure SMTP Server and E-mail Notification Settings in the Services Web.Config File

 

1 TFS will use the service account(TFSService) to connect to SmtpServer, so TFSService must be a valid member of your SmtpServer, or your SmtpServer allow anonymous senders to send e-mail.

2 Edit the C:\Program Files\Microsoft Visual Studio 2008 Team Foundation Server\Web Services\Services\Web.config

  <appSettings>
    <add key="ConnectionString" value="Data Source=[Server];Initial Catalog=TfsIntegration;Integrated Security=True;Persist Security Info=False;Application Name=TeamFoundation" />
    <add key="eventingEnabled" value="true" />
    <add key="DetailedExceptions" value="false" />
    <add key="emailNotificationFromAddress" value="****@*****.***" />
    <add key="smtpServer" value="[smtpHost]" />
    <add key="enableEmails" value="true" />
  </appSettings>

 

3 Reset IIS

posted @ 2010-03-03 11:27 Ruiz 阅读(152) 评论(0) 编辑

2009年12月10日

How custom wit control Open another work item in Team Explorer

摘要: For the steps how to create and apply custom control, please refer to How to:Create a Custom WI Control Now we want to a feature to make custom wit control open another work item, like the behavior o...阅读全文

posted @ 2009-12-10 17:02 Ruiz 阅读(491) 评论(0) 编辑

2009年12月8日

How to Keep build number / assembly version the same and auto-increment

摘要: First, Thanks for Richard’s blog http://richardsbraindump.blogspot.com/2007/07/versioning-builds-with-tfs-and-msbuild.html A simple way to keep the build number manually is to store last build number ...阅读全文

posted @ 2009-12-08 13:44 Ruiz 阅读(744) 评论(0) 编辑

2009年11月26日

How TO Subscribe TFS Event Using Web Service

摘要: Team Foundation Eventing Service delivers notification of events by e-mail or through Web services. If we subscribe TFS Event using Web Service, we can do much more then E-mail. 1 Create a Asp.NET We...阅读全文

posted @ 2009-11-26 10:03 Ruiz 阅读(1762) 评论(0) 编辑

2009年11月19日

Create TFS Report Step by Step

摘要: After installation of SQL Server Business Intelligence Development Studio(2008), you can create TFS Reports yourself. 1 Using VS to create a Report Server Project “My Reports” 2 Right click Shared Dat...阅读全文

posted @ 2009-11-19 17:28 Ruiz 阅读(714) 评论(0) 编辑

2009年11月10日

How to exclude file types in TFS source control

摘要: The exclude file types are defined in HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\9.0\TeamFoundation\SourceControl\AddOptions\ExcludeMasks, the default value like Debug;Release;*.pdb;*.obj;*.dll...阅读全文

posted @ 2009-11-10 13:15 Ruiz 阅读(98) 评论(0) 编辑

<2012年2月>
2930311234
567891011
12131415161718
19202122232425
26272829123
45678910

导航

统计

公告

昵称:Ruiz
园龄:2年5个月
粉丝:1
关注:0

搜索

 
 

常用链接

我的标签

随笔分类

随笔档案

最新评论

阅读排行榜

评论排行榜

推荐排行榜