我可以在现有 PDB 文件上手动 运行 SourceLink 吗?

Can I run SourceLink manually on existing PDB files?

假设我已经从源代码构建了一个(C++ 或 .NET)库,所以我在本地有源代码和 PDB 文件,但我不想修改库代码,例如添加 /SOURCELINK or a nuget package

是否可以在命令行上 运行 sourcelink link 那些现有的 PDB 到 git 存储库?

如果您没有修改源代码,那么可以,但是您必须手动下载 .PDB 文件并将它们包含在编译后的输出文件夹中,然后使用正确的方法将其上传到 git .json 文件符合以下架构:

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.

json 文件的架构是:

{
    "$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"]
}

不幸的是,除了原始 post 中不允许的 /SOURCELINK 之外,我还没有找到用于创建这些文件的命令行实用程序。