Go to Implementation with sourcelink
Asked Answered
W

2

11

How can I enable visual studio to 'Go to implementation' for library code that is exposed with SourceLink?

We recently began using SourceLink in our .NETcore library in an attempt to debug the library while consuming it. We enabled SourceLink using this project: ctaggart/SourceLink by adding the following line to our csproj:

<PackageReference Include="SourceLink.Embed.AllSourceFiles" Version="2.6.0" PrivateAssets="All" />

This has worked great in that I are now able to step into the library code with the debugger, but I am unable to jump to implementation/definition of any of this library code. Is there a way I can get visual studio to do this?

Wenoa answered 20/12, 2017 at 0:42 Comment(2)
I'd really like to see that too. Just like the embedded support that just shipped with VS 15.5, you probably want to add a suggestion in uservoice for Visual Studio IDE and link to it from the embedded support suggestion: visualstudio.uservoice.com/forums/121579-visual-studio-ide/…Extortionary
@CameronTaggart Good suggestion! Just posted: visualstudio.uservoice.com/forums/121579-visual-studio-ide/…Wenoa
Z
1

SourceLink is now a .NET Foundation project at https://github.com/dotnet/sourcelink/.

First, configure how Source Link will behave:

You can enable SourceLink experience in your own project by setting a few properties and adding a PackageReference to a SourceLink package:

<Project Sdk="Microsoft.NET.Sdk">
 <PropertyGroup>
    <TargetFramework>netcoreapp2.1</TargetFramework>

    <!-- Optional: Publish the repository URL in the built .nupkg (in the NuSpec <Repository> element) -->
    <PublishRepositoryUrl>true</PublishRepositoryUrl>

    <!-- Optional: Embed source files that are not tracked by the source control manager in the PDB -->
    <EmbedUntrackedSources>true</EmbedUntrackedSources>

    <!-- Optional: Include the PDB in the built .nupkg -->
    <AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
  </PropertyGroup>
  <ItemGroup>
    <!-- Add PackageReference specific for your source control provider (see below) --> 
  </ItemGroup>
</Project>

Then, add the Source Link package that matches your repository. Packages are currently in pre-release and these are the available ones:

github.com and GitHub Enterprise

<ItemGroup>
    <PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0-beta-63127-02" PrivateAssets="All"/>
</ItemGroup>

Visual Studio Team Services

<ItemGroup>
    <PackageReference Include="Microsoft.SourceLink.Vsts.Git" Version="1.0.0-beta-63127-02" PrivateAssets="All"/>
</ItemGroup>

Team Foundation Server

<ItemGroup>
    <PackageReference Include="Microsoft.SourceLink.Tfs.Git" Version="1.0.0-beta-63127-02" PrivateAssets="All"/>
    <SourceLinkTfsGitHost Include="tfs-server-name" VirtualDirectory="tfs"/>
</ItemGroup>

GitLab

<ItemGroup>
    <PackageReference Include="Microsoft.SourceLink.GitLab" Version="1.0.0-beta-63127-02" PrivateAssets="All"/>
</ItemGroup>

Bitbucket.org

<ItemGroup>
    <PackageReference Include="Microsoft.SourceLink.Bitbucket.Git" Version="1.0.0-beta-63127-02" PrivateAssets="All"/>
</ItemGroup>
Zebulon answered 3/9, 2018 at 8:49 Comment(2)
kindly consider adding more information in your from the link that is relevant to the question. It helps in case the link is removed.Naldo
@MarcoThomazini How does this answer the question?Cadmarr
F
3

Being able to navigate to the source of a NuGet package is something that is being considered but has yet to be done. You can track its progress at https://github.com/dotnet/roslyn/issues/24349.

Freshman answered 30/1, 2020 at 15:52 Comment(0)
Z
1

SourceLink is now a .NET Foundation project at https://github.com/dotnet/sourcelink/.

First, configure how Source Link will behave:

You can enable SourceLink experience in your own project by setting a few properties and adding a PackageReference to a SourceLink package:

<Project Sdk="Microsoft.NET.Sdk">
 <PropertyGroup>
    <TargetFramework>netcoreapp2.1</TargetFramework>

    <!-- Optional: Publish the repository URL in the built .nupkg (in the NuSpec <Repository> element) -->
    <PublishRepositoryUrl>true</PublishRepositoryUrl>

    <!-- Optional: Embed source files that are not tracked by the source control manager in the PDB -->
    <EmbedUntrackedSources>true</EmbedUntrackedSources>

    <!-- Optional: Include the PDB in the built .nupkg -->
    <AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
  </PropertyGroup>
  <ItemGroup>
    <!-- Add PackageReference specific for your source control provider (see below) --> 
  </ItemGroup>
</Project>

Then, add the Source Link package that matches your repository. Packages are currently in pre-release and these are the available ones:

github.com and GitHub Enterprise

<ItemGroup>
    <PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0-beta-63127-02" PrivateAssets="All"/>
</ItemGroup>

Visual Studio Team Services

<ItemGroup>
    <PackageReference Include="Microsoft.SourceLink.Vsts.Git" Version="1.0.0-beta-63127-02" PrivateAssets="All"/>
</ItemGroup>

Team Foundation Server

<ItemGroup>
    <PackageReference Include="Microsoft.SourceLink.Tfs.Git" Version="1.0.0-beta-63127-02" PrivateAssets="All"/>
    <SourceLinkTfsGitHost Include="tfs-server-name" VirtualDirectory="tfs"/>
</ItemGroup>

GitLab

<ItemGroup>
    <PackageReference Include="Microsoft.SourceLink.GitLab" Version="1.0.0-beta-63127-02" PrivateAssets="All"/>
</ItemGroup>

Bitbucket.org

<ItemGroup>
    <PackageReference Include="Microsoft.SourceLink.Bitbucket.Git" Version="1.0.0-beta-63127-02" PrivateAssets="All"/>
</ItemGroup>
Zebulon answered 3/9, 2018 at 8:49 Comment(2)
kindly consider adding more information in your from the link that is relevant to the question. It helps in case the link is removed.Naldo
@MarcoThomazini How does this answer the question?Cadmarr

© 2022 - 2024 — McMap. All rights reserved.