Search code examples
gitvisual-studio-2017azure-devopsvisual-studio-2019git-credential-manager

Cloning repository from MSA backed Azure DevOps using Visual Studio 2017 or 2019 and AAD account


Microsoft has introduced the option to invite AAD users into MSA backed Azure DevOps accounts. This is great for companies that are transitioning accounts over from "unmanaged" to "managed", starting with transferring account ownership to an AAD user and then fixing the user and licensing mess in a slower approach.

However, when I try to clone a repository using Visual Studio 2017 or 2019, I'm greeted with an error message:

enter image description here

Git failed with a fatal error. Authentication failed for: {remote-url}.

or, depending on which version of the Git credential manager you have:

error: cannot spawn askpass: No such file or directory fatal: could not read Username for '{remote-url}': terminal prompts disabled`

When cloning from the command line, there are no issues and afterward, Visual Studio can also use the resulting git repository.


Solution

  • Update

    The latest version os Visual Studio 2017 (15.9.10+) now contains version 1.18.4 of the Git Credential Manager and should solve many of the issues that were caused by the older versions. Should you need a more recent version of the GCMfW, the same trick should work for newer versions too.


    After chatting with Chad Boles (who maintains Team Explorer in Visual Studio), we worked out another option. This is preferred over overwriting the files in the Visual Studio installation as this may break future updates and can cause hard to debug issues in the future.

    1. Install the latest GCMW-1.xx.xx.exe in your system and/or update to the latest version of Git for Windows which should include GCM.
    2. Update your global git config to point to a specific implementation of the Git credential Manager:

      c:\>git config --global --edit
      

      Update the [credential] section to read:

      [credential]
          helper = C:\\\\Program\\ Files\\\\Git\\\\mingw64\\\\libexec\\\\git-core\\\\git-credential-manager.exe
      

      Ensure the path points to where the latest Git Credential Manager can be found on your system. Mind all of the escapes needed to make paths work in the global git config.