Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Access to pdb with source link on private Azure Repo #5157

Closed
cfeltz34 opened this issue Apr 7, 2022 · 5 comments
Closed

Access to pdb with source link on private Azure Repo #5157

cfeltz34 opened this issue Apr 7, 2022 · 5 comments

Comments

@cfeltz34
Copy link

cfeltz34 commented Apr 7, 2022

New feature

I would like to access to pdb with source link on private Azure Repo

Environment data

dotnet --info output:

SDK .NET (reflétant tous les fichiers global.json) :
 Version:   6.0.101
 Commit:    ef49f6213a

Environnement d'exécution :
 OS Name:     Windows
 OS Version:  10.0.19043
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\6.0.101\

VS Code version: 1.61.0
C# Extension version: 1.3.1

Steps to reproduce

  1. Deploy .Net library on private Azure artifact
  2. With a pipeline¹, deploy PDB with sourcelink (use PublishSymbols@2 task)
  3. Create launch.json² with sourceLinkOptions enabled attribute
    "stopAtEntry": false,
    "justMyCode": false,
    "suppressJITOptimizations": true,
    "sourceLinkOptions": {
    "": { "enabled": true },
    "https://dev.azure.com/MyOrganisation/
    ": { "enabled": true }
    }
  4. Debug project (F5)
  5. Add breakpoint and attempt to enter in library (F11)

Expected behavior

See library source code,
With Visual Studio, the debugger ask me my login / password to authentificate

Actual behavior

Library class file is opened with error : "Request failed with HTTP status code 401 (Unauthorized)."

¹ Azure pipeline

pool:
  vmImage: 'windows-latest'

variables:
  solution: 'MyLibrary.sln'
  buildPlatform: 'Any CPU'
  buildConfiguration: 'Release'
  vstsFeed: '******'
  externalFeedCredentials: '******'

stages:
- stage: CreateNugetPackages
  jobs:
  - job: CreatePackages
    steps:
    - task: NuGetToolInstaller@1

    - task: UseDotNet@2
      displayName: Use .NET 6.0
      inputs:
        packageType: 'sdk'
        version: '6.0.101'

    - task: DotNetCoreCLI@2
      displayName: Restore solution
      inputs:
        command: restore
        projects: $(solution)
        feedsToUse: 'config'
        nugetConfigPath: 'nuget.config'
        externalFeedCredentials: $(externalFeedCredentials)
      
    - task: DotNetCoreCLI@2
      displayName: Build solution
      inputs:
        projects: $(solution)
        arguments: '--configuration $(BuildConfiguration) /p:Copyright="FELTZ Christophe" /p:SourceLinkCreate=true'
  
    - task: DotNetCoreCLI@2
      displayName: "Create package (Nuget)"
      inputs:
        command: 'pack'
        arguments: '--configuration $(buildConfiguration)'
        includesymbols: true
        packagesToPack: 'Solution\MyLibrary.csproj'
        nobuild: true
        versioningScheme: 'off'

    - task: NuGetCommand@2
      displayName: "Push packages (Nuget)"
      inputs:
        command: 'push'
        feedsToUse: 'select'
        publishVstsFeed: $(vstsFeed)
        packagesToPush: '$(Build.ArtifactStagingDirectory)/**/*.*nupkg'
        nuGetFeedType: 'internal'
        versioningScheme: 'off'
        allowPackageConflicts: true

    - task: PublishSymbols@2
      displayName: "Publish Nuget symbols"
      inputs:
        SearchPattern: '**/bin/**/*.pdb'
        SymbolServerType: 'TeamServices'

² launch.json file

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "ExampleApi",
            "type": "coreclr",
            "request": "launch",
            "preLaunchTask": "02_BuildApis-Build ExampleApi",
            "program": "${workspaceFolder}/Examples/Backends/ExampleApi/bin/Debug/net6.0/ExampleApi.dll",
            "args": [],
            "cwd": "${workspaceFolder}/Examples/Backends/ExampleApi/",
            "stopAtEntry": false,
            "justMyCode": false,
            "suppressJITOptimizations": true,
            "sourceLinkOptions": {
                "*": { "enabled": true },
                "https://dev.azure.com/MyOrganisation/*": { "enabled": true }
            },
            "env": {
                "COMPlus_ZapDisable": "1",
                "COMPlus_ReadyToRun": "0",
                "ASPNETCORE_ENVIRONMENT": "Development", 
                "ASPNETCORE_URLS": "http://localhost:49000/"
            }
        }
    ]
}

³ Library csproj file :

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFrameworks>netcoreapp2.1;netcoreapp3.1;net5.0;net6.0</TargetFrameworks>
    <OutputType>Library</OutputType>
    <PackageId>MyLibrary</PackageId>
    <VersionPrefix>1.0.0</VersionPrefix>
    <Version Condition=" '$(BUILD_BUILDNUMBER)' == '' ">$(VersionPrefix)-local</Version>
    <Version Condition=" '$(BUILD_BUILDNUMBER)' != '' ">$(VersionPrefix)-$(BUILD_BUILDNUMBER)</Version>
    <Authors>FELTZ Christophe</Authors>
    <GeneratePackageOnBuild>true</GeneratePackageOnBuild>
    <IsPackable>true</IsPackable>
    <DebugType>embedded</DebugType>
    <IncludeSymbols>true</IncludeSymbols>
    <SymbolPackageFormat>snupkg</SymbolPackageFormat>
    <OpenApiGenerateDocuments>false</OpenApiGenerateDocuments>
    <CheckEolTargetFramework>false</CheckEolTargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.SourceLink.AzureRepos.Git" Version="1.1.1" PrivateAssets="All"/>
  </ItemGroup>

  <ItemGroup>
    ...
  </ItemGroup>
  </Project>
@cfeltz34
Copy link
Author

cfeltz34 commented Apr 7, 2022

See network trace

@cfeltz34
Copy link
Author

cfeltz34 commented Apr 7, 2022

Remark : on Visual Studio, there are an option for "Enable Source Link support" :
"Fall back to Git Credential Manager authentication for all Source Link request.
It's possible to use Git credential to authenticate the pdb request ?

@gregg-miskelly
Copy link
Contributor

This is tracked with the feature: #2071. Thanks for taking the time for such a detailed report!

@cfeltz34
Copy link
Author

cfeltz34 commented Apr 8, 2022

Thank you for your responsiveness, I hope you will find the time to prioritize this change request.

@cfeltz34
Copy link
Author

cfeltz34 commented Apr 8, 2022

Do you think that it's possible to configure vsCode to use Chrome's proxy (and therefore retrieve cookies containing authentication information) ?

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

No branches or pull requests

2 participants