TFS Build: Errors and tips

Last updated: 2016-10-07

Building using TFS Build server

Errors

There are no files in the output dropfolder

When you run “Queue New Build …” in TFS and get the logging output:

(_CheckForInvalidConfigurationAndPlatform target) -> 
 C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Microsoft.Common.targets(610,5):
 warning : The OutputPath property is not set for project 'MyProject.NET.vbproj'.
 Please check to make sure that you have specified a valid combination of Configuration and Platform for this project.
 Configuration='Release' Platform='Anu CPU'.
 You may be seeing this message because you are trying to build a project without a solution file, and have specified a non-default Configuration or Platform that doesn't exist for this project.
 [d:\Builds\53\MyTfsRoot\MyBuildDef\src\MyProjectPath\MyProject\MyProject.vbproj]

… then you should try to edit your build definition:

  • Goto section Process – Build Process Parameters – 1. Required – Items to Build – Configurations to Build
  • In my case, where I have chosen Release configuration it says “Any CPU|Release”.
  • Press the elipses (…) in the right column.
  • Put the cursor in the Platform column
  • Edit Any CPU to AnyCPU
  • Save your Build definition

Now you might get output in the drop folder.

Tips

Config Transform does not work … but it works, when you preview transform

In solution explorer expand project – Properties – PublishProfiles

Rename your pubxml files, so they have the exact same name as your solution configurations

Config Transform does not work … but it works, when you build in your solution

In your build definition:

Goto section Process – Build Process Parameters – 3. Advanced – MSBuild Arguments: /p:TransformConfigFiles=true

All files in the output ends up in the same folder

When you run “Queue New Build …” in TFS and all files ends up in the same folder, then it could be due to you are building your solution (.sln).

Instead you can build each project (*proj) – then TFS will create a folder for each.

In your build definition:

  • Goto section Process – Build Process Parameters – 1. Required – Items to Build – Projects to Build
  • Change $/MyTfsPath/MySolution.sln
  • to several rows with each a project like: $/MyTfsPath/Project1.csproj
  • Save your Build definition

Now each project might end in its own folder in the drop folder.

Building using command line

Tips

A sample build script

mybuildscript.cmd

REM Path to tf.exe
set path=D:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\VS SCC;%path%
set path=D:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE;%path%

REM Set working folder by setting Current directory
d:
cd \buildfolder

REM Get specific (with a date in future) to Current Dir (from workspace mapped to current dir) 
tf get "$/MyApp/Main" /recursive /force /noprompt /version:D01/01/2099

REM Build sln
call "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\msbuild.exe" "D:\buildfolder\myapp.sln" /t:Rebuild /p:Configuration=Release /l:FileLogger,Microsoft.Build.Engine;logfile=Manual_MSBuild_ReleaseVersion_LOG.log

REM Optionally (Re)build webs, if they failed - with errorstack
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_compiler.exe -v /localhost -errorstack -p MyWebFolder\ -u -f PrecompiledWeb\localhost\

Using public local workspace on buildserver

TFS don’t like several users to use same drive location of code on the same server, which probably is what you want on a server.
To overcome that you can use the same workspace for all users on that server.
For several users to use the same workspace you should use a public and local workspace.

If you have Visual Studio on the server you can map a local drive to a tfs path (e.g. $/MyApp) and then edit the workspace, which should have the name of the server. Press the advanced-button (when in edit-mode) – then you get the option to change the workspace to public and the location from server to local.
If you don’t have Visual Studio on the server you can use the comment tf workspace (not covered here) for the same task.

When you have the public local workspace you can use this script to be able to let a system account use that workspace (when that account have read access to the tfs path).

getlatestonserver.cmd – reusing a public workspace for all users on that server

set path=D:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\VS SCC;%path%
set path=D:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE;%path%

REM Set working folder by setting Current directory
d:
cd \buildfolder 

REM Using mapping in public Workspace (servername) shared by SomeUser:
REM print workspaces - and refresh local workspace cache
tf workspaces /collection:http://yourtfsserver/tfs/sometfscollection /format:detailed

Get files from workspace mapped to current directory

REM print latest changeset
tf changeset /latest /noprompt

REM Use public workspace to get specific (with a date in future) to Current Dir (from workspace mapped to current dir)
tf get "$/MyApp/Main" /recursive /force /noprompt /version:D01/01/2099

The End

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

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

%d bloggers like this: