dotnet / sourcelink

Source Link enables a great source debugging experience for your users, by adding source control metadata to your built assets
MIT License
1.26k stars 122 forks source link

Access Private Repo Github don't send authentification #865

Open DavyLGinkoia opened 2 years ago

DavyLGinkoia commented 2 years ago

Description

I have a problem to debug and step into the source code for my package. SourceLink is not working properly for my own package (see attached screenshot).


Package Information

image


Basic Information


Configuration Package


  <PropertyGroup>
    <TargetFramework>net6.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>disable</Nullable>
  </PropertyGroup>

    <PropertyGroup>
        <DefaultItemExcludes>$(DefaultItemExcludes);PublishWebDeploy*\**;.logs\**</DefaultItemExcludes>
    </PropertyGroup>

    <PropertyGroup Label="Common">
        <Compagny>********</Compagny>
        <Author>Davy L</Author>
                <Copyright>2022</Copyright>
    </PropertyGroup>

  <PropertyGroup Label="Package">
    <IsPackable>true</IsPackable>
    <GeneratePackageOnBuild>false</GeneratePackageOnBuild>
    <RepositoryUrl>https://github.com/***********/Ginkoia.API.Common</RepositoryUrl>
    <IncludeSymbols>true</IncludeSymbols>
    <SymbolPackageFormat>snupkg</SymbolPackageFormat>
  </PropertyGroup>

<PropertyGroup Label="Debug">
  <DebugType>portable</DebugType>
</PropertyGroup>

  <PropertyGroup Label="SourceLink issues 572">
    <TargetFrameworkMonikerAssemblyAttributesPath>$([System.IO.Path]::Combine('$(IntermediateOutputPath)','$(TargetFrameworkMoniker).AssemblyAttributes$(DefaultLanguageSourceExtension)'))</TargetFrameworkMonikerAssemblyAttributesPath>
  </PropertyGroup>

  <ItemGroup Label = "SourceLink issues 572">
        <EmbeddedFiles Include="$(GeneratedAssemblyInfoFile)"/>
        <EmbeddedFiles Include="$(GeneratedGlobalUsingsFile)"/>
        <EmbeddedFiles Include="$(TargetFrameworkMonikerAssemblyAttributesPath)"/>
  </ItemGroup>

  <PropertyGroup Label="MinVer">
    <MinVerTagPrefix>v</MinVerTagPrefix>
  </PropertyGroup>

    <PropertyGroup Label="C#">
        <LangVersion>latest</LangVersion>
    </PropertyGroup>

  <PropertyGroup>
    <Deterministic>true</Deterministic>
    <ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
    <PublishRepositoryUrl>true</PublishRepositoryUrl>
    <EmbedUntrackedSources>true</EmbedUntrackedSources>
 <AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1">
        <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
        <PrivateAssets>all</PrivateAssets>
    </PackageReference>
  </ItemGroup>

  <ItemGroup  Label="MinVer">
    <PackageReference Include="MinVer" Version="4.2.0">
        <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
        <PrivateAssets>all</PrivateAssets>
    </PackageReference>
  </ItemGroup>

</Project>

Configuration Consumer

launch.json

"justMyCode": false,
"symbolOptions": {
    "searchMicrosoftSymbolServer": true,
    "searchNuGetOrgSymbolServer": true,
    },
"sourceLinkOptions": {
    "*": { "enabled": false}
    },
"suppressJITOptimizations": true,
"requireExactSource": false

Error Message

// Le fichier source '\_\Ginkoia.Api.Common\Services\CollectionServicesExtensions.cs' est
// introuvable sur cet ordinateur. Le fichier PDB du module de ce fichier source contient
// des informations permettant de télécharger le fichier source via Source Link, mais la
// requête du débogueur visant à télécharger ce fichier source n'a pas abouti.
// 
// Échec de la requête avec le code d'état HTTP 404 (NotFound).
// 
// URL à partir de laquelle le fichier source va être téléchargé :
// https://raw.githubusercontent.com/********/Ginkoia.API.Common/055ebe11ac4755d397bdc36423f41c8a9f21a6f1/Ginkoia.Api.Common/Services/CollectionServicesExtensions.cs
// 
// Pour plus d'informations sur Source Link et VS Code, consultez :
// https://aka.ms/VSCode-DotNet-SourceLink

Acces by GitHub Web interface

https://raw.githubusercontent.com/********/Ginkoia.API.Common/055ebe11ac4755d397bdc36423f41c8a9f21a6f1/Ginkoia.Api.Common/Services/CollectionServicesExtensions.cs?token=xxxxx

I don't know where my mistake is. Please help me

DavyLGinkoia commented 2 years ago

Same probleme as issue 635

DavyLGinkoia commented 2 years ago

For information I caught the request sent by sourcelink and there is no authentication

GET /*****/Ginkoia.API.Common/3a6f2a068a7d8d652fe4a1af513778f27c82cff4/Ginkoia.Api.Common/Services/CollectionServicesExtensions.cs HTTP/1.1

No Proxy-Authorization Header is present.
No Authorization Header is present.

I try the same request with postman and it's work

I try to change without succes

<RepositoryUrl>https://github.com/***********/Ginkoia.API.Common</RepositoryUrl>
to 
<PrivateRepositoryUrl>https://github.com/***********/Ginkoia.API.Common</PrivateRepositoryUrl>

How i can pass the basic authentication ?

tmat commented 2 years ago

@chuckries

DavyLGinkoia commented 2 years ago

For information i try with VS2022 Comunity a all works fine

StephenCleary commented 2 years ago

I have this same problem with GHE. VS produces this output (in the "Navigate to External Sources" output) if I F12 into a nuget with source-linked pdb:

Navigating to symbol 'SYMBOL' from 'DLL'.
Symbol found in assembly path 'C:\Users\stephen.cleary\.nuget\packages\PACKAGE\VERSION\lib\TARGET\DLL.dll'
Found PDB file at 'C:\Users\stephen.cleary\.nuget\packages\PACKAGE\VERSION\lib\TARGET\DLL.pdb'
git-credential-manager-core.exe: Could not obtain credentials. Process failed with exit code -1.
ERROR: The request failed with code 404 : "Not Found". Treating 404 as authentication failure. Some services return 404 instead of 401 for authentication failures.

Notes:

The easiest workaround IMO is to install ReSharper and try again. Re# will bring up a notice that allows you to add your Git username and PAT:

Untitled

This creates a Windows Credential:

Untitled2

You can take a similar path by logging in to Visual Studio and under Account Settings ensure that your GitHub Enterprise account is present. This creates a Windows Credential for GitHub for Visual Studio. Or you can add the credential manually. Either of these approaches solved the authentication problem for me.

However, even with these credentials, VS-without-ReSharper will sometimes work but sometimes not. I believe it only gives 2 or 3 seconds for the source to be found and downloaded, which is not fast enough in my situation. In these situations I get The operation was canceled. or A task was canceled. in my Navigate to External Sources output. ReSharper does not have the same timeout problems.

TL;DR: Use ReSharper. VS doesn't really work well in this scenario (yet). Oh, and submit feedback to the VS team, since it's pretty clearly their problem and not a problem in this repository.