dotnet / dotnet/sourcelink

VS Debugger does not retrieve source code from Bitbucket Data Center

Open
#1,493 3 comments 0 reactions 0 assignees View on GitHub
external
Dominant language
C#
Stars
1.4k
Forks
148
PR merge metrics
No merged PRs in 30d

Description

For several days I have been trying to get Source Link to work with my company's Bitbucket Data Center instance, but with no success so far.

**The package**
I have created a NuGet package "sourceLinkTest" with the following project file (some details replaced by `[...]`):
```


net8.0
enable
enable
True
Use to verify Source Link functionality
False
1.0.5
$(AssemblyVersion)
$(AssemblyVersion)
[...]
https://bitbucket.[...]/scm/tjcomplayg/sourcelinktest.git
git
true
False
snupkg


embedded
true


none



all
runtime; build; native; contentfiles; analyzers; buildtransitive

```

The resulting package looks fine in the _NuGet Package Explorer_:

- Health -> Source Link: Valid
- Repository -> Type: git
- Repository -> Url: `https://bitbucket.[...]/projects/tjcomplayg/repos/sourcelinktest/browse`
- Package contents -> sourceLinkTest.dll -> PDB Sources contains `https://bitbucket.[...]/projects/tjcomplayg/repos/sourcelinktest/raw/ExceptionalClass.cs?at=aa00542ad8ee5d37a1ff69ac6a128dc6f88c1289`. In a browser, this URL yields the raw source code of the file ExceptionalClass.cs, **provided that I am authenticated via SSO.**

The _sourcelink CLI tool_ gives mixed results:
```
PS C:\Temp> sourcelink print-urls .\sourceLinkTest.dll
68c4166a442cfa9751843e5e2d5d9c06414ba32666fed9f4c64a1a7e114c8b5f sha256 csharp /_/ExceptionalClass.cs
https://bitbucket.[...]/projects/tjcomplayg/repos/sourcelinktest/raw/ExceptionalClass.cs?at=aa00542ad8ee5d37a1ff69ac6a128dc6f88c1289
f3f134e9e825e3e7268090f58b1af2bda2de513f61a09c56f48b9b8d08612abc sha256 csharp /_/obj/Debug/net8.0/sourceLinkTest.GlobalUsings.g.cs
embedded
f7a5d9789c863625e139ff99e1113a503830f6b85a88f6129916df83ac76b49e sha256 csharp /_/obj/Debug/net8.0/.NETCoreApp,Version=v8.0.AssemblyAttributes.cs
embedded
40a4271744bf84ef21d98d0c91d7dd61bb4f10d5394df12fb2983a610dda5d76 sha256 csharp /_/obj/Debug/net8.0/sourceLinkTest.AssemblyInfo.cs
embedded
```
looks fine, but
```
PS C:\Temp> sourcelink test .\sourceLinkTest.dll
1 Documents with errors:
68c4166a442cfa9751843e5e2d5d9c06414ba32666fed9f4c64a1a7e114c8b5f sha256 csharp /_/ExceptionalClass.cs
https://bitbucket.[...]/projects/tjcomplayg/repos/sourcelinktest/raw/ExceptionalClass.cs?at=aa00542ad8ee5d37a1ff69ac6a128dc6f88c1289
error: url hash does not match: 68c4166a442cfa9751843e5e2d5d9c06414ba32666fed9f4c64a1a7e114c8b5f
sourcelink test failed
```
does not. I assume that the authentication is the problem here.

**The application**
Project file of my .NET 8.0 test application:
```


WinExe
net8.0-windows
enable
enable
true



```
When the app is loaded, I call a constructor from `sourceLinkTest` that throws an exception. For my tests I start my app with the Visual Studio Debugger attached.

**Expectation**
When the exception is thrown, the debugger displays the code containing the `throw` statement (= source code of the package).

**Observation**
When the exception is thrown, the highlighted line is where the constructor is called (= source code of the app), not the place where the exception is thrown (= source code of the package). If I "Go to [the] definition" of the constructor, I see disassembled code, not the original source.

**Debug output**
I see zero output related to Source Link in the Debug output pane, especially no HTTP status code.
However, for about two seconds a dialog is displayed saying

> Locating Source
> The debugger is locating source files. Please wait.
> / _/ExceptionalClass.cs"

Do you have any suggestions how to further debug this issue and get Source Link working?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.