When using NuGet packages which include symbols, Visual Studio is copying these debug symbol files (*.pdb
) right into the bin output folder.
This does not happen when using NuGet and xbuild
on Linux using Mono - the pdb
files are not copied to the output folder.
Is there any way to let xbuild
mimic the pdb-copying behavior of Visual Studio?
For now I was able to achieve what I wanted by writing this script, which also converts the pdb files to mdb (requires pdb2mdb
to be in the path):
#!/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
Usage:
copy_pdb_from_nuget.sh packages MyProject.csproj ./bin