Suppose I have built a (C++ or .NET) library from source, so I have source code and PDB files locally, but I don't want to modify the library code to e.g. add /SOURCELINK
or a nuget package.
Is it possible to run sourcelink on the command-line to link those existing PDBs to the git repository?
If you have not modified the source code, then yes, kind of, but you must manually download the .PDB files and include them in your compiled output folder, and upload it to git with the proper .json file conforming to the following schema:
The JSON configuration file contains a simple mapping of local file path to URL where the source file can be retrieved via http or https. A debugger would retrieve the original file path of the current location from the PDB, look this path up in the Source Link map, and use the resulting URL to download the source file.
The schema of the json file is:
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "SourceLink",
"description": "A mapping of source file paths to URLs",
"type": "object",
"properties": {
"documents": {
"type": "object",
"minProperties": 1,
"additionalProperties": {
"type": "string"
},
"description": "Each document is defined by a file path and a URL. Original source file paths are compared
case-insensitively to documents and the resulting URL is used to download source. The document
may contain an asterisk to represent a wildcard in order to match anything in the asterisk's
location. The rules for the asterisk are as follows:
1. The only acceptable wildcard is one and only one '*', which if present will be replaced by a relative path.
2. If the file path does not contain a *, the URL cannot contain a * and if the file path contains a * the URL must contain a *.
3. If the file path contains a *, it must be the final character.
4. If the URL contains a *, it may be anywhere in the URL."
}
},
"required": ["documents"]
}
Unfortunately, I have not found a command line utility for creating these files beyond the disallowed /SOURCELINK
in the original post.