Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Host bower component on Visual Studio Online

Problem:
What I try to do is host a bower components on visual studio online. This seems however not possible the way I try to do it.

I have created a bower component and checked it into visual studio online with the tutorial of Brian Ford. This bower component now safely resides in my a visual studio git project. However, when I try to do:

bower install https://myAccount.visualstudio.com/DefaultCollection/_git/bower-component    

it put's something in the bower_components folder, but this is not the bower components that I have pushed to visual studio online. In the bower_components folder is a bower.json, with some incorrect values and an "index" file, without file extension. When I open this "index" file in an editor, it looks like the login page of visual studio online.

To me it seems that the problem is the authentication when connecting to visual studio online.

I tried:

  • To used git credentials store but this didn't seem to have any effect when trying to download the bower components.
  • I also tried to use "private-bower", to register visual studio online as proxy with the alternative username and password of visual studio online. However, it was not possible to register the URL's of visual studio online because private-bower only support git:// URL's.

Does anyone have any experience with trying to get this to work with visual studio online, or any team foundation server? Or does anyone has other possible solutions to this problem?

like image 455
Ricconnect Avatar asked Feb 11 '23 11:02

Ricconnect


1 Answers

* Update June 2016

TFS 2015 (as of Update 3) now supports SSH connecting to Git repos. Using the git+https:// may not be required anymore for Bower to retrieve code, but will require some testing on your side.


Original Response

I dove into this last week and made some interesting findings. A workaround, and a possible bug identified in TFS. I researched with an on-premise version of TFS, but it may still apply.

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 from an online Git repository, 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 URL itself (which I wouldn't).


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.

This information is also posted at MSDN Forums.

like image 103
mitch Avatar answered Feb 14 '23 08:02

mitch