Skip to content
This repository has been archived by the owner on Apr 16, 2020. It is now read-only.

Any tips for troubleshooting Visual Studio no working with Source Link? #306

Closed
epignosisx opened this issue Jan 9, 2018 · 16 comments
Closed

Comments

@epignosisx
Copy link

I'm trying to integrate SourceLink V2 with our internal repos and it seems like the nuget is generated correctly with SourceLink based on the output of:

dotnet sourcelink test path/to/Assembly.1.0.0.nupkg
sourcelink test passed: lib/netstandard2.0/Assembly.dll

However, when I installed the nuget in a solution and try to step in the assembly it does not work. Any tips for troubleshooting? I checked VS's debug output but it does not have anything related Source Linking. I do not get a VS prompt either.

Here is my VS config:

image

image

This is the csproj:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
    <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
    <PackageVersion>0.0.0</PackageVersion>
    <AssemblyVersion>0.0.0</AssemblyVersion>
    <Company>X</Company>
    <Authors>X</Authors>
    <Description>X</Description>
    <DebugSymbols>true</DebugSymbols>
    <DebugType>embedded</DebugType>
    <IncludeSymbols>false</IncludeSymbols>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="System.ComponentModel.Primitives" Version="4.3.0" />
    <PackageReference Include="System.Diagnostics.Debug" Version="4.3.0" />
    <PackageReference Include="System.Diagnostics.DiagnosticSource" Version="4.4.1" />
    <PackageReference Include="System.Private.ServiceModel" Version="4.4.0" />
    <PackageReference Include="System.ServiceModel.Duplex" Version="4.4.0" />
    <PackageReference Include="System.ServiceModel.Http" Version="4.4.0" />
    <PackageReference Include="System.ServiceModel.NetTcp" Version="4.4.0" />
    <PackageReference Include="System.ServiceModel.Security" Version="4.4.0" />
    <PackageReference Include="SourceLink.Create.CommandLine" Version="2.7.4" PrivateAssets="All" />
    <DotNetCliToolReference Include="dotnet-sourcelink" Version="2.7.4" />
  </ItemGroup>

</Project>

Relevant build script line:

& dotnet build $solution --configuration "Release"  /p:Platform="Any CPU" /p:SourceLinkCreate=true  /p:SourceLinkUrl="http://stash.xxx.com:7990/projects/cclcom/repos/xxx/browse/*?raw=1&at={commit}"
@ctaggart
Copy link
Owner

ctaggart commented Jan 9, 2018

SourceLink 2.7.4
Source Code On Demand

Usage:  [options] [command]

Options:
  -h|--help  Show help information

Commands:
  print-documents  print the documents stored in the pdb or dll
  print-json       print the Source Link JSON stored in the pdb or dll
  print-urls       print the URLs for each document based on the Source Link JSON
  test             test each URL and verify that the checksums match

Use " [command] --help" for more information about a command.

@ctaggart
Copy link
Owner

ctaggart commented Jan 9, 2018

While debugging, you can also make sure the pdb files (symbols) are actually loaded.

Debug > Windows > Modules (Ctrl + Alt + U)

image

@epignosisx
Copy link
Author

epignosisx commented Jan 10, 2018

Thanks for the help. I switched to portable and it worked when I using a local (file system) nuget feed! However, when the nuget is created from our CI (TeamCity), it fails to Step Into.

If I try to manually load the symbols through the Debug > Windows > Modules, it is trying to point to a file system location in the CI agents. Not sure if this is expected or not, but here are some details:

image

If I click on "Symbol Load Information" it has the TC location

image

This is my Symbols Settings:

image

In the Team City agent, this is the sourcelink.json file generated:

{"documents":{"D:\\TCW\\16805bc3ab87691c\\*":"http://stash.xxx.com:7990/projects/cclcom/repos/somerepo/browse/*?raw=1&at=de2a587657d77c404ff75047fb6ce66064cff418"}}

Following your advise, if I unzip the generated nuget in TeamCity, and run the dotnet source-link commands this is what I get:

dotnet sourcelink print-json c:\temp\nuget\Assembly.1.9.5\lib\netstandard2.0\Assembly.pdb
{"documents":{"D:\\TCW\\16805bc3ab87691c\\*":"http://stash.xxx.com:7990/projects/cclcom/repos/somerepo/browse/*?raw=1&at=de2a587657d77c404ff75047fb6ce66064cff418"}}

dotnet sourcelink print-documents c:\temp\nuget\Assembly.1.9.5\lib\netstandard2.0\Assembly.pdb
c77b4dd8b5444604628bf81030467e4cea671e45 sha1 csharp D:\TCW\16805bc3ab87691c\src\Assembly\Utilities\CastUtilities.cs
867ed556e45121e470e52806b9e7637b8b779372 sha1 csharp D:\TCW\16805bc3ab87691c\src\Assembly\Utilities\EmailExtensions.cs
etc

