GitTools / GitLink

Making .NET open source accessible!
MIT License
555 stars 86 forks source link

What am I doing wrong? #140

Open phatcher opened 7 years ago

phatcher commented 7 years ago

Steps to reproduce

  1. Followed the instruction on the getting started page, adding the NuGet package to each project
  2. Build the project

Platform: .NET version: 4.5

Expected behaviour

Should have the symbols replaced

Actual behaviour

Symbol still pointing locally

Code is available at https://github.com/phatcher/Meerkat.Security

Also some advice on how incorporate into a FAKE script without adding the NuGet package would be nice.

v-jacai commented 7 years ago

Do you see the *.srcsrv file in the folder? If so, you can open the symbol file in the Notepad.

phatcher commented 7 years ago

No, I can see that I have gitlink in the packages as a developmentDependency and a binary reference in the project., but that's it - there's no change to the project's build targets so I don't see how it's going to achieve anything.

gep13 commented 7 years ago

@phatcher can you confirm which NuGet Package you have installed?

Sounds like you have added this one:

https://www.nuget.org/packages/gitlink/

Which contains the exe and pdb, where as I think you want this one:

https://www.nuget.org/packages/gitlinktask/

which contains the exe, dll, pdb and associated targets file.

phatcher commented 7 years ago

I do have gitlink - that's what the front page says to install.

Just tried to use gitlinktask and it wouldn't install into my project (which is .NET 4.5) - I notice the package does not have a lib folder

install-package : Could not install package 'gitlinktask 2.4.1'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.5', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author. At line:1 char:1

gep13 commented 7 years ago

The issue that you are seeing is that the readme in the develop branch (which is the default branch) tells you about the new, soon to be released version of GitLink, and not the one that is currently pushed to nuget.org, i.e. 2.4.1.

I would point you here:

https://github.com/GitTools/GitLink/tree/master

For information about the GitLink and GitLinkTask packages which are currently pushed to NuGet.org.

phatcher commented 7 years ago

Ah thanks, hadn't noticed that I was on the develop branch, so at the moment it has to process the source and the new one will process the pdb directly?

gep13 commented 7 years ago

I would need @GeertvanHorrik or @AArnott to confirm that one. Personally, I run GitLink through a Cake task:

https://github.com/cake-contrib/Cake.Recipe/blob/develop/Cake.Recipe/Content/gitlink.cake#L9

So I haven't used the approach that you are describing, I just know about it's existence 😄

AArnott commented 7 years ago

@phatcher: yes, the gitlink in the develop branch can just be given the pdb file and it will do all the work without a bunch of the other integration with MSBuild. If you want to try out what's in GitLink's develop branch, since we don't yet have a nuget package of it released, you could temporarily install the PdbGit nuget package instead of GitLink (which is basically GitLink's develop branch at the moment) and see if that "just works" for you. Either way, that can be good feedback for GitLink going forward.

phatcher commented 7 years ago

@AArnott I'll have a go at that and get back to you - will make it easier to integrate into my Fake build script as it would just be another task after the tests but before the nuget pack

AArnott commented 7 years ago

Why add a task at all? So long as you're using MSBuild to compile your projects, PdbGit does it as part of that.

phatcher commented 7 years ago

I need it as a separate task as it operates on the pdbs in the build directory, so I do the task after the tests are run successfully but before the pack.

You end up with something like...

Target "SourceLink" (fun _ ->
    let PdbGit = (fun pdbFile -> 
        let result = ExecProcess(fun info ->
            info.FileName <- "./packages/build/pdbgit/tools/pdbgit"
            info.Arguments <- pdbFile)(TimeSpan.FromMinutes 2.0)
        if (result <> 0) then
            failwithf "pdbgit returned with non-zero exit code"
    )

    PdbGit (buildDir + "/MyAssembly.pdb")
)

I notice that it only takes a single file i.e. it won't accept a filespec *.pdb which might be a useful change, though I suppose you'd have to be careful specifying it so you don't process for third-party assemblies

AArnott commented 7 years ago

@phatcher what you're doing and asking for makes sense. But I still don't understand why you can't do it as part of your msbuild. You say you rewrite the PDB after tests pass, but why not do it when the PDB is first created? In the future, Roslyn compilers will support passing data to the compiler so that the PDB has source server support without rewriting, which would mean this is all front-loaded, very similar to pdbgit doing it directly after compilation. So what is your concern with doing this write after compilation?

phatcher commented 7 years ago

@AArnott Sorry I think I was misunderstanding - couldn't see how I can pass this as an argument to MSBuild.

Do I basically install this as a solution-level package and it adds targets to the solution to do the source indexing?

AArnott commented 7 years ago

Almost. Install the package to each of your individual projects.

phatcher commented 7 years ago

Thanks