-
Notifications
You must be signed in to change notification settings - Fork 134
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 [...]):
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<Title>Use to verify Source Link functionality</Title>
<SignAssembly>False</SignAssembly>
<AssemblyVersion>1.0.5</AssemblyVersion>
<FileVersion>$(AssemblyVersion)</FileVersion>
<Version>$(AssemblyVersion)</Version>
<Company>[...]</Company>
<RepositoryUrl>https://bitbucket.[...]/scm/tjcomplayg/sourcelinktest.git</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
<IncludeSymbols>False</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DebugType>embedded</DebugType>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DebugType>none</DebugType>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.Bitbucket.Git" Version="8.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
</Project>
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:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UseWPF>true</UseWPF>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="sourceLinkTest" Version="1.0.5" />
</ItemGroup>
</Project>
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?