Creating TFS Work items Based On SharePoint Build Outcome

While fixing builds for my current project, and I’m now finally about half way through em, one problem that bubbled up was that the previously employed build manager had attempted to put together some code to have a build based on compilation success/failure of his SharePoint projects to generate work items. Now, at first glance his code looked correct to me (I’ve stripped it down a stitch):

[xml]




[/xml]

Nothing about that at first glance looked wrong, but he was getting the error:

A Work Item could not be created for failures in build ‘build’. Please verify that the work item type ‘Task’ is supported in team project ‘proj’ and it has field ‘Microsoft.VSTS.Build.FoundIn’ defined.

Now this problem implies that there wasn’t some of the required foundation laid down before the aforementioned code was integrated. Basically, a work item type Task defined in your team project, then you need to create that first. So bascially hack up the work item type definition file with those definitions, and you are good to go!

Share

Easy Way To Add Role Assignments

I have to do this all the time. If you have a similar requirement, just use the following method:

[csharp]

public static void AddRoleAssignment(ISecurableObject securable, SPPrincipal principal, SPRoleDefinition[] roleDefinitions)
{
var roleDefinitionBindings = new SPRoleDefinitionBindingCollection();
foreach (SPRoleDefinition definition in roleDefinitions)
{
roleDefinitionBindings.Add(definition);
}
var roleAssignment = new SPRoleAssignment(principal);
roleAssignment.ImportRoleDefinitionBindings(roleDefinitionBindings);
securable.RoleAssignments.Add(roleAssignment);
}

[/csharp]

The usage of it is pretty straightforward, you have an ISecurableObject parameter to expose role assignments for an object, an SPPrincipal to represent a user or group, and a SPRoleDefinition array to act as a container for role definitions.

Share