How to set the “default” configuration for a project.

Being a Process Consultant specializing in TFS I teach many companies how to use Team Build.  When you create a new build definition you have the option to set “Configurations to Build”. However, if you leave that value blank the build will build the “default” configuration. The questions I am inevitability ask are “what is the default configuration” and “how do we set the default configuration”?  Well in this post I will show you where it is stored and how to update it for typical Visual Studio 2012 project. Visual Studio projects are msbuild scripts and because of that we can set properties in the actual project files that are going to be sent to msbuild to be compiled.  To change the default configuration you we need to load the project file as xml which is the file format of msbuild.  With the project open in Visual Studio simply right click on the desired project and select “Unload Project” from the context menu.  Once the project is unloaded right click on it again and select “Edit [Project Name]” and Visual Studio will open the file as an xml file we can edit.  Search the file for a “Configuration” element in a property group (it is normally the first group).  It should look similar to this: <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>   This is the line responsible for setting the default configuration of your build.  Simply change “Debug” to the desired default configuration, save the file then right click on project file in Solution Explorer and select “Reload Project”.  After you check in your changes an queue a new build it will be built using this configuration if the “Configurations to Build” is blank in the build definition.

I get an error trying to run reports on TFS2012 install

Problem: I get the following error when I attempt to view reports: An error has occurred during report processing. (rsProcessingAborted)Cannot impersonate user for data source 'TfsReportDS'. (rsErrorImpersonatingUser)Log on failed. Ensure the user name and password are correct. (rsLogonFailed)For more information about this error navigate to the report server on the local server machine, or enable remote errors  Solution: Verify that the password for the account reporting services is using has not expired. Explanation: In your browser, navigate to http://localhost/reports (from your reporting server machine).Click on Tfs2010ReportDS on the home page. Under the 'Credentials stored securely in the report server' click the Test Connection button. You should see the following message "Log on failed. Ensure the user name and password are correct."Simply reenter the username and password information and test the connection again.

I have to create the same branches in every new team project

Problem: I have to create the same branching structure in several team projects.  I would like a way to automate this process. Solution: Use the tf.exe and tfpt.exe command line tools in a batch file. Explanation: Using the tf.exe and tfpt.exe command line tools you can preform the same task from the command line that you can preform in the IDE.  Using tf.exe and tfpt.exe we can script the creation of the desired branching structure to speed up the process. You can download the Microsoft Visual Studio Team Foundation Server 2012 Update 1 Power Tools from here. The script below creates the Basic Branch Plan from the Visual Studio Team Foundation Server Branching and Merging Guide which you can download from here. The script must by run from a Developer Command Prompt so that tf.exe and tfpt.exe can be found.  Your other option is to update the environment variables for you machine to include the location of tf.exe and tfpt.exe in your path. @ECHO OFF REM If they did not provide arguments show them how to REM use this batch file if "%1" == "" GOTO Usage if "%2" == "" GOTO Usage REM Create a temp workspace to create the branches in. REM This will be deleted at the end tf workspace /new /noprompt temp /collection:%1 REM Before you can create branches you must do a get latest tf get $/%2 REM Create a main folder that will become the main branch of code md %2\Main REM Add this folder to TFS tf add %2\Main /noprompt REM Check in the main folder tf checkin /comment:"Adding main branch" /recursive /noprompt REM Now start creating the other branches REM main to dev tf branch $/%2/Main $/%2/Dev /noget /checkin REM main to release tf branch $/%2/Main $/%2/Release /noget /checkin REM We have to use tfpt from the power tools to convert REM the folder to a branch so we get the new branch icons REM in source control explorer tfpt branches /convertToBranch /collection:%1 /recursive $/%2/Main Echo Deleting temp workspace Echo. tf workspace /delete /noprompt temp REM Remove the directories we created rd %2 /s /q REM Skip usage and just end GOTO End REM Show how to use the script :Usage Echo This batch file will create the default Main, Dev and Release branches Echo for a team project. Echo Requires: Echo Microsoft Visual Studio Team Foundation Server 2012 Update 1 Power Tools Echo. Echo Usage: Echo createBraches collection teamProjectName Echo. Echo collection = http://tfs:8080/tfs/myCollection Echo teamProjectName = the team project name in that collection Echo. Echo createBranches http://tfs:8080/tfs/sandboxcollection teamProjectName :End createBranches.cmd (1.67 kb)

All my workspaces are missing!

Normal 0 false false false EN-US X-NONE X-NONE /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin-top:0in; mso-para-margin-right:0in; mso-para-margin-bottom:10.0pt; mso-para-margin-left:0in; line-height:115%; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi;} Problem: After a TFS server move all my workspaces are missing. Solution: Use the TF.exe Workspace command with the /newowner option. Explanation: During a recent TFS upgrade and migration from TFS 2010 running in workgroup mode to TFS 2012 on a new server I lost all my workspaces.  From the new TFS server I could run the TF.exe workspaces command and see all the existing workspaces.  However, if I were to open Visual Studio on any of the client machines none of those workspaces would show up. When TFS is in workgroup mode user accounts are all local accounts.  On the TFS server there was for example a Donovan L Brown account.  The name would be in the format of ComputerName\UserName.  After I moved to new hardware the computer name was different.  However, all the workspaces were owned by the accounts with the old computer name.  You can confirm that by running the TF.exe workspaces command and looking at the owner column. My goal is to simply update the owner of the workspace to point at the new local Donovan L Brown account on the new computer.  tf workspace [/collection:TeamProjectCollectionUrl] [workspacename[;workspaceowner]] [/newowner:ownername] If you have pending changes in the workspaces you will have to shelve them first.  This can be a bit of a challenge as well because you are not the owner of the workspace yet.  To work around this just use the TF.exe workspace command to change the workspace to public.  After which you can shelve the changes using your new account.  Once the changes are shelved you can change the workspace owner to the new account. Finally you can unshelve your changes and return to work.

Build workspace folder already mapped.

Problem: My Team Build keeps failing with an error that my source folder is already mapped in another workspace. The path C:\Builds\1\Demo\Reports\Sources is already mapped in workspace 7_1_WIN-GS9GMUJITS8. Solution: Use the tf.exe tool to delete the workspace holding on to that location. Explanation: tf workspace /delete [/collection:TeamProjectCollectionUrl] workspacename[;workspaceowner] [/login:username,[password]]

Why is my MS Project run so slow when connected to TFS.

Problem: With MS Project connected to TFS Project takes forever to refresh. Solution: One possible solution is to change the calculation mode from automatic to manual.  To change the calculation mode select Tools / Options / Calculation / Calculation Mode and change from automatic to manual.

I need to show TFS history of a file on the command line so I can redirect to a text file.

Problem: When I run the tf history command from the command line it shows a dialog box. Solution: Add the /noprompt option to the TF History command. This will cause the output to be shown in the command window. You can then use DOS redirection to easily store the results in a text file. For example: tf history $/MyProject/Main/Source /recursive /noprompt /format:detailed /collection:http://MyTFS:8080/tfs/defaultcollection > history.txt This will result in a new file called history.txt to be created in the working folder. Explanation: The key to not showing the dialog box is the /noprompt.  If you leave off the /noprompt you will be shown a dialog box. The output redirection operator > is used to send the command output to somewhere other than the screen for example a text file. > somefile.txt (If the file already exists it will be overwritten.)>> somefile.txt (This will append a file. If the file does not already exist it will be created.)