locked
Use git on TFS to host bower component

    Question

  • Hi,

    My question is if it is possible to host a bower component on a git repository of TFS and let it function as a private bower repository.

    I know that TFS correctly work with git, for example I can do a git clone on my bower component repository and it successfully clones the repository. But when I do a bower install I only get a "sort of" html page downloaded with seems to display the login screen when you connect to TFS. So it seems that bower does not authenticate correctly to TFS, however I don't think you can intercept this authentication process and alter it.

    The alternative that I have thought of to create my private repository and reuse the components in other projects (like with bower) is to create a custom grunt task that does a clone of the repositories. Versioning in that case is done with branches, because tag support does not seem that extended yet in TFS. Does this seem to be the only way to do this? I prefer to use bower, because it has a much more functionality and is already used in my projects. 

    Thursday, March 19, 2015 8:34 AM

Answers

  • Hi, Ricconnect.

    I dove into this last week and made some interesting findings. A workaround, and a bug identified in TFS. 

    For starters, you will want to use HTTPS to connect to your TFS instance. Bower, upon pulling from a HTTPS source, will prompt for credentials that gets passed to TFS. Then, since TFS does not recognize the ".git" suffix that Bower also expects, you need to adjust the protocol.

    bower install "git+https://tfs.domain.com/tfs/Collection/_git/MyComponent"

    This should be enough to get Bower to talk to TFS and pull the component. You will need to enter your credentials as it runs, unless you feel comfortable putting them in the https URL itself. 

    -----

    Now, where you'll run into issues is if you tag your commits with versions (as you would want to do to properly version your component). TFS doesn't seem to play nicely with tags, as you've noticed. If you do this, when bower runs a checkout, an error throws in TFS. 

    InvalidCastException:
    Unable to cast object of type 'Microsoft.TeamFoundation.Git.Server.TfsGitTag'
    to type 'Microsoft.TeamFoundation.Git.Server.TfsGitCommit'.

    I found this looking at the administration logs at http://tfs.domain.com:8080/tfs/_oi. 

    If I tried to checkout a bower component where I did not tag any of my commits, things went successfully. I guess now all that's left to do is file a bug in TFS for this...

    • Marked as answer by Ricconnect Tuesday, September 01, 2015 12:40 PM
    Monday, April 06, 2015 3:51 PM

All replies

  • Hi,

    Thank you for posting in here.
    We are checking on this and will get back at earliest.

    Regards,
    Manu Rekhar
    Thursday, March 19, 2015 5:42 PM
    Moderator
  • Thanks, Manu. I am also looking to get more information about this.

    Especially with Visual Studio 2015 support for bower integration, I think more and more users will be interested. Especially those working on enterprise or closed-source solutions. Being able to manage front-end components via our on-premise TFS would be ideal. 

    Asking for TFVC interoperability would be too much ... :) 


    Friday, April 03, 2015 3:04 PM
  • Hi, Ricconnect.

    I dove into this last week and made some interesting findings. A workaround, and a bug identified in TFS. 

    For starters, you will want to use HTTPS to connect to your TFS instance. Bower, upon pulling from a HTTPS source, will prompt for credentials that gets passed to TFS. Then, since TFS does not recognize the ".git" suffix that Bower also expects, you need to adjust the protocol.

    bower install "git+https://tfs.domain.com/tfs/Collection/_git/MyComponent"

    This should be enough to get Bower to talk to TFS and pull the component. You will need to enter your credentials as it runs, unless you feel comfortable putting them in the https URL itself. 

    -----

    Now, where you'll run into issues is if you tag your commits with versions (as you would want to do to properly version your component). TFS doesn't seem to play nicely with tags, as you've noticed. If you do this, when bower runs a checkout, an error throws in TFS. 

    InvalidCastException:
    Unable to cast object of type 'Microsoft.TeamFoundation.Git.Server.TfsGitTag'
    to type 'Microsoft.TeamFoundation.Git.Server.TfsGitCommit'.

    I found this looking at the administration logs at http://tfs.domain.com:8080/tfs/_oi. 

    If I tried to checkout a bower component where I did not tag any of my commits, things went successfully. I guess now all that's left to do is file a bug in TFS for this...

    • Marked as answer by Ricconnect Tuesday, September 01, 2015 12:40 PM
    Monday, April 06, 2015 3:51 PM
  • Thanks for the great information, Mitchell.  Did you actually file the bug?  If so, I would be interested in tracking that, if you have a link to it...
    Wednesday, July 08, 2015 2:48 PM
  • Is there any more progress on this. We are trying to use tfs git VC for bower internally. It looks like I can use bower by branch, but not by tags
    Friday, May 20, 2016 4:46 PM