Tuesday, November 20, 2012

TFS Build: Unable to create the workspace 'xxx' due to a mapping conflict

Right. You get this one, so you go to your build agent and delete a workspace manually.
If you are reading this post to find only how to delete a workspace, here it is get and go:

C:\Program Files (x86)\Microsoft Visual Studio 11.0>tf workspace /delete /collection:CollectionURL WorkspaceName /login:BuildServerAccount

If you want to know some more - keep reading :)

So, after a while problem comes again. And again. One day (I think it was 3rd time I got to delete workspace manually) I actually asked myself a question - why does this happen?

When a workspace is fetched\created by the agent during build, it uses a template for workspace name, which is defined in the build template used for your build defintition. Like this:


<Assign x:TypeArguments="x:String" DisplayName="Initialize Workspace Name" To="[WorkspaceName]"
Value="[String.Format(&quot;{0}_{1}_{2}&quot;, BuildDetail.BuildDefinition.Id, Microsoft.TeamFoundation.LinkingUtilities.DecodeUri(BuildAgent.Uri.AbsoluteUri).ToolSpecificId, BuildAgent.ServiceHost.Name)]" mtbwt:BuildTrackingParticipant.Importance="Low" />

And now imagine you have several build templates, and each has its own way for naming a workspace. Not a big deal, seems to be?... but wait. At some point a build definition decides to change to another build template. And everything is same for the build, but the workspace naming.
Build starts at the same agent. Since it is another naming template for the workspace, agent tries to create a new workspace - and oops, there is already mapping for this source control folder. Kabum! Mapping conflict.

How to fix it? Use same workspace naming template throughout all your build templates. 

PS: Many thanks to Jakob Ehn, who helped me to figure this out. 

Friday, November 16, 2012

HowTo: Run application as a user from another domain

Sometimes (pretty often actually) I need to run application as another user.
What I usually do in this case - SHIFT+right-click

and that works as charm.... unless the account I need to run under comes from another domain.
Then I get this:
 
In that case there is a neat solution from command line:

runas /user:domain\username /netonly "application.exe"

Made my life way more easy :)

Tuesday, November 13, 2012

TF30063: You are not authorized to access Microsoft-IIS/7.5

One beautiful day build definitions startet to give such error:




Also getting latest on the folder with custom activities dlls gave the same error.
What a nonsense thought I, cause I am admin afterall!

Right, the problem was not enough disk space on TFS application tier machine.
Cleaning up resolved the problem.