dotnet sourcelink print-urls c:\temp\nuget\Assembly.1.9.5\lib\netstandard2.0\Assembly.pdb
c77b4dd8b5444604628bf81030467e4cea671e45 sha1 csharp D:\TCW\16805bc3ab87691c\src\Assembly\Utilities\CastUtilities.cs
http://stash.xxx.com:7990/projects/cclcom/repos/somerepo/browse/src/Assembly/Utilities/CastUtilities.cs?raw=1&at=de2a587657d77c404ff75047fb6ce66064cff418
867ed556e45121e470e52806b9e7637b8b779372 sha1 csharp D:\TCW\16805bc3ab87691c\src\Assembly\Utilities\EmailExtensions.cs
http://stash.xxx.com:7990/projects/cclcom/repos/somerepo/browse/src/Assembly/Utilities/EmailExtensions.cs?raw=1&at=de2a587657d77c404ff75047fb6ce66064cff418
etc

The BitBucket urls are correct. If I paste the generated file urls into the browser, I get the raw file. Is

http://stash.xxx.com:7990/projects/cclcom/repos/somerepo/browse/*?raw=1&at=de2a587657d77c404ff75047fb6ce66064cff418

supposed to be a url or a pattern? If it is supposed to be a url that returns a snapshot of all the files for that commit, then it is not working. I'm getting a 404 from BitBucket Server.

By the way, I try to run the dotnet source-link commands pointing at the nupkg I get the following error for all the print-* commands:

Invalid COR20 header signature.

However, this one passes:

dotnet sourcelink test c:\temp\nuget\Assembly.1.9.5.nupkg
sourcelink test passed: lib/netstandard2.0/Assembly.pdb

@YakhontovYaroslav
Copy link

YakhontovYaroslav commented Jan 10, 2018

I have encountered similar as in comment above problem with embedded source files.
Enabling this debug setting helped:
image

But unfortunately this goes against this guide on debugging .net sources and i cannot debug framework sources anymore.

@ctaggart
Copy link
Owner

@epignosisx If you are getting 404 errors from the URLs, then sourcelink test should be failing.

@ctaggart
Copy link
Owner

@YakhontovYaroslav possibly a Visual Studio regression if embedded source works for 15.5.0 and not 15.5.2.

@ctaggart
Copy link
Owner

ctaggart commented Jan 10, 2018

As a troubleshooting step, try out a source link enabled library that is known to work. I created an example and uploaded a video demo in #307.

@epignosisx
Copy link
Author

@ctaggart the individual urls for each file work just fine. My question is about this one:

http://stash.xxx.com:7990/projects/cclcom/repos/somerepo/browse/*?raw=1&at=de2a587657d77c404ff75047fb6ce66064cff418

from the print-json output. Is that supposed to be a true url that should return a 200 OK from BitBucket?

@ctaggart
Copy link
Owner

@epignosisx The information in the json is used to construct the URLs. The * gets replaced. If the URLs work, it should work in Visual Studio (unless our implementations are slightly different).

@epignosisx
Copy link
Author

@ctaggart thank you so much for putting together that video! It helped a lot narrowing things down. I downloaded the TryJson repo and it worked great! So definitely not a VS issue.

So I went back and started looking at my implementation and found the problem. It was simply that I'm publishing my ASP.NET Core app to a different directory and during the publishing the dependencies' pdb files are not copied over. Once I manually copied the pdb it worked!

You should consider adding that video and the TryJson to the wiki as troubleshooting tips. It will definitely narrow down the problem.

@ctaggart
Copy link
Owner

@epignosisx Glad you figured it out.

Any idea what is needed to get the pdb files copied over automatically. If you add SourceLink to your ASP.NET Core app too, does it then copy the pdb files. Or if you add this property, does it copy the pdb files?

@epignosisx
Copy link
Author

epignosisx commented Jan 15, 2018

I haven’t figured that part out yet. I’m going to try out a few things, among them your suggestion. I’ll post my findings.

This wouldn’t be an issue if embedded pdbs would have worked. Any idea why?

@ctaggart
Copy link
Owner

ctaggart commented Jan 27, 2018

It appears the the .NET Core projects when targeting the .NET Framework do not copy the pdb files to the Debug or Release directories. the .NET Core targets use runtimeconfig files, so they end up using the files from their original locations.

netcoreapp2.0

<TargetFramework>netcoreapp2.0</TargetFramework>

image

net46

<TargetFramework>net46</TargetFramework>

image

The file is there:
image

I'll open up a bug.

@ctaggart ctaggart reopened this Jan 27, 2018
@ctaggart
Copy link
Owner

The old project file format ends up with this output:
image

@ctaggart
Copy link
Owner

I opened up bug 3rd party pdb files not copied to build output #2920.

@ctaggart
Copy link
Owner

ctaggart commented Feb 1, 2018

I opened up a specific issue to track this problem. #313

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants