How to: Modify a project portal site template

We have received a few requests for how to modify the default team project settings recently. So I’m writing this post to share the steps of modifying a site template.

As we already know, when we create a new team project, the corresponding portal in SharePoint is also created. The portal is created with the SharePoint template referenced in the process template. After we download a process template, we can open the WssTasks.XML. Then we will find a <site> element which specifies the SharePoint site template and language id. Until now, the SharePoint site template can not be edited in the Process Editor from TFS power tool.

When TFS is installed, the SharePoint site templates for MSF for Agile and MSF for CMMI are uploaded to SharePoint. You can find these template in %ProgramFiles%\Microsoft Visual Studio 2008 Team Foundation Server\Tools\Templates. The below steps are for how to modify the portal site template. The MSFAgile.stp is for WSS 2.0 and MSFAgile30.stp is for WSS 3.0.

Configure an existing team portal and save the portal as an template.

  1. Open an existing team portal and modify settings such as time zone.
  2. In the portal, click Site Actions->Site Settings->Save site as template.
  3. Since the process template already contains the default document libraries, so we uncheck the Include Content checkbox.
  4. Click OK and MyTemplate is created in Site Template Gallery.
  5. Go to Site Actions->Site Settings->Site templates and download MyTemplate.stp to a local folder.

Sometimes, you need to modify the MyTemplate.stp manually. Skip these steps if you don’t need to do that.

  1. Install Microsoft Cabinet Software Development Kit. The portal template for a team project is just cab files. We can use the CABARC.EXE in the SDK to extract and recreate the template files.
  2. Login the TFS server and navigate to %ProgramFiles%\Microsoft Visual Studio 2008 Team Foundation Server\Tools\Templates.
  3. Find the template you want to modify. Make a back up of it and change the extension from .stp to .cab. Then you can open the .cab file with Windows Explorer. Copy all contents to a folder, say C:\TemplateExtract.

    TemplateExtract2

  4. Modify the settings in the manefist.xml based on your requirement and save.
  5. Recreate the .stp template file with CABARC.EXE. For example: CABARC N “C:\MyTemplate.stp C:\TemplateExtract\*.*”, then MyTemplate.stp should be created in C: drive.

    addTemplate2

Upload the portal site template to SharePoint.

  1. List the global template with stsadm -o enumtemplates. stsadm.exe is usually located in %ProgramFiles%\common files\microsoft shared\web server extensions\12\bin. Remember the tile of the site template you want to modify.

    enumtemplate

  2. If you want to add a new template, you can skip this step. If you want to update and existing site template, you need to first delete the old template with stsadm –o deletetemplate and then upload the template with the same title. For example: stsadm –o deletetemplate –title VSTS_MSFAgile.

    deleteTemplate

  3. Add the template with stsadm –o addtemplate command. For example: stsadm –o addtemplate –filename C:\MyTemplate.stp –title VSTS_MSFAgile. Since a process template references the site template by template title. If you are replacing an existing template, make sure the title is the same as displayed when run enumtemplates in the previous step.

    AddTemplate4

  4. Run iisreset to restart the IIS.

Finally, you can create a new team project to test the newly uploaded site template.

How to: Enable tracing of TFS add-ins for Excel and MS Project

TFS provides abilities to manage work items in Excel and MS Project. When you experience unexpected behaviors while managing work items in Excel or MS Project, one approach to diagnose this issue is to enable tracing. The trace log can give us more information and probably contains clues.

  1. Create a file EXCEL.exe.config to enable tracing of Excel (WINPROJ.exe.config for MS Project).
  2. Add the below content to the config file and save.
    <?xml version ="1.0"?>
    <configuration>
    <system.diagnostics>
    <trace autoflush="true" indentsize="4">
    <listeners>
    <add name="myListener" type="System.Diagnostics.TextWriterTraceListener"
    initializeData="c:\Logs\Excel.log" />
    </listeners>
    </trace>
    <switches>
    <add name="General" value="4" />
    </switches>
    </system.diagnostics>
    </configuration>



  3. Go to the folder where EXCEL.exe or WINPROJ.exe locate. For Office 2007, they are in %\ProgramFiles%\Microsoft Office\Office12.


  4. Copy the EXCEL.exe.config or WINPROJ.exe.config there.


  5. Restart Excel or MS Project. When you use functions in the TFS add-in, trace logs should be created.

How to: Upgrade TFS data tier to SQL Server 2008

Many customers asked about how to upgrade the TFS DT to SQL Server 2008. I’m writing this post  in the hope of that other TFS administrators can get a quick help. The following are steps to upgraded the TFS DT:

  1. Apply TFS 2008 SP1 if you haven’t applied it yet. TFS 2008 SP1 is a must in order to work with SQL Server 2008.
  2. Follow the document How to: Upgrade to SQL Server 2008 (Setup) to upgrade the database.
  3. Open the installation folder of TFS, find the configuration file Web Services\Warehouse\web.config.
  4. Modify the assembly binding redirection of Microsoft.AnalysisServices from <bindingRedirect oldVersion="9.0.242.0" newVersion="9.0.242.0"/> to <bindingRedirect oldVersion="9.0.242.0" newVersion="10.0.0.0"/>.
  5. Perform the step #4 for the Toos\SetupWarehouse.exe.config and Toos\TfsAdminUtil.exe.config.
  6. If some reports from the default MSF for Agile or MSF for CMMI template don’t work after the database upgrade, you might want to look at Issues with TFS 2008 built-in reports using SQL Server Reporting Services 2008

Test ID should be used when running MSTest.exe with /unique switch

The MSDN document MSTest.exe Command-Line Options describes the usage of MSTest. It has a /unique switch. If you follow the demo in the document to use /unique switch, you might get the error message “Test MethodTest1 is not unique. It maps to more than one test.”.

In Visual Studio, a test method has an ID. To get the test ID, you can

  1. Select a test in the Test View window.
  2. Press F4 to open the Property Window.
  3. Find the ID field in the Property Window.

For unit test, the test ID is made up of namespace.class.testmethod. For coded web test, the ID is made up of namespace.class. When MSTest.exe is run with /unique switch, test ID should be passed to /test switch. For example: MSTest  /testcontainer:TestProject1.dll /test:TestProject1.Class1Test.TestMethod1 /unique.

Can’t synchronize TFS warehouse after upgrading SQL Server to 2008

A few days ago, I upgraded the database of my TFS from SQL Server 2005 to 2008. Then the warehouse of TFS can’t be synchronized. Finally, I got time to troubleshoot this issue today.

Symptoms

I tried to invoke the web service http://TfsServer:8080/Warehouse/v1.0/warehousecontroller.asmx?op=Run to synchronize the warehouse, then an 6 error message were logged in the Windows Event Log immediately in TFS server. One of them looks like this:

Detailed Message: Cube processing runtime error: \r\nMicrosoft.TeamFoundation.Server.AnalysisServiceConnectionException: Error encountered when creating connection to Analysis Services. Contact your Team Foundation Server administrator. ---> Microsoft.AnalysisServices.ConnectionException: Cannot connect to Analysis Services version '10.0.1600.22'.
   at Microsoft.AnalysisServices.Server.Connect(String connectionString, String sessionId)
   at Microsoft.AnalysisServices.Server.Connect(String connectionString)
   at Microsoft.TeamFoundation.Warehouse.OlapCreator.GetServerEdition()
   --- End of inner exception stack trace ---
   at Microsoft.TeamFoundation.Warehouse.OlapCreator.GetServerEdition()
   at Microsoft.TeamFoundation.Warehouse.OlapCreator.CommonInit()
   at Microsoft.TeamFoundation.Warehouse.OlapCreator..ctor(String serverName, String databaseName, String relationalConnectionString)
   at Microsoft.TeamFoundation.Warehouse.AdapterScheduler.RunCubeProcess()

The other 5 error messages were similar to this one. I list their error message without call stacks here so that people can reach to this post so no matter which error message is used as the keyword to search, .

  1. Detailed Message: Failed to load adapter Microsoft.VisualStudio.TestTools.WarehouseAdapter.Adapter. Exception Info: \n Microsoft.TeamFoundation.Server.AnalysisServiceConnectionException: Error encountered when creating connection to Analysis Services. Contact your Team Foundation Server administrator. ---> Microsoft.AnalysisServices.ConnectionException: Cannot connect to Analysis Services version '10.0.1600.22'.
  2. Detailed Message: Failed to load adapter Microsoft.TeamFoundation.WorkItemTracking.Adapter.Adapter. Exception Info: \n Microsoft.TeamFoundation.Server.AnalysisServiceConnectionException: Error encountered when creating connection to Analysis Services. Contact your Team Foundation Server administrator. ---> Microsoft.AnalysisServices.ConnectionException: Cannot connect to Analysis Services version '10.0.1600.22'.
  3. Detailed Message: Failed to load adapter Microsoft.TeamFoundation.VersionControl.Adapter.VCAdapter. Exception Info: \n Microsoft.TeamFoundation.Server.AnalysisServiceConnectionException: Error encountered when creating connection to Analysis Services. Contact your Team Foundation Server administrator. ---> Microsoft.AnalysisServices.ConnectionException: Cannot connect to Analysis Services version '10.0.1600.22'.
  4. Detailed Message: Failed to load adapter Microsoft.TeamFoundation.Build.Adapter.TeamBuildAdapter. Exception Info: \n Microsoft.TeamFoundation.Server.AnalysisServiceConnectionException: Error encountered when creating connection to Analysis Services. Contact your Team Foundation Server administrator. ---> Microsoft.AnalysisServices.ConnectionException: Cannot connect to Analysis Services version '10.0.1600.22'.
  5. Detailed Message: Failed to load adapter Microsoft.TeamFoundation.Warehouse.CommonStructureAdapter. Exception Info: \n Microsoft.TeamFoundation.Server.AnalysisServiceConnectionException: Error encountered when creating connection to Analysis Services. Contact your Team Foundation Server administrator. ---> Microsoft.AnalysisServices.ConnectionException: Cannot connect to Analysis Services version '10.0.1600.22'.

Assessments

The error message indicates that TFS can’t connect to the Analysis Service after upgraded. I then lunched the SQL Server Management Studio 2008 and successfully connected to the Analysis Service. So the Analysis Service should work fine. Since the issue began occurring after upgraded SQL Server. TFS might still use OM from SQL Server 2005 to connect to SQL Server 2008.

To verify my guess, I restarted the IIS by running iisreset command and checked assembly binding information with fslogvw. In the tool, I found an item for binding assembly Microsoft.AnalysisServices for w3wp.exe, which is the IIS worker process of TFS web site. Here are the log:

LOG: Redirect found in application configuration file: 9.0.242.0 redirected to 9.0.242.0.
LOG: Post-policy reference: Microsoft.AnalysisServices, Version=9.0.242.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91
LOG: Found assembly by looking in the GAC.

LOG: Binding succeeds. Returns assembly from C:\Windows\assembly\GAC_MSIL\Microsoft.AnalysisServices\9.0.242.0__89845dcd8080cc91\Microsoft.AnalysisServices.dll.
LOG: Assembly is loaded in default load context.

Obviously, the OM from old SQL Server 2005 was used.

Solution

In the installation folder of TFS, I navigated to Web Services\Warehouse, There’s a web.config there. After TFS 2008 SP1 is applied, it adds an assembly binding redirection for Microsoft.AnalysisServices. At the time when I installed TFS 2008 SP1, the SQL Server was not upgraded yet. So the Microsoft.AnalysisServices was directed to the version 9.0.242.0, which is from SQL Server 2005.

On my another machine that SQL Server 2008 was already installed when applying the TFS 2008 SP1. This assembly was directed to 10.0.0.0. So the assembly redirection is supposed to be manually updated after upgrading the SQL Server.

In the web.config, I redirected this assembly to 10.0.0.0 and restarted IIS. The problem was resolved.

      <dependentAssembly>
<assemblyIdentity name="Microsoft.AnalysisServices"
publicKeyToken="89845dcd8080cc91"
culture="neutral" />
<bindingRedirect oldVersion="9.0.242.0" newVersion="10.0.0.0"/>
</dependentAssembly>


 



[EDIT] The SetupWarehouse command also utilizes the assembly Microsoft.AnalysisServices when rebuilding the TFS cube. So after upgrading to SQL Server 2008, you will also want to configure the SetupWarehouse.exe.config in the same manner.