Mono-xbuild:将调试符号从NuGet软件包文件夹复制到输出bin文件夹中



使用包含符号的NuGet包时,Visual Studio会将这些调试符号文件(*.pdb)直接复制到bin输出文件夹中。

在使用Mono的Linux上使用NuGet和xbuild时不会发生这种情况——pdb文件不会复制到输出文件夹中。

有什么方法可以让xbuild模仿Visual Studio的pdb复制行为吗?

现在,我可以通过编写这个脚本来实现我想要的,这个脚本还将pdb文件转换为mdb(需要pdb2mdb在路径中):

#!/bin/bash
PACKAGE_PATH_SUBSTR=$1
CSPROJ=$2
OUT_DIR=$3
# 1.) search for file references in the .csproj file with the help of the partial nuget package path name
# 2.) replace .dll with .pdb
# 3.) replace all left <HintPath> and </HintPath> tags
# 4.) replace windows path separators () with unix ones (/)
PDB_CANDIDATES=$(grep -oP '<HintPath>(.*'${PACKAGE_PATH_SUBSTR}'.*.dll)</HintPath>' $CSPROJ | sed -e "s/.dll/.pdb/g" | sed -e 's/<(/){0,1}HintPath>//g' | sed -e 's/\///g' )
# loop through all possibly existent pdb file names
for item in ${PDB_CANDIDATES}; do
        # check if the pdb file candidate really exists
        if [ -e $item ]; then
                # pdb exists, copy it to the bin output path
                cp -v ${item} ${OUT_DIR}
                # convert pdb to mdb
                pdb2mdb ${OUT_DIR}/$(basename $(echo $item | sed -e 's/.pdb/.dll/g') )
                # if you wanted you could delete the pdb file now.
        fi
done

用法:copy_pdb_from_nuget.sh packages MyProject.csproj ./bin

相关内容

最新更新