1
votes

I've written a TFS 2013 Build Definition using TfvcTemplate.12.xaml, set it to trigger on each check-in and to not clean the workspace. When the build runs it modifies certain source files under source control when the build runs. If I then check-in changes for a file that was modified on the build machine during the previous check in, I get the following error:

Unable to perform the get operation because the file already exists locally
Exception Message: One or more errors occurred while performing a Get operation. (type GetException)
Exception Stack Trace:    at Microsoft.TeamFoundation.Build.Workflow.Activities.SyncWorkspaceInternal.ThrowIfErrorsOccurred.Execute(CodeActivityContext context)
   at System.Activities.CodeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager)
   at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)

Is it possible to get TFS to do a Get with Overwrite when running the "Get sources from Team Foundation Version Control" step? I want my Build Definition to overwrite modified files on the build agent that do not match source control and do not want to set my build definition to clean the workspace.

In a previous version of TFS I could do it by adding the following to TFSBuild.proj:

<IncrementalBuild>True</IncrementalBuild>
<GetOverwrite>True</GetOverwrite>
2
It is not good practice to checkin as part of the build? Could you explain the necessity?MrHinsh - Martin Hinshelwood
The build is preprocessing some legacy source files on disk before compiling them.canuckdownunder

2 Answers

1
votes
  1. Create a PowerShell script (for instance c:\Builds\GetCodeGeneratedFiles.ps1) on the build agent with the content:

    & "c:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\TF.exe" get "$Env:TF_BUILD_SOURCESDIRECTORY\*.*" /v:"$Env:TF_BUILD_SOURCEGETVERSION" /recursive /overwrite /noprompt
    
  2. Update the build definition so that the Pre-build script path is the PowerShell Script (for instance c:\Builds\GetCodeGeneratedFiles.ps1)

When the build runs it will do a Get of all files across the workspace up to the version specified by the queued build. Then when the Get step in the Team Build process runs it won't need to Get any files since they will already exist in the local workspace.

0
votes

When you edit the build definition, you should see a process tab. In there, there's usually an option to change the way the build definition performs it's get. You don't have the same overwrite issues, because it will get the right files to begin with. If you have files already there it will replace them with the files checked in.