0

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

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

有什么办法让xbuild模仿 Visual Studio 的 pdb 复制行为?

4

1 回答 1

2

现在我可以通过编写这个脚本来实现我想要的,它还将 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

于 2015-12-09T08:21:40.923 回答