project-system icon indicating copy to clipboard operation
project-system copied to clipboard

Add SourceLink

Open KirillOsenkov opened this issue 4 years ago • 15 comments

Microsoft.VisualStudio.ProjectSystem.Managed.dll doesn't appear to be SourceLinked. Would be super nice to add SourceLink for easier debugging.

KirillOsenkov avatar Nov 01 '19 19:11 KirillOsenkov

@tmat can you point me to the targests in arcade that do sourcelink? I think the easiest way forward is to copy those

jmarolf avatar Nov 01 '19 20:11 jmarolf

@jmarolf Is Project System official built done from an internal mirror in dnceng/devdiv? If not, you can just add a package reference to Microsoft.SourceLink.GitHub package. You don't need anything special.

Is there a plan to move PS to Arcade?

tmat avatar Nov 01 '19 20:11 tmat

Is there a plan to move PS to Arcade?

No arcade is all about shipping as part of the .NET Core SDK and has very little support for VSIXes shipping in Visual Studio. As a VS only component 90% of arcade is noise to us

jmarolf avatar Nov 01 '19 23:11 jmarolf

That's not quite true. We use Arcade for Interactive Window repo as well.

tmat avatar Nov 01 '19 23:11 tmat

This repo is using RepoToolset which is no longer maintained. Arcade SDK is.

tmat avatar Nov 01 '19 23:11 tmat

That's not quite true. We use Arcade for Interactive Window repo as well.

Does it build out of dnceng internal like arcade recommends?

jmarolf avatar Nov 01 '19 23:11 jmarolf

Not currently, I was about to switch to that if possible. Whether the official builds build from devdiv or dnceng is orthogonal to Arcade though. Roslyn also builds from devdiv currently.

tmat avatar Nov 01 '19 23:11 tmat

Alright, there is no easy path forward. The existing repotoolset targets set out-of-date properties that interfere with sourcelink. We either need to move off of repotoolset entirely or move to arcade.

I'll leave this decision up to @drewnoakes and @davkean and the @dotnet/project-system team to decide

jmarolf avatar Nov 03 '19 03:11 jmarolf

The existing repotoolset targets set out-of-date properties that interfere with sourcelink. We either need to move off of repotoolset entirely or move to arcade.

Can you point me to this conclusion?

davkean avatar Nov 04 '19 03:11 davkean

@davkean pull down the branch from https://github.com/dotnet/project-system/pull/5620

you will get this build error

         C:\Users\vsagent\.nuget\packages\roslyntools.repotoolset\1.0.0-beta-62705-01\tools\RepositoryInfo.targets(65,5): error : SourceRoot contains duplicate items 'F:\workspace\_work\1\s\' with conflicting metadata 'SourceControl': 'git' and 'Git' [F:\workspace\_work\1\s\setup\ProjectSystemSetup\ProjectSystemSetup.csproj]
         C:\Users\vsagent\.nuget\packages\roslyntools.repotoolset\1.0.0-beta-62705-01\tools\RepositoryInfo.targets(65,5): error : SourceRoot contains duplicate items 'F:\workspace\_work\1\s\' with conflicting metadata 'SourceControl': 'git' and 'Git' [F:\workspace\_work\1\s\setup\ProjectSystemSetup\ProjectSystemSetup.csproj]

looking at the binlog (that is in spanish? I guess we have all the binlogs written to the same place?) you can see the two sourcelink targets interact.

Target Name=GenerateSourceLinkFile Project=Microsoft.VisualStudio.AppDesigner.vbproj
    Target Name=InitializeSourceControlInformation Project=Microsoft.VisualStudio.AppDesigner.vbproj
        Target Name=_InitializeSourceControlInformationFromSourceControlManager Project=Microsoft.VisualStudio.AppDesigner.vbproj
            Target Name=InitializeSourceControlInformationFromSourceControlManager Project=Microsoft.VisualStudio.AppDesigner.vbproj
                Usando la tarea "Microsoft.Build.Tasks.Git.LocateRepository" del ensamblado "C:\Users\vsagent\.nuget\packages\microsoft.build.tasks.git\1.0.0-beta2-19367-01\build\..\tools\net461\Microsoft.Build.Tasks.Git.dll".
                Microsoft.Build.Tasks.Git.LocateRepository
                    Parámetro de tarea:Path=F:\workspace\_work\1\s\src\Microsoft.VisualStudio.AppDesigner
                    Propiedad de salida: _GitRepositoryId=F:\workspace\_work\1\s\.git
                    Propiedad de salida: ScmRepositoryUrl=https://github.com/dotnet/project-system
                    Elementos de salida: 
    SourceRoot=
        F:\workspace\_work\1\s\
                RevisionId=ef53af941c46faeeef456c7995013dfff835416e
                ScmRepositoryUrl=https://github.com/dotnet/project-system
                SourceControl=git
                    Propiedad de salida: SourceRevisionId=ef53af941c46faeeef456c7995013dfff835416e
                Propiedad establecida: RepositoryType=git
            Target Name=_SourceLinkHasSingleProvider Project=Microsoft.VisualStudio.AppDesigner.vbproj
                Usando la tarea "Microsoft.SourceLink.Common.SourceLinkHasSingleProvider" del ensamblado "C:\Users\vsagent\.nuget\packages\microsoft.sourcelink.common\1.0.0-beta2-19367-01\build\..\tools\net461\Microsoft.SourceLink.Common.dll".
                Microsoft.SourceLink.Common.SourceLinkHasSingleProvider
                    Parámetro de tarea:ProviderTargets=;_InitializeGitHubSourceLinkUrl
                    Propiedad de salida: SourceLinkHasSingleProvider=True
            Target Name=TranslateGitHubUrlsInSourceControlInformation Project=Microsoft.VisualStudio.AppDesigner.vbproj
                Usando la tarea "Microsoft.SourceLink.GitHub.TranslateRepositoryUrls" del ensamblado "C:\Users\vsagent\.nuget\packages\microsoft.sourcelink.github\1.0.0-beta2-19367-01\build\..\tools\net461\Microsoft.SourceLink.GitHub.dll".
                Microsoft.SourceLink.GitHub.TranslateRepositoryUrls
                    Parámetro de tarea:RepositoryUrl=https://github.com/dotnet/project-system
                    Parámetro de tarea:
    SourceRoots=
        F:\workspace\_work\1\s\
                RevisionId=ef53af941c46faeeef456c7995013dfff835416e
                ScmRepositoryUrl=https://github.com/dotnet/project-system
                SourceControl=git
                    Parámetro de tarea:
    Hosts=
        github.com
                ContentUrl=https://raw.githubusercontent.com
                    Parámetro de tarea:IsSingleProvider=True
                    Propiedad de salida: ScmRepositoryUrl=https://github.com/dotnet/project-system
                    Elementos de salida: 
    _TranslatedSourceRoot=
        F:\workspace\_work\1\s\
                RevisionId=ef53af941c46faeeef456c7995013dfff835416e
                ScmRepositoryUrl=https://github.com/dotnet/project-system
                SourceControl=git
                Elementos quitados: 
    SourceRoot=
        F:\workspace\_work\1\s\
                RevisionId=ef53af941c46faeeef456c7995013dfff835416e
                ScmRepositoryUrl=https://github.com/dotnet/project-system
                SourceControl=git
                Elementos agregados: 
    SourceRoot=
        F:\workspace\_work\1\s\
                RevisionId=ef53af941c46faeeef456c7995013dfff835416e
                ScmRepositoryUrl=https://github.com/dotnet/project-system
                SourceControl=git
            Target Name=SourceControlManagerPublishTranslatedUrls Project=Microsoft.VisualStudio.AppDesigner.vbproj
                Propiedad establecida: PrivateRepositoryUrl=https://github.com/dotnet/project-system
    Target Name=_GenerateSourceLinkFile Project=Microsoft.VisualStudio.AppDesigner.vbproj
        Target Name=InitializeSourceLinkUrl Project=Microsoft.VisualStudio.AppDesigner.vbproj
            Target Name=InitializeSourceRoot Project=Microsoft.VisualStudio.AppDesigner.vbproj
                Target Name=_InitializeSourceRootFromSourceControl Project=Microsoft.VisualStudio.AppDesigner.vbproj
                    Se omitió la tarea "Error" debido a una condición falsa (False); ('$(GitHeadSha.Length)' != '40') se evaluó como ('40' != '40').
                    Propiedad establecida: _RepositoryRawUrl=
                    Propiedad establecida: _RepositoryRawUrl=https://raw.githubusercontent.com/dotnet/project-system
                    Se omitió la tarea "Error" debido a una condición falsa (False); ('$(_RepositoryRawUrl)' == '') se evaluó como ('https://raw.githubusercontent.com/dotnet/project-system' == '').
                    Elementos agregados: 
    SourceRoot=
        F:\workspace\_work\1\s\
                SourceControl=Git
                SourceLinkUrl=https://raw.githubusercontent.com/dotnet/project-system/ef53af941c46faeeef456c7995013dfff835416e/*
                Se omitió la tarea "Error" debido a una condición falsa (False); ('@(_InvalidSourceRoot)' != '') se evaluó como ('' != '').
                Usando la tarea "MapSourceRoots" del ensamblado "C:\Users\vsagent\.nuget\packages\microsoft.net.compilers\3.3.0-beta3-19415-01\tools\Microsoft.Build.Tasks.CodeAnalysis.dll".
                MapSourceRoots
                    Parámetro de tarea:
    SourceRoots=
        F:\workspace\_work\1\s\
                RepositoryUrl=https://github.com/dotnet/project-system
                RevisionId=ef53af941c46faeeef456c7995013dfff835416e
                ScmRepositoryUrl=https://github.com/dotnet/project-system
                SourceControl=git
        F:\workspace\_work\1\s\
                SourceControl=Git
                SourceLinkUrl=https://raw.githubusercontent.com/dotnet/project-system/ef53af941c46faeeef456c7995013dfff835416e/*
                    Errors
                        C:\Users\vsagent\.nuget\packages\roslyntools.repotoolset\1.0.0-beta-62705-01\tools\RepositoryInfo.targets(65,5): SourceRoot contiene elementos duplicados "F:\workspace\_work\1\s\" con metadatos en conflicto "SourceControl": "git" y "Git" [F:\workspace\_work\1\s\src\Microsoft.VisualStudio.AppDesigner\Microsoft.VisualStudio.AppDesigner.vbproj]
                        C:\Users\vsagent\.nuget\packages\roslyntools.repotoolset\1.0.0-beta-62705-01\tools\RepositoryInfo.targets(65,5): SourceRoot contiene elementos duplicados "F:\workspace\_work\1\s\" con metadatos en conflicto "SourceControl": "git" y "Git" [F:\workspace\_work\1\s\src\Microsoft.VisualStudio.AppDesigner\Microsoft.VisualStudio.AppDesigner.vbproj]
                    Elementos de salida: 
    _MappedSourceRoot=
        F:\workspace\_work\1\s\
                MappedPath=F:\workspace\_work\1\s\
                OriginalItemSpec=F:\workspace\_work\1\s\
                RepositoryUrl=https://github.com/dotnet/project-system
                RevisionId=ef53af941c46faeeef456c7995013dfff835416e
                ScmRepositoryUrl=https://github.com/dotnet/project-system
                SourceControl=git
                SourceLinkUrl=https://raw.githubusercontent.com/dotnet/project-system/ef53af941c46faeeef456c7995013dfff835416e/*
                Elementos quitados: 
    SourceRoot=
        F:\workspace\_work\1\s\
                RepositoryUrl=https://github.com/dotnet/project-system
                RevisionId=ef53af941c46faeeef456c7995013dfff835416e
                ScmRepositoryUrl=https://github.com/dotnet/project-system
                SourceControl=git
        F:\workspace\_work\1\s\
                SourceControl=Git
                SourceLinkUrl=https://raw.githubusercontent.com/dotnet/project-system/ef53af941c46faeeef456c7995013dfff835416e/*
                Elementos agregados: 
    SourceRoot=
        F:\workspace\_work\1\s\
                MappedPath=F:\workspace\_work\1\s\
                OriginalItemSpec=F:\workspace\_work\1\s\
                RepositoryUrl=https://github.com/dotnet/project-system
                RevisionId=ef53af941c46faeeef456c7995013dfff835416e
                ScmRepositoryUrl=https://github.com/dotnet/project-system
                SourceControl=git
                SourceLinkUrl=https://raw.githubusercontent.com/dotnet/project-system/ef53af941c46faeeef456c7995013dfff835416e/*
        Compilando completamente el destino "_GenerateSourceLinkFile".
        No se especificaron archivos de entrada.
        Usando la tarea "GenerateSourceLinkFile" del ensamblado "C:\Users\vsagent\.nuget\packages\microsoft.sourcelink.common\1.0.0-beta2-19367-01\build\..\tools\net461\Microsoft.SourceLink.Common.dll".
        GenerateSourceLinkFile
            Parámetro de tarea:
    SourceRoots=
        F:\workspace\_work\1\s\
                MappedPath=F:\workspace\_work\1\s\
                OriginalItemSpec=F:\workspace\_work\1\s\
                RepositoryUrl=https://github.com/dotnet/project-system
                RevisionId=ef53af941c46faeeef456c7995013dfff835416e
                ScmRepositoryUrl=https://github.com/dotnet/project-system
                SourceControl=git
                SourceLinkUrl=https://raw.githubusercontent.com/dotnet/project-system/ef53af941c46faeeef456c7995013dfff835416e/*
            Parámetro de tarea:OutputFile=F:\workspace\_work\1\s\artifacts\Debug\obj\Microsoft.VisualStudio.AppDesigner\Microsoft.VisualStudio.AppDesigner.sourcelink.json
        Elementos agregados: FileWrites=F:\workspace\_work\1\s\artifacts\Debug\obj\Microsoft.VisualStudio.AppDesigner\Microsoft.VisualStudio.AppDesigner.sourcelink.json

jmarolf avatar Nov 04 '19 04:11 jmarolf

Okay thanks, I think we can handle that without throwing the baby out with the bath water.

davkean avatar Nov 04 '19 04:11 davkean

I suppose some careful over-ridding of targets could make things work. I will freely admit that is beyond me. Look forward to seeing the solution

jmarolf avatar Nov 04 '19 04:11 jmarolf

Putting this back for review since it seems the work on this was being complicated by roslyn-tools. Since we don't use roslyn-tools anymore, this is likely easier to do. Personally, I don't know anything about SourceLink though.

MiYanni avatar Jul 27 '22 21:07 MiYanni

@MiYanni I've set up source link for NuGet packages before so may be able to help if you wanted to pick this up.

https://github.com/dotnet/sourcelink#using-source-link-in-net-projects

One tip is to use NuGet Package Explorer to verify the SourceLink configuration for a .nupkg file. It will tell you if it's configured correctly, which will save a lot of time.

drewnoakes avatar Jul 28 '22 07:07 drewnoakes

yeah it's pretty much

<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />

KirillOsenkov avatar Jul 28 '22 22:07 KirillOsenkov

Assigning this to me since this can help ramp-up in with https://github.com/dotnet/sdk/issues/1458

ocallesp avatar Aug 19 '22 23:08 ocallesp

Yes, please do this. Debugging this assembly from outside the team is no fun without source code.

AArnott avatar Sep 02 '22 18:09 AArnott

I've ended up figuring it out after running into an issue that Andrew actually created. https://github.com/dotnet/sourcelink/issues/492 PR will be created shortly.

MiYanni avatar Sep 08 '22 00:09 MiYanni