I faced an issue with the automated builds recently. I created automated builds in tfs 2008 and they worked good. When the project sources are migrated to tfs 2010, all my builds are not work properly in tfs 2010. Eventhough they succeeded, they did not pick the latest sources rather, an old source is found to be copied to the deployment server. After analysis I found that, in tfs 2010, there is an additional folder created in the path and it is the ‘Agent Id’. So I have updated the source path with the agent id as shown below,
this fixed the issue.
I got this error message when I tried to check in my changes into the tfs. I am not violating the check in policy as, I have associated my check in files with a task. This issue happened for me in VS 2010.
So, to fix this issue, you need to install the TFS 2010 power tools. Please download and install the TFS 2010 power tools from the following location http://visualstudiogallery.msdn.microsoft.com/en-us/c255a1e4-04ba-4f68-8f4e-cd473d6b971f After installing the software, restart the Visual Studio. Now, the check in will work.
Developers add unit tests for every method they write and it ensures quality of the application. To know the lines of code they have covered via unit tests, the code coverage should be enabled. Code coverage tells the developers, the various scenarios (using unit tests) they have covered for testing the methods. To enable code coverage follow the steps below,
a. I assume that, your application has a unit test project and a test list with unit test methods added to it. So, as a first step, in visual studio 2010 ultimate, goto Tests->Edit Test Settings ->Local (local.testsettings) as shown in the image below,
b. Now, the Test Settings dialog will appear. Select ‘Data and Diagnostics’ tab. Select ‘Code Coverage’. Click on the ‘Configure’ link as shown in the image below,
Now, you will get a dialog window where you can select the assemblies, projects that come under your unit test.
c. Run the unit tests now.Once the test results are displayed, to view the code coverage results, Goto Tests->Windows->Code Coverage Results.
d. The code coverage results will be displayed as shown below,
Normally, code coverage of 85% is considered to be good.
The following code snippet explains the way to connect to tfs programmatically and get the build status of team projects.
This will be helpful when you create a custom application to display the build status of certain team projects in tfs.
private IQueuedBuildsView myTfsQueuedBuilds= null;
private IQueuedBuildsView myTfsBuildQueue;
/// Create initial connection to the TFS 2008 Build Server.
public void Connect()
TeamFoundationServer tfs = new TeamFoundationServer(TfsUrl);
IBuildServer buildServer = (IBuildServer)
ArrayList queuedBuildsList = new ArrayList();
//teamProject is the string array of team project name in tfs
foreach (string project in teamProject)
myTfsBuildQueue = buildServer.CreateQueuedBuildsView (project);
myTfsBuildQueue.StatusChanged += new
//1000 ms and ‘myForm’ is the instance of the page
myTfsQueuedBuilds= new IQueuedBuildsView[queuedBuildsList.Count];
for(int i=0; i<queuedBuildsList.Count; i++)
queuedBuilds[i] = (IQueuedBuildsView)queuedBuildsList[i];
private void buildQueue_StatusChanged(object sender, StatusChangedEventArgs e)
foreach(IQueuedBuildsView qbv in queuedBuilds)
if (e.Changed && qbv.QueuedBuilds.Length > 0)
foreach (IQueuedBuild qb in qbv.QueuedBuilds)
//update status in UI
I used to get latest sources from tfs several times a day. Also, I depend on multiple projects in tfs. So, I created a simple .bat file to get the latest sources from multiple projects in tfs by a single click. Here is the code,
ECHO STARTING. PLEASE WAIT….
CD C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC
CALL vcvarsall.bat x86
tf.exe GET ITEMSPEC /FORCE /ALL /OVERWRITE /RECURSIVE $/ProjectA
tf.exe GET ITEMSPEC /FORCE /ALL /OVERWRITE /RECURSIVE $/ProjectB
tf.exe GET ITEMSPEC /FORCE /ALL /OVERWRITE /RECURSIVE $/ProjectC/Binaries
tf.exe GET ITEMSPEC /FORCE /ALL /OVERWRITE /RECURSIVE $/ProjectD
ECHO YOUR CHECKED OUT FILES
ECHO NOT OVERWRITTEN
Copy the above lines of code, create a file with .bat extension and paste in it. Simple things makes your life easier.
When you create a new build definition in tfs, you will get a .proj file created. You need to make few changes to deploy your application to the destination server automatically. Here is a sample .proj file, which deploy and make changes in the web.config automatically,
<?xml version=”1.0″ encoding=”utf-8″?>
<!– DO NOT EDIT the project element – the ToolsVersion specified here does not prevent the solutions
and projects in the SolutionToBuild item group from targeting other versions of the .NET framework.
<Project DefaultTargets=”DesktopBuild” xmlns=”http://schemas.microsoft.com/developer/msbuild/2003” ToolsVersion=”3.5″>
<!– Do not edit this –>
<Import Project=”$(MSBuildExtensionsPath)\Microsoft\VisualStudio\TeamBuild\Microsoft.TeamFoundation.Build.targets” />
<!– Team Foundation Build Version – DO NOT CHANGE –>
This property is included only for backwards compatibility. The description of a build definition
is now stored in the database. For compatibility with V1 clients, keep this property in sync with
the value in the database.
<!– BUILD MACHINE
This property is included only for backwards compatibility. The default machine used for a build
definition is now stored in the database, as the MachineName property of the definition’s
DefaultBuildAgent. For compatibility with V1 clients, keep this property in sync with the value
in the database.
<!– ADDITIONAL REFERENCE PATH
The list of additional reference paths to use while resolving references. For example:
<AdditionalReferencePath Include=”C:\MyFolder\” />
<AdditionalReferencePath Include=”C:\MyFolder2\” />
<Message Text=”Updating Web.config” />
<Message Text=”Copying source files to live” />
<Copy SourceFiles=”@(MyProjectApplicationFiles)” OverwriteReadOnlyFiles=”true” DestinationFolder =”$(MyProjInstallDirectory)\%(RecursiveDir)” />