Thursday, April 12, 2012

TFS Portal Error: This site doesn't have a default Team Foundation Server instance

Basically this error happens when SharePoint is NOT linked/connected with TFS. You can reconfigure this for the Team project where the portal is supposed to be connected.

Here are the steps.

First verify the TFS Collection has default SharePoint site.

Step 1: On Team Foundation Server Administration Console, Select the TFS Collection and “SharePoint Site” tab.

image

Step 2: Click “Edit Default Site Location” link and update the default site location.

image

Step 3: Access the SharePoint, if that did not fix the issue, reconfigure the portal setting for the team projects using Visual Studio

Reconfigure Team Portal Settings

Step 4: On the Visual Studio Team Explorer, right click on the Team Project and select “Portal Settings”

image

Step 5: Project Portal Settings page appears. Click on “Enable Team Project Portal” and Click on “Configure Url” button.

image

Step 6: On “Specify an existing SharePoint Site” window (as mentioned in image above), specify the SharePoint URL. Confirm the url by clicking on the URL link. Now the SharePoint would show the data from reports and other details

Step 7: Press OK to save the changes.

Start/Stop Visual Studio Team Build Service using API

Here is full code snippet to start/stop Visual Studio Team Build Service.

private const string TFSBuildService = "TFSBuildServiceHost";
private ServiceController TFSController;

public TeamBuildServiceController()
{
// Check if the Visual Studio Team Build service exists on the machine. If not then raise an error.
bool srvcExists = false;
foreach (ServiceController srvcOnMachine in ServiceController.GetServices())
{

if (string.Compare(srvcOnMachine.ServiceName, TFSBuildService, StringComparison.OrdinalIgnoreCase) == 0)
{
srvcExists = true;
break;
}
}


this.TFSController = new ServiceController {ServiceName = TFSBuildService};
}

public void StopService()
{
if(this.TFSController == null)
{
return;
}

// Stop the service if its running
if (this.TFSController.CanStop)
{
this.TFSController.Stop();
int timecounter = 0;

while (this.TFSController.Status != ServiceControllerStatus.Stopped)
{
if (timecounter > 60)
{
break;
}

timecounter++;
Thread.Sleep(1000);
this.TFSController.Refresh();
}
}

if(this.TFSController.Status != ServiceControllerStatus.Stopped)
{
Thread thread = new Thread(ShowMessageToRestart);
thread.SetApartmentState(ApartmentState.STA);
thread.Start(
"The Visual Studio Team Foundation Build service cannot be stopped. Changes to the environment variable will not reflect on the builds till the service has been restarted. \r\n\r\nPlease restart the service after the installation completes.");
thread.Join();
}
}

public void StartService()
{
if (this.TFSController == null)
{
return;
}

// Start TFS build service
this.TFSController.Start();
int timecounter = 0;

while (this.TFSController.Status != ServiceControllerStatus.Running)
{
if (timecounter > 60)
{
break;
}

timecounter++;
Thread.Sleep(1000);
this.TFSController.Refresh();
}

if (this.TFSController.Status != ServiceControllerStatus.Running)
{
Thread thread = new Thread(ShowMessageToRestart);
thread.SetApartmentState(ApartmentState.STA);
thread.Start(
"The Visual Studio Team Foundation Build service cannot be started. Team build will not be executed on this machine until the service is not started. Please try to start the service manually.");
thread.Join();
}
}




Wednesday, April 11, 2012

Creating TFS Alerts using Eclipse TEE

TFS Alerts are very useful to know about the work item updates,CI build statuses and check-in. There are some basic alerts available in TFS out of box and custom alerts in Power Tools. The alerts can be created using TFS Web Access and/or Visual Studio, but there were none using Eclipse.

Finally the Power Tools (Alert Editor) is available for Eclipse. Here are the steps to create alerts using Eclipse/TEE

Prerequisites

1. Eclipse 3.2-3.7

2. Microsoft Visual Studio Team Explorer Everywhere 2010 (TEE) with SP1

http://www.microsoft.com/download/en/details.aspx?id=25125

Step 1: Download and Install

The Team Foundation Server 2010 Powers Tools for Eclipse is available here. The setup instructions are available on the same page.

http://www.microsoft.com/download/en/details.aspx?id=28557

Step 2: Open Alerts Explorer on Eclipse

image

Step 3: The Alert Explorer would show all the alerts created by you. To create new alerts click on “New Alert”

image

image

Pick an alert template, example choose “Failed Builds” to send alert when a build fails.

Step 3: Update the Send to email address or pick the emailids by using the “Select Users” button.

image

Step 5: You can change the name of the Alerts, and add filters by adding fields and values.

image

Step 6:  You can save the alerts by clicking the save button. Now you have successfully setup a custom alert.

image

Tuesday, April 10, 2012

Business Intelligence Development Studio Downloads

To develop reports we need BIDS (Business Intelligence Development Studio). It is free and available as part of SQL Server Express editions. The BIDS is available for SQL Server 2005 and SQL Server 2008.

Here is more detail about BIDS

http://msdn.microsoft.com/en-us/library/ms173767.aspx#Accessibility

Microsoft SQL Server 2005 Express Edition Toolkit

http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=19413

Microsoft® SQL Server® 2008 Express with Tools

http://www.microsoft.com/en-us/download/details.aspx?id=1842

TFS Portal Error: This site doesn't have a default Team Foundation Server instance

Basically this error happens when SharePoint is NOT linked/connected with TFS. You can reconfigure this for the Team project where the portal is supposed to be connected.

Here are the steps.

First verify the TFS Collection has default SharePoint site.

Step 1: On Team Foundation Server Administration Console, Select the TFS Collection and “SharePoint Site” tab.

image

Step 2: Click “Edit Default Site Location” link and update the default site location.

image

Step 3: Access the SharePoint, if that did not fix the issue, reconfigure the portal setting for the team projects using Visual Studio

Reconfigure Team Portal Settings

Step 4: On the Visual Studio Team Explorer, right click on the Team Project and select “Portal Settings”

image

Step 5: Project Portal Settings page appears. Click on “Enable Team Project Portal” and Click on “Configure Url” button.

image

Step 6: On “Specify an existing SharePoint Site” window (as mentioned in image above), specify the SharePoint URL. Confirm the url by clicking on the URL link. Now the SharePoint would show the data from reports and other details

Step 7: Press OK to save the changes.

Monday, March 5, 2012

Enabling logging on MSTest.exe

Many times you might need to enable verbose logging on MSTest.exe to debug the Test related issue on the build machine.

Here are the steps

Step 1: Find the MSTest.exe.config file on the build machine. It can be found at the following location
<Drive:>\Program Files\Microsoft Visual Studio 10.0\Common7\IDE

Step 2: Make a backup copy of MSTest.exe.config file

Step 3: Add the following <system.diagnostics> in the MSTest.exe.config file
<system.diagnostics>
    <trace autoflush="true" indentsize="4">
      <listeners>
        <add name="EqtListener" type="System.Diagnostics.TextWriterTraceListener" initializeData="C:\Temp\MSTestTrace.log" />
      </listeners>
    </trace>
    <switches>
      <add name="EqtTraceLevel" value="Verbose" />
    </switches>
  </system.diagnostics>

Step 4: Here is the sample updated file.

<?xml version ="1.0"?>
<configuration>
  <startup useLegacyV2RuntimeActivationPolicy="true">
    <supportedRuntime version="v4.0"/>
  </startup>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <probing privatePath="PrivateAssemblies;PublicAssemblies;PrivateAssemblies\DataCollectors;PrivateAssemblies\DataCollectors\x86"/>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.VisualStudio.QualityTools.UnitTestFramework" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
        <bindingRedirect oldVersion="10.1.0.0" newVersion="10.0.0.0"/>
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.VisualStudio.QualityTools.Tips.UnitTest.Adapter" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
        <bindingRedirect oldVersion="10.1.0.0" newVersion="10.0.0.0"/>
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
        <bindingRedirect oldVersion="10.1.0.0" newVersion="10.0.0.0"/>
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.VisualStudio.QualityTools.Tips.UnitTest.Tip" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
        <bindingRedirect oldVersion="10.1.0.0" newVersion="10.0.0.0"/>
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
<system.diagnostics>
    <trace autoflush="true" indentsize="4">
      <listeners>
        <add name="EqtListener" type="System.Diagnostics.TextWriterTraceListener" initializeData="C:\Temp\MSTestTrace.log" />
      </listeners>
    </trace>
    <switches>
      <add name="EqtTraceLevel" value="Verbose" />
    </switches>
  </system.diagnostics>
  <appSettings>
    <add key="GetCollectorDataTimeout" value="300"/>
    <add key="TestProjectRetargetTo35Allowed" value="true" />
  </appSettings>
</configuration>

Step 5: Restart the “Visual Studio Team Foundation Build Service Host” service on build machine. The next build would log the detail.

Friday, March 2, 2012

Disable All Build Definitions, Build Controllers and Build Agents using SQL

We had a situation where we need to disable all the build definitions, build controllers and build agents without bringing TFS up and running. This was on QA instance, we backed up and restored the database on QA from Prod, so when we brought QA TFS up, TFS QA started running all the scheduled builds on Prod build controllers, which caused the problem.

Here are the SQL commands I ran on TFS QA database, which disabled all the 600+ build definitions and 100+ controllers

Use TFS_<Collection Name>

--Disable Build Agents

Update dbo.tbl_BuildAgent Set [Enabled]= 0 Where [Enabled]=1

--Disable Controllers

Update dbo.tbl_BuildController Set [Enabled]= 0 Where [Enabled] =1

--Disable Build definitions

Update dbo.tbl_BuildDefinition Set [Enabled]= 0 Where [Enabled] =1