GitTools / GitLink

Making .NET open source accessible!
MIT License
555 stars 86 forks source link

Question/Help: VS 2015 - Operation not supported? #80

Open raghur opened 8 years ago

raghur commented 8 years ago

I'm doing a quick test with internal bitbucket server and VS 2015 loads symbol but will not pull down the source. I'm testing on the same machine that I built the dll on - however, I have deleted the source file from the disk location to force VS to load source from Git. (Operation not supported from SRCSRV)

Here's the OUtput window

'TestApp.vshost.exe' (CLR v4.0.30319: TestApp.vshost.exe): Loaded 'd:\Code\TestApp\TestApp\bin\Debug\TestApp.exe'. Symbols loaded.
'TestApp.vshost.exe' (CLR v4.0.30319: TestApp.vshost.exe): Loaded 'd:\Code\TestApp\TestApp\bin\Debug\ALibraryComponent.dll'. Symbols loaded.
SRCSRV: Source server cannot retrieve the source code for file 'D:\code\services.core\src\ALibraryComponent\AnInterestingClass.cs' in module 'd:\Code\TestApp\TestApp\bin\Debug\ALibraryComponent.dll'. Operation not supported. Unknown error: 0x80004005.

Here's the pdbstr output on the dll

$ pdbstr.exe -r   -p:d:\code\TestApp\lib\ALibraryComponent.pdb -s:srcsrv
SRCSRV: ini ------------------------------------------------
VERSION=2
SRCSRV: variables ------------------------------------------
RAWURL=https://xxxxx.xxxxx.com/projects/YYY/repos/services.core/browse/%var2%?at=983ce92dbe49289d3bfcbbb42b2d6d06eb2c8aaa&raw
SRCSRVVERCTRL=https
SRCSRVTRG=%RAWURL%
SRCSRV: source files ---------------------------------------
D:\code\services.core\src\ALibraryComponent\AnInterestingClass.cs*src/ALibraryComponent/AnInterestingClass.cs
D:\code\services.core\src\ALibraryComponent\Properties\AssemblyInfo.cs*src/ALibraryComponent/Properties/AssemblyInfo.cs
SRCSRV: end ------------------------------------------------

Things I checked:

  1. VS 2015 - running as Administrator (elevated)
  2. Just my code disabled
  3. Symbol cache folder enabled
raghur commented 8 years ago

So I re-ran GitLink with -powershell and now I get a HTML file. I guess that's because the login form's being downloaded. I have IE open and logged in to my Bitbucket server instance (as advised on the main page)... Any help?

raghur commented 8 years ago

Found it... and for the benefit of anyone else coming across this - so SRCSRV will only download urls without query strings.

I think hoping to get this working with an internal Bitbucket server seems like a dead end!

SRCSRV will re-use a cookie (so if you login to bitbucket server on IE) and then it tries to download, it probably will be able to. But because it can't do query strings, it can't be used.

The -powershell option can get around the SRCSRV, but now all it gets back is the login page.

I wonder how people have got this working? @marcind or @sMusy - can you help?

sMusy commented 8 years ago

The login page probably means you don't have rights to access the repo. Is it in public access ? If your network is intra that would not be a problem to configure Bitbucket as public access right ? At least that's what I did.

raghur commented 8 years ago

I have rights - just have to login to the repo with domain credentials. Even for read access one has to login, since there are lots of repos and people only have access to a subset based on their needs.

raghur commented 8 years ago

Here's an open ticket on Bitbucket server for providing non-suffixed urls. (not holding my breath for that, though)

sMusy commented 8 years ago

Authentication when using powershell option with GitLink is indeed not implemented yet. Giving credentials as parameter is not a good option I guess :)

A popup asking for credentials when launching the powershell download would be the way to go. I'll look into that and see if I can do a PR as soon as I can.

raghur commented 8 years ago

So does anyone have an idea why SRCSRV will barf on a url with query params? Seems weird... probably worth sending that back to M$ but doubt that it's something they'll fix quickly. Just seems so weird!

sMusy commented 8 years ago

There is an issue about this here https://github.com/ctaggart/SourceLink/issues/94

raghur commented 8 years ago

Thanks @sMusy - that was helpful along with the linked SO post. It's so ridiculous that it boggles the mind. As if it's not possible to find out what protocol (file, unc or HTTP/S) is being used and based on that reject paths. Anyway, I'm just venting :) and it's probably going to stay as is until M$ move to ppdb or stop using srcsrv.dll in VS.

shonnly commented 8 years ago

@raghur - i spend a whole day trying to fight it, and now i see this thread. Any update on this? Seems like i am stuck with the same situation exactly.

Did anyone found a way to fix this?

raghur commented 8 years ago

@shonnly - no update. BTW, the bitbucket server ticket is marked as fixed (as in they support query param less urls now) however, you probably have to update to the latest server (fix ver is 4.7.0)

shonnly commented 8 years ago

@raghur - i ended up setting up a tiny Web Api service that queries a local clone of a Git repository. So this pretty much solved the issue for me and my team. I had to make some changes to GitLink. If you decide to go the same path, i posted a blog post about this.

https://shonnlyga.wordpress.com/2016/05/28/source-server-with-git-repository/

michael-hay commented 5 years ago

The bitbucket ticket mentioned above did not fix this issue as they did not expose a way to get a specific revision in a non-suffixed URL. They say the following:

We added a URL at /projects/{project}/repos/{repo}/raw/{path...}.

In order to get a specific revision you still need to use the syntax

?at=

The quick workaround it to setup an NGINX rewrite rule. Takes about 5 minutes. Set a location like this (here nginx is on a different host than Bitbucket Enterprise, Yes I am sure there are better regexs than this...use at your own risk. )

location /srcsrv/ {
 rewrite /srcsrv/([^/]+)/([^/]+)/([^/]+)/(.+) https://bitbucket.company.com/projects/$1/repos/$2/raw/$4?at=$3 break;
 }

Add Gitlink nuget as a dependency to your project. Open your .csproj file and add a parameter for the GitLinkGitRemoteUrl to your PropertyGroup (I did this for my release builds, edit the project and repo name for your repo, leave the rest as is)

<GitLinkGitRemoteUrl>http://nginx_host/srcsrv/<project>/<repo_name>/{revision}/{filename}</GitLinkGitRemoteUrl>

Note when you build Gitlink will instrument your PDB to point to the nginx server which will do a URL rewrite to Bitbucket Enterprise to get the file revision you want.

juangburgos commented 3 years ago

I made a small node app to make the proper URL rewrites for Gitlab: https://github.com/juangburgos/GitlabRewritter