TFS 2015 build server with git line endings

We use TFS 2015 with GIT and Team Foundation Build 2015 as Build definition. The Sources are in C/C++.
On the Build Server I’m facing a line ending problem.

On the developers PC (Microsoft Windows 7) the core.autocrlf=true is set. The line endings are always CRLF which is ok.

On the Build Server (Microsoft Server 2012 R2) the same core.autocrlf=true is set. If I get the sources on the Build Server on the command line (git version everything is ok and all source files has CRLF as line ending.
But if the Build definition (e.g. for continuous integration) gets the sources, the line endings are always LF.

Where can I set the core.autocrlf=true for the Build definition?

  • How to Determine the Work Items Fixed in a particular TFS Build when using Branches?
  • Pending Changes Visual Studio 2013, Git repository
  • Error encountered while cloning the remote repository with VS 2015 Update 3 (TFS 2015 Update 3)
  • Git operation during TFS build: “fatal: could not read Password” (wincred used)
  • TFS 2010 - Deleting a folder in Visual Studio solution before check-in of changes
  • TFS Branching & Merging Strategies
  • What is best way to manage multiple related repositories with git?
  • TFS Submodule in a seperate Team Project
  • 2 Solutions collect form web for “TFS 2015 build server with git line endings”

    I found the problem and the solution.

    The setting core.autocrlf true is correct for my environment. But the Build Server starts the Build with a different user as I was logged in to do the check of the settings.

    Solution: Make sure the all users on the Build server has the same setting.
    I set an Environment System Variable HOME to the directory C:\GitHome. Within this directory the file .gitconfig is placed with the correct setting.
    This works for my case.

    Assuming you are using vNext build. Get Source is a automatic step, we can’t set or modify this step.

    Just have a quick test, set core.autocrlf to True with command git config --global core.autocrlf true. Then run vNext build, the source will be checked out to %agent%\_work\xx\s. After that, under this working folder, run command git config --list, you’ll see core.autocrlf=true. Get-source step doesn’t change the core.autocrlf. You may try with this way.

    This article provides more information on how to deal with line endings.

    Git Baby is a git and github fan, let's start git clone.