Search This Blog

Thursday, December 28, 2006

Get Build Changes (ChangeSetData, Changeset, Change)

To improve our custom build report that I have talked about before (Custom Build Logger) I wanted to add information regarding the users that are involved in this build and the changes that they made to source control.
Here's an example how to go over build changes:


using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.VersionControl.Client;
using Microsoft.TeamFoundation.Build.Proxy;

TeamFoundationServer tfs = new TeamFoundationServer(server);
VersionControlServer vcs = (VersionControlServer)tfs.GetService(typeof(VersionControlServer));
BuildStore bs = (BuildStore)tfs.GetService(typeof(BuildStore));
ChangeSetData[] changeSetsData = bs.GetChangeSetsForBuild(bs.GetBuildUri(project, buildNumber));
foreach (ChangeSetData changeSetData in changeSetsData)
{
//Here you can do something with the ChangeSetData properties
//changeSetData.CheckedInBy...
//Get the ChangeSetData Changeset
Changeset changeSet = vcs.GetChangeset(changeSetData.ChangeSetId);
//Go over the Changeset changes
foreach (Change change in changeSet.Changes)
{
//Here you can do something with the Change
//change.Item.ServerItem...
}
}

Monday, December 25, 2006

File was rejected by digital signature policy (VS 2005 SP1 Installation)

I'm installing Visual Studio 2005 SP1 on our servers and I got this error while running the installation. It seems to be a memory issue while trying to verify the package. Here's a KB that that was suppose to help solving the problem: http://support.microsoft.com/kb/925336. Here's a detailed guide:
1) Open Administrative Tools -> Local Security Policy.
2) Click the "Software Restriction Policies" item on the left tree. If you see on the right side of the window a message that says: "No Software Restriction Policies Defined" then you need to right click the "Software Restriction Policies" item on the left side of the window and select "Create New Policies". Look at the screen shot below:



3) After doing this (or you did not have to), double click the "Enforcement" item in the right side of the window. In the new opened window select the "All users except local administrators" radio button. and apply the changes. Take a look at the picture below:





4) After doing all those still I had the same error. I searched and found another post (http://blogs.msdn.com/heaths/archive/2006/09/22/Enabling-Large-Patches-to-Install.aspx) regarding big patches installation and followed these steps:

Set the DWORD value PolicyScope to 1 in the HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\Safer\CodeIdentifiers key. Run "net stop msiserver" (without quotes). Install the EXE or MSP (if you extracted the MSP from the EXE).

Don't forget to set it back to the old value.

This helped me solve the issue and after few hours of struggling I finished installing the patch. I don't know if you need to do everything I mentioned. Maybe you can apply the last one only and it will work.

Thursday, December 14, 2006

As I mentioned before, yesterday, I spoke at the Team System event is Israel. I have joined SRL to a lecture on Configuration Management and Build Enhancements. It was a pleasure sharing the knowledge. Here I am:






Tuesday, December 12, 2006

Drag and Drop Files Order

Check out this interesting question on Yedda


Yedda - People.Sharing.Knowledge.WinAmp 5.32: playlist

I love Winamp and I've been using it since version 2 I think, but there's one problem with it that I keep getting: when I drag files from Windows Explorer to the Winamp playlist, the order of the files changes. When will they fix it?

Topics: , ,

Asked by hubble on December 11, 2006

View the entire discussion on YeddaYedda - People.Sharing.Knowledge.




Check out this interesting answer on Yedda


Yedda - People.Sharing.Knowledge.WinAmp 5.32: playlist

Actually, it's a windows and not WinAmp issue. If you'll do this with Windows Media Player you'll get the same result. I even wrote an application once that had the same behaviour. The reason it happens is that when you start dragging windows consider the file that the mouse cursor is pointing on as the first one in the list. If you will point to the first file in the list you will get the list as it should be but probably (and naturally...) you are pointing to the middle of the list and the files are added not as you wished.

Hope I helped.

Topics: , ,

Answered by dudushmaya on December 11, 2006

View the entire discussion on YeddaYedda - People.Sharing.Knowledge.


Monday, December 11, 2006

Microsoft Team System Event in Israel

I'm going to speak this Wednesday at the Annual Microsoft Team System Event in Israel. I will talk about how we see Team System in our organization and present some of the enhancements we did.
Team System Rocks!!! Spread the word...

Wednesday, December 06, 2006

Custom Build Logger (ILogger)

Developers were complaining that the build log (Build.log) is too complicated to read and they only want so see the log when the build fails and why.

The first thing I though doing was to write a log reader. Wrong!!! I googled "team build logger" and found this page: http://blogs.msdn.com/gautamg/archive/2006/04/19/578967.aspx which explains how to write a custom build logger (by implementing ILogger interface). I was already familiar with this interface and used it once while writing an MSBuild script executer. The important stuff from this blog was that you can register a custom logger for a team build by adding a line to the TFSBuild.rsp for the build type (/Logger:LoggerClassFullName, AssemblyFileName ).

So, I've implemented a new logger which captures build errors and send them at the end of the build to developers. The thing is that failed tests are treated as warning and do not fail the build (The log view in Visual Studio captures the warnings and mark the build as failed). The worse thing is that there is not logging regarding the failed tests. So we are back where we've started with a log that only says that the tests failed. The next step to try and solve this issue was finding the trx files and parsing them for the test results. In the code below you can see how I did it. Ignore the whole code just look at the SelectNodes and SelectSingleNode lines which retrieve the errors from the trx file. You can download the sources from here. Thank you Eyal for the free hosting... To make it work you need to update the config file with your settings and add the line: /Logger:BuildLoggers.ErrorsMailLogger, BuildLoggers.dll to the TFSBuild.rsp file.

XmlNodeList xmlNodeList = testResultsXmlDoc.SelectNodes("//UnitTestResult[errorInfo]");

xmlNode.SelectSingleNode("testName").InnerText

xmlNode.SelectSingleNode("errorInfo").SelectSingleNode("message").InnerText

xmlNode.SelectSingleNode("errorInfo").SelectSingleNode("stackTrace").InnerText

Clarizen Secures $7 Million in First-Round Funding Co-Led by Benchmark Capital and Carmel Ventures

We had a nice press release yesterday. You can read it here: http://www.prnewswire.com/cgi-bin/stories.pl?ACCT=104&STORY=/www/story/12-04-2006/0004484503&EDATE=.
Some other article regarding Clarizen:
http://www.themarker.com/tmc/article.jhtml?ElementId=gg20061204_989865&strToSearch=%F7%EC%F8%E9%E6%EF - Hebrew
http://www.degardener.com/2006/12/05/clarizen-is-a-first-in-a-number-of-ways/

Wednesday, November 29, 2006

Another Terminals Version

Again, we have published a new Terminals version. This time we've added a cool feature called: Desktop Share. With this feature you can define a share (should be to your desktop) on the terminal server. When you drag and drop files to your terminal server window those files will be copied to that share. It's a little trick to support easy file copy to the server. If you would like to enable copy and paste of files between the client and the server you can read: HOW TO: Securely Copy and Paste Files Between the Terminal Services Client and the Terminal Server in Windows 2000.

Tuesday, November 28, 2006

XPath Nested Queries

Xml XPath queries are not so straight forward and each time I'm using them I struggle it.

On one of our inside tools I needed to parse an Xml file but the selected nodes were reflected from their value and not from their name only. I was used to have a SelectSingleNode(nodeName) or SelectNodes(nodeName) that did the job for me but now I needed something else.

Here's an example of the Xml:

<Data>
    <Table>
        <Row>
            <Field Name="Name" Value="object1"/>
            <Field Name="Type" Value="int"/>
            <Field Name="Value" Value="1"/>
        </Row>
        <Row>
            <Field Name="Name" Value="object2"/>
            <Field Name="Type" Value="int"/>
            <Field Name="Value" Value="2"/>
        </Row>
        <Row>
            <Field Name="Name" Value="object3"/>
            <Field Name="Type" Value="string"/>
            <Field Name="Value" Value="aaa"/>
        </Row>
        <Row>
            <Field Name="Name" Value="object4"/>
            <Field Name="Type" Value="string"/>
            <Field Name="Value" Value="bbb"/>
        </Row>
        <Row>
            <Field Name="Name" Value="object5"/>
            <Field Name="Type" Value="int"/>
            <Field Name="Value" Value="3"/>
        </Row>
    </Table>
</Data>

Now, I would like to select all <Field> nodes that are from type int. So I need to write query that will find all <Field> nodes that have "Name" attribute with the value "Type" and "Value" attribute with the value "int".

Here's how the query should look when you are using XmlDocument.SelectNodes or XmlDocument.SelectSingleNode:

"//Field[@Name='Type'][@Value='int']"

Now, how do I select all the <Row> nodes that correspond to this query? I've tried and found out that a nested query actually works...

"//Row[Field[@Name='Type'][@Value='int']]"

Xml XPath queried can be very powerful.

Terminals New Version

I have posted before about this tool and now it has a new version.

We fixed some bugs and added these features:
1) Order toolbar buttons
2) Remote server port selection
3) Remote sounds
4) Connect automatically to local devices (Disk drives, printers, serial ports)

You can download it here: http://www.codeplex.com/Release/ProjectReleases.aspx?ProjectName=Terminals.

Sunday, November 12, 2006

How to Get a List of Build Statuses

I have a TFS build installer utility that uses the BuildStore interface to get list of available fields to install. I wanted to filter the list with the build status field but did not find a function that returns the list so using Reflector I found out the the statuses are inside a class named BuildStatus. This class contains a list of public, static, string properties that each one of them represents a build status. The real string value of the build status property is stored in a resource named BuildTypeResource.

So in order to get the list of build statuses I wrote this method:

public static string[] GetBuildStatuses()
{
Type t = typeof(Microsoft.TeamFoundation.Build.Common.BuildConstants.BuildStatus);
ArrayList constants = new ArrayList();
PropertyInfo[] propertyInfos = t.GetProperties(BindingFlags.Public | BindingFlags.Static |
BindingFlags.FlattenHierarchy);
List<string> buildStatuses = new List<string>();
foreach (PropertyInfo propertyInfo in propertyInfos)
{
if (propertyInfo.PropertyType == typeof(string))
{
buildStatuses.Add(propertyInfo.GetValue(null, new object[] { }).ToString());
}
}
return buildStatuses.ToArray();
}

The method uses reflection in order to go through all the properties of the class and retrive their values. The result list will return:

"Build Initializing", "Getting Sources", "Sync Completed", "Compilation Started", "Compilation Completed", "Testing Started", "Testing Completed", "Successfully Completed", "Failed", "Stopped".

Thursday, November 09, 2006

www.clarizen.com

I'm working in a company that develops on demand project management application. You can take a look at our web site: www.clarizen.com and register to the beta which will be released at Q1 2007.

You can read some interesting stuff from our CEO regarding Clarizen, SaaS and project management here: http://www.clarizen.com/ceo.html.

Of course our development platform for this project is Microsoft Visual Studio Team System. I look forward to integrate both systems (Clarizen and Team System) to have a complete development process.

Tuesday, November 07, 2006

How to Get Build Types List

There's no method in TFS API that retrieves a list of build types for a project. I looked inside the BuildStore interface and found nothing. Later I saw somewhere that it is not exposed so I wrote my own implementation using source control API. I'm retrieving a list of folders under the TeamBuildTypes folder.

using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.VersionControl.Client;

public string[] GetBuildTypes(string serverName, string teamProject)
{
TeamFoundationServer tfs = new TeamFoundationServer(serverName, CredentialCache.DefaultCredentials);
tfs.EnsureAuthenticated();
VersionControlServer vcs = (VersionControlServer)tfs.GetService(typeof(VersionControlServer));
ItemSet itemSet = vcs.GetItems("$/" + teamProject + "/TeamBuildTypes", VersionSpec.Latest, RecursionType.OneLevel, DeletedState.NonDeleted, ItemType.Folder);
List<string> buildTypes = new List<string>();
foreach (Item item in itemSet.Items)
{
string buildType = Path.GetFileName(item.ServerItem);
if (buildType != "TeamBuildTypes")
{
buildTypes.Add(buildType);
}
}
return buildTypes.ToArray();
}

Deploymnet Items Not Copied During Build

We had a problem when we've integrated the tests into the build process.
In the TestRunConfig file (.testrunconfig) you can configure deployment items to be copied into the test run directory. The thing is that Visual Studio stores the path with ending backslash and because of annoying bug the deployment items are not copied during the TFS build. This does not happen while working inside Visual Studio environment.
The solution was to open the file in a text editor and remove the ending backslash from all the deployment items. We also removed write permissions from this file so nobody will recreate the problematic paths in the file.

Monday, November 06, 2006

Build's Relevant Associated Changesets using LabelQueryScope

We're working with 2 branches and performing builds on each one of them. Today we've noticed that in the "Associated changests" list we see changsets from both branches. A little investigation of the "Microsoft.TeamFoundation.Build.targets" file we found that you can override a property named "LabelQueryScope" to make the build process only changesets from a specific branch. So in this case if you have a project with 2 sub branches than you need to set the "LabelQueryScope" property with "@$/$(TeamProject)/Branch".
By changing this property you also change the labeled branch of the build.

Sunday, November 05, 2006

Terminals

I know I haven't written for a while. I'm still trying to get used to the idea of blogging.
I've created a new project in CodePlex named Terminals. If you use Remote Desktop Connection to connect to terminal servers/desktops then you would probably like this tool. It's a multi tab remote desktop connection IDE with lots of cool features written, of course, in C#. My partner to this project is Eyal Post one of the greatest toolsmiths mankind has known who has provided us VSSConverter GUI. BTW, CodePlex is a great place to find and join TFS related projects. The cool part is that you actually use TFS to store your projects source files and work items.

Wednesday, August 23, 2006

Cube Processing Runtime Error

I has some bad days with TFS.
After 2 weeks of work on the new server I found that the reports are not generated and you can see only old reports.
I regenerated the warehouse (setupwarehouse.exe) and running the adapters stopped working.
I read the: Warehouse Troubleshooting Guide but had no success. After going deeper I found that the problem was in the SQL Server Analysis trying to process the TfsWarehouse database. The errors I found in the event viewer and while manualy running it were:

Cube processing runtime error: \r\nMicrosoft.AnalysisServices.OperationException: The member '[8/22/2006]' was not found in the cube when the string, [Date].[Date].[Date].[8/22/2006], was parsed.
The END SCOPE statement does not match the opening SCOPE statement.
MdxScript(Team System) (66, 1) The END SCOPE statement does not match the opening SCOPE statement.


I read on another blog about a problem while moving from one server to another and installing SQL Server with a different collation (Scotty.Net). His post gave me a good direction but I got into some problems while trying to change the collation. Anyway, I found myself reinstalling the Team Foundation server and with no solution for the problem.

The big advance came when I searched for: "The END SCOPE statement does not match the opening SCOPE statement". I found an MSDN forum post with the same problem I had (http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=550484&SiteID=1). I understood that the problem was with a table named: dbo.Today under the TfsWarehouse database. It's a single row table which contains dates that are used while running the adapters. Anyway, I've checked the differences of the values with the old server database and found that the values are related to the regional settings of the machine. I've changed them manually and the process finshed successfuly. After a while the row was regenerated and the problem occured again.

The solution to this problem was to change the regional settings of the tfsservice user to the one in the previous installation. I logged in to the server with that user and changed it.

Wednesday, August 09, 2006

"The path xxx is already mapped in workspace xxx."

I was struggling with a problem I had when using TFS API I tried to map a file using:
public void Map(string serverPath, string localPath);
I was getting an exception telling me that the file was already mapped in another workspace:
"The path {File Path} is already mapped in workspace {Workspace Name}."
This workspace was deleted beofre.
With the help of friend of mine I found out that TFS save workspace info under the user local settings dir. We found a file named: VersionControl.config under {User Documents and Settings dir}\Local Settings\Application Data\Microsoft\Team Foundation\1.0\Cache.
This file contains all the local mapping of TFS. Probably when you use the Map method and don't use:
public void DeleteMapping(WorkingFolder mapping); before deleting the workspace the mapping information is not removed from this file which is used by TFS to check if you've alreay mapped a specific path.
To resolve this problem delete all the keys from the config file. Don't delete the file because you'll get it again from the server cache.

Sunday, July 30, 2006

Moving TFS To Another Server

This weekend I have moved the Team Foundation server to another server. I used How to: Move Your Team Foundation Server from One Hardware Configuration to Another document to do this.
One problem I had that the referenced document: How to: Restore Team Foundation Server Data to a Different Server is a little confusing since it is not taking into consideration the possibility that you are moving a single server deployment and you have already done some stuff. I found that some of the things I've done in the main document are repeating in this document.
At the bottom line if you follow the guide it works and smoothly.

Thursday, July 06, 2006

TFS API

Team Foundation API is wide open and straight forward you can do everything you do through the Team Explorer and command line using the API. I'll post some examples using this API using Visual Studio 2005 and C#.

Creating a Team Foundation server

You should add reference to: Microsoft.TeamFoundation.Client.dll

Team Foundation assemblies are located under: C:\Program Files\Microsoft Visual Studio 8\common\IDE\PrivateAssemblies.

On the using clause add:
using Microsoft.TeamFoundation.Client;

// Create the server object and connect to the server.
TeamFoundationServer teamServer = TeamFoundationServerFactory.GetServer(serverName);

// Check the connection
teamServer.EnsureAuthenticated();

Now you have a Team Foundation Server object to work with. Check out the TeamFoundationServer class using Reflector or ObjectExplorer to see other members of the class.

TFS Source Control Strategy

I'm considering which startegy to use with Team Foundation source control.
I'm thinking of:

  • One main branch for the next release. Most of the work is done on this branch.
  • One bug fixing branch for a released version. This branch lives until a new version is released.
  • Temporary branch for changes needed to be enter to the next version prior to the current version release.
  • Branches for feature development that cannot be implemented in one release


Should look like this:
$/{Project}

  • main (v2.0 development prior to a release)
  • v1.1 (v1 bug fixes)
  • v3.0 (temporary branch until v2 is released)
  • FeatureBranch (for big developemnt effort that cannot be implemented for the next release)


  • Developers work on the main branch most of the time
  • If they have a fix for a released version then they need to merge it to the next versions too
  • When a temporary branch is opened the main branch should be merged to it often
  • When a feature is decided to be released it should be merged from the feature branch to the main branch
  • The main branch should be merged to the feature branch one a week

TFS Installation Guide

The installation guide is great! I have never seen such documented step by step guide. If you follow the guide you will have a successful installation of the server.
The most current version of the guide is available from Microsoft:
http://go.microsoft.com/fwlink/?LinkId=40042
Since we have small number of users I have installed the single server version of Team Foundation Server. You can get help on deciding how to deploy Team Foundation Server here: http://msdn.microsoft.com/vstudio/teamsystem/team/quickstarts/tfs_plan/

TFS Implementation

I've started an implementation of Team Foundation Server in my organization. I will try to document the process and maybe post some good stuff for others that are trying to implement Team Foundation Server too.