Team Build 2010 Customized Output Directories & SharePoint 2010 WSPs


 

Before we get started, if you need help configuring your Team Build 2010 Server to support SharePoint 2010 please refer to the following documentation on MSDN.  If you already have a developer workstation with SharePoint 2010 and Visual Studio 2010 this script will collect all the required files for you to install on your build server. 

You can of course simply install SharePoint 2010 and then Visual Studio 2010 together on your build server and be done with it Smile.  I have also applied SP1 to Windows Server 2008 R2, Visual Studio 2010, TFS 2010 and SharePoint 2010 in this environment.

Now onto organizing your drop folder.  There are a few solutions out on the web with the promise of customized outputs….

The method I chose to use for this particular blog post was this one by fellow MVP Ed Blankenship.

I made a copy of the DefaultTemplate.xaml and customized the build process template as per Ed’s blog post.

Customizable Output Directories for TFS 2010 Build

I have configured my Build Definition as follows (My solution file has the following project types: MVC 3, Web Deployment, Windows Service, SharePoint 2010 Visual Web Part and Web Site Project). 

You must ensure you have the correct build process template selected, set the CustomizableOutputDirectory parameter to TRUE and in the MSBuildArguments field, add the following: /p:IsPackaging=True

Build Definition

The SharePoint Project (.csproj) must opt-in to use this new functionality by using the same method as you did for a Web Application.  Unload the project file and edit the .csproj to include the lines shown below and then save it and check-in your changes.

<!-- Customizable Output Directory Opt-In for TFS Build (web application projects) --><PropertyGroup Condition="$(TeamBuildOutDir) != '' ">  <OutDir>$(TeamBuildOutDir)</OutDir></PropertyGroup>

If you’ve followed all the steps so far you should be receiving the following error when the build definition is triggered:

C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\SharePointTools\Microsoft.VisualStudio.SharePoint.targets (389): Unable to get the assembly for SharePoint Project Item

On the build server you have to update the Microsoft.VisualStudio.SharePoint.targets file (make a backup copy first).  This file is located in the following folder “C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\SharePointTools\”.

Go to line number 366 “<CreateSharePointProjectService Configuration=…” shown in the screenshot below

Microsoft.VisualStudio.SharePoint.targets

Change the attribute OutDir=”$(TeamBuildOutDir)” to OutDir=”$(TargetDir)” and save the file.  Trigger a new build of your solution and the result should be as follows:

Build succeeded

You should be able to locate the WSP in the drop folder as shown in the screen capture below:

Team Build 2010 Drop Folder SharePoint 2010 .wsp

Hopefully this helps someone else trying to better organize their drop folder.  Let me know how it goes!

About wesmacdonald

Wes MacDonald is a Visual Studio ALM MVP, MCT, MCTS, MCITP (SharePoint) and a Principal Consultant for LIKE 10 INC., a SharePoint Server, Visual Studio and Team Foundation Server Consulting Firm providing premium support and guidance services.

7 Responses to “Team Build 2010 Customized Output Directories & SharePoint 2010 WSPs”

  1. Hey Wes, get tutorial. I found another and followed it, but yours give a better description of what to do. Anyhow, I’ve made the changes as you’ve described, but I’m getting another error:
    C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\SharePointTools\Microsoft.VisualStudio.SharePoint.targets (411): Method not found: ‘Boolean Microsoft.VisualStudio.SharePoint.PathUtils.HasIllegalDeploymentPathCharacters(System.String)’.

    I’m not quite sure what that means. I have multiple projects in my solution and I’ve added the opt-in for them to build separately in their own folders. Do I need to remove this opt-in for all projects in the Sharepoint solution or does it matter?

    I’d appreciate any kind of input that you may be able to provide. Thanks!

    • I would turn up the logging on the build to see if you can get more information on this error and then review the log. In your build environment I would verify the required files are actually present or it could also be due to a space in the path name…

      • I do have spaces in my path names. However, I’m not quite sure where I’d go about fixing that. I just cranked up the build logging verbosity and dropped some tags in the targets file to see if I can get any more info. I’ll let you know what I find in about 5-8min :).

      • Verbose logging didn’t help. I don’t know if diagnostic mode will help.

        The target it is failing on is PackageFiles. There are two properties: LayoutPath and PackagePath.

        LayoutPath=pkg\Debug\abc.xyz.Core
        PackagePath=C:\Builds\1\TeamProjectName\Build Definition Name\Binaries\abc.xyz.Core.wsp

        The outputDirectory that is passed to MSBuild is: C:\Builds\1\TeamProjectName\Build Definition Name\Binaries\

        I’m really at my wits end on this one!

      • There were two projects that should output a wsp file in the solution. I made one of them not build by removing it from the build configuration. The other project gives the same error. So much for it being something with that project. Oh, well. So much for CI and packaging!

      • I am sending you an email shortly with some screenshots. I reviewed the configuration of my SharePoint 2010 Build Server that I used for the post. It appears you do not have the correct assembly. The assembly Microsoft.VisualStudio.SharePoint.Tasks.dll on my system is dated 2/19/2011 and has the particular method you claim to be missing.

Trackbacks/Pingbacks

  1. August 8, 2011 – Learn TFS Daily | Learn TFS - August 10, 2011

    [...] Team Build 2010 Customized Output Directories & SharePoint 2010 WSPs from Wes MacDonald If you are doing SharePoint development, you can utilize Team Build 2010 to build and deploy your SharePoint components. Here, Wes shows you how to organize your drop folder when building SharePoint projects. [...]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 1,115 other followers

%d bloggers like this: