Tuesday, January 15, 2013

TFS: The download file is corrupt. Please get the file again.


We got  "The download file is corrupt. Please get the file again." on our build machine.
At the same time when a user tries to see history and chooses on some file to compare to Previous version - it shows completely different file.

Spooky, right? Do not panic!

First, locate problematic chageset, find it in Team Web Access and make sure comparison to previous version looks good there. If it does not - panic, this post will not help you.

If it DOES look allright in TWA - problem is caching. Most likely on server side, but neat to cleanup both.

1. Cleanup server cache (TFS 2012)
Go to your application tier machine and delete whatever is under:
C:\Program Files\Microsoft Team Foundation Server 11.0\Application Tier\Web Services\_tfs_data
if scared to delete - rename the folder. The folder with the same name will be created immidiately again by application tier anyway, then you can delete the old one. If files are in use - stop tfs server, perform deletion, start tfs server.

2. Cleanup client cache
Delete all under:
C:\Users\<yourusername>\Local Settings\Application Data\Microsoft\Team Foundation\x.0\Cache

Voila :)

Wednesday, January 9, 2013

TFS Build Error: Type XXX not visible. If the type is local...

Error message looks something like this:

Type 'System.Linq.OrderedEnumerable`2[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]' not visible. If the type is local, please set the LocalAssembly field in XamlReaderSettings.

The problem appears if you have some variable which is visible (NB! visible, not used!) in different scopes, and one of them is AgentScope. Then a scope where the variable is not used, but visible might not be able to resolve the type.

For example, I have sequence - Main. Under it I have AgentScope. I declare a variable MyList of type StringList and set visibility to Main. Right, everybody should be able to see MyList!...

I use MyList in Main -> so it's type (StringList) belongs to used types and the corresponding assembly is imported.
So we move to agent scope. I do not use MyList on agent scope, so StringList doesn't end up in the list of used types => corresponding assembly is not loaded on agent. But visibility says - AgentScope must know about MyList (since it is under Main), so AgentScope tries to see the variable - but no type StringList is known on agent -> kabum!

Solution is easy - set scope of variables limited to their usage. In my case I created sub-sequence, where I use MyList and limit scope to it.

Tuesday, January 8, 2013

TFS data schema conflicts

There is some information around on why it appears and theory behind. But here
 TFS Locate and resolve data schema conflicts
is a step-by-step guide how to solve the problem.

Sunday, January 6, 2013

Queue build from another build: template

Recently I needed to run one main build and then trigger several "child" builds if the main one succeeded. The most obvious was to make a PS script which is scheduled, but then I was curious to make it also from standard TFS build. So I did.

So, build definition takes the following parameters:



 As you can see - it doesn't ask for solution to build, agent and etc etc. That was the most tricky part. To achieve that you need to clean up and change some in template arguments like this:

The rest is more or less obvious - queue main build, wait for it to complete, check status, and queue child builds. From standard build definition only those activities in the beginning should be present:

No stuff like run on agent etc, since build is not doing any heavy work, I decided this is not needed.
Ping me back if you need some more help.