GitLink icon indicating copy to clipboard operation
GitLink copied to clipboard

Embed source files that do not belong to the git repo

Open AArnott opened this issue 8 years ago • 10 comments

When the build itself generates code, that code won't be in the git repo but may still be valuable to step through. This code can be embedded in the PDB such that (a future version of) the VS debugger can display it.

@tmat: any pointers to docs on how we can add sources files to the PDB?

Project owners: I'm willing to fix this.

AArnott avatar Nov 18 '16 21:11 AArnott

csc task/command line:

 /embed                    Embed all source files in the PDB.
 /embed:<file list>        Embed specfic files the PDB

tmat avatar Nov 18 '16 21:11 tmat

@nguerrera

AArnott avatar Nov 19 '16 03:11 AArnott

@tmat that switch approach works if your code generators participate and prepare the msbuild items before the compiler is invoked. Does the Csc task accept a parameter for this, and do the msbuild C# targets pass that parameter in from an item list already?

For the person building the PDB, I guess post-compilation adding source files to it is possible, but perhaps we can settle on unadvisable if there is a preferred path which is the above approach. But I'd love to learn how to do that.

AArnott avatar Nov 21 '16 05:11 AArnott

Also, what is this /sourcelink: switch I see? I can't find docs on it. Does it obsolete post-compilation PDB tools such as this one?

AArnott avatar Nov 21 '16 05:11 AArnott

@(EmbeddedFiles) get passed to /embed

nguerrera avatar Nov 21 '16 05:11 nguerrera

@AArnott Yes, it does. https://github.com/dotnet/roslyn/issues/12759

tmat avatar Nov 21 '16 06:11 tmat

Just pointing out again (see also https://github.com/dotnet/roslyn/pull/15256#discussion_r88746143) that /embed is currently only supported if the pdb being produced is portable.

The design for embedded source accounted for Windows PDBs as well, but due to some funding changes, the testing was not completed for VS 2017 RC. Getting it to work with Windows PDBs is tracked by https://github.com/dotnet/roslyn/issues/13707, which is pushed out passed VS 2017 RTM.

https://github.com/dotnet/roslyn/pull/13138 has a code complete implementation of /embed working for Windows PDBs if you want to play with it sooner.

nguerrera avatar Nov 21 '16 17:11 nguerrera

/embed is currently only supported if the pdb being produced is portable.

Can you educate me on the downside to that? What prevents everyone from compiling portable pdb's? Is it that only certain debuggers support them? Which ones?

AArnott avatar Nov 22 '16 05:11 AArnott

A bit late to join the party, but this is for after the changes by @AArnott , right?

GeertvanHorrik avatar Nov 23 '16 15:11 GeertvanHorrik

That's how I'm seeing it, yes. And in fact, the way the discussion is going, it may not really be a gitlink 'feature'. Rather, simply emitting warnings for files that aren't in the git repo with a recommendation that they arrange to add their generated files to the @(EmbeddedFiles) item list.

AArnott avatar Nov 23 '16 19:11 AArnott