[GH-ISSUE #11] Feature request: Update .pdbs to match signed assemblies #7

Closed
opened 2026-02-25 21:30:27 +03:00 by kerem · 5 comments
Owner

Originally created by @Bringer128 on GitHub (Feb 27, 2015).
Original GitHub issue: https://github.com/brutaldev/StrongNameSigner/issues/11

Originally assigned to: @brutaldev on GitHub.

Currently signing assemblies will invalidate any debug symbols that were generated with them, making it impossible to debug using Visual Studio.

I've been able to get away with doing IL debugging using DILE so far, but it would be great to be able to debug against the actual source.

I'm interested in looking into this feature but I can't commit to a timeframe yet so I'm putting this issue here in case someone else feels up to the challenge. :)

Originally created by @Bringer128 on GitHub (Feb 27, 2015). Original GitHub issue: https://github.com/brutaldev/StrongNameSigner/issues/11 Originally assigned to: @brutaldev on GitHub. Currently signing assemblies will invalidate any debug symbols that were generated with them, making it impossible to debug using Visual Studio. I've been able to get away with doing IL debugging using DILE so far, but it would be great to be able to debug against the actual source. I'm interested in looking into this feature but I can't commit to a timeframe yet so I'm putting this issue here in case someone else feels up to the challenge. :)
kerem 2026-02-25 21:30:27 +03:00
Author
Owner
<!-- gh-comment-id:76317095 --> @Bringer128 commented on GitHub (Feb 27, 2015): It looks like Cecil might have the features needed: https://johnhmarks.wordpress.com/2011/01/19/getting-mono-cecil-to-rewrite-pdb-files-to-enable-debugging/ https://github.com/jbevain/cecil/tree/master/symbols/pdb https://github.com/jbevain/cecil/wiki/Debug-symbols
Author
Owner

@brutaldev commented on GitHub (Feb 27, 2015):

If you already have the source and are building the project, why not sign the assemblies using Visual Studio during the build step?

I suppose if PDB files were released with a build of unsigned third party assemblies you may want to update the PDBs as well. In this scenario though it's unlikely you will be able to debug against the source code.

<!-- gh-comment-id:76338574 --> @brutaldev commented on GitHub (Feb 27, 2015): If you already have the source and are building the project, why not sign the assemblies using Visual Studio during the build step? I suppose if PDB files were released with a build of unsigned third party assemblies you may want to update the PDBs as well. In this scenario though it's unlikely you will be able to debug against the source code.
Author
Owner

@bradphelan commented on GitHub (Apr 25, 2016):

To speed things up we don't let visual studio sign the files. What we have is an msbuild task that signs every assembly it finds in the build directory that does not currently have a strong name. This only occurs after the build is complete. This is faster than trying to sign everything found in the nuget packages directory before the build. We have found that some packages have large numbers of sub-directories containing assemblies that are only linked on the condition of obscure rules.

However now the problem is that as we are using brutal to sign our own app assemblies we lose the debugging info. I can trade you the below MSBuild script for adding in the debug info if it is not too much trouble.

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

  <Target 
      Name="StrongName"
      Inputs="$(TargetDir)\$(TargetFileName)"
      Outputs="$(TargetDir).signed\$(TargetFileName)"
      >
      <Exec Command="powershell -command $(MSBuildThisFileDirectory)\strongnamer.ps1  $(TargetDir) $(TargetFileName)" />
  </Target>

  <PropertyGroup>
      <BuildDependsOn>
          $(BuildDependsOn);
          StrongName
      </BuildDependsOn>
  </PropertyGroup>

  <Target
      Name="Build"
      DependsOnTargets="$(BuildDependsOn)"
  />
</Project>

and

param(
[string]$inPath=".\", # the directory containing the build
[string]$targetfileName="a.dll"  # The name of the dll to be registered ( relative to $outpath )
) 


[char[]]$trimChars = '\\' 
function FixTerminatingSlash ($root) { 
    return $root.TrimEnd($trimChars)    
}

$outPath = "$(FixTerminatingSlash(Get-Item $inPath).FullName).Signed\"

echo "InPath is $inPath"
echo "OutPath is $outPath"

#################################################################
# Key generation tool. We generate a new key every time. Why not?
# All we care about is that each addin has a different identity. We
# are not really caring exactly what that identity is.
#################################################################
$keyFile = "$outPathStrongName.snk"
$netfxpath = "C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools"
$sn = "$netfxpath\sn.exe"
echo "NETFX Path is $sn"
&$sn -k 2048 $keyFile

#############################
# Setup tools
#############################

# Strong name assembly signing tool stored in nuget package 
$strongNameSigner = "$(gci $PSScriptRoot\packages\Brutal.Dev.StrongNameSigner.*)\tools\StrongNameSigner.Console.exe"

#############################
# Signing process
# 
# Copies the build to a new directory, signs all dlls and then registers 
# the main dll in the GAC
#############################


robocopy  /mir $inPath $outPath
&$strongNameSigner -in $inPath -out $outPath -k $keyFile

<!-- gh-comment-id:214262555 --> @bradphelan commented on GitHub (Apr 25, 2016): To speed things up we don't let visual studio sign the files. What we have is an msbuild task that signs every assembly it finds in the build directory that does not currently have a strong name. This only occurs after the build is complete. This is faster than trying to sign everything found in the nuget packages directory before the build. We have found that some packages have large numbers of sub-directories containing assemblies that are only linked on the condition of obscure rules. However now the problem is that as we are using **brutal** to sign our own app assemblies we lose the debugging info. I can trade you the below MSBuild script for adding in the debug info if it is not too much trouble. ``` <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Target Name="StrongName" Inputs="$(TargetDir)\$(TargetFileName)" Outputs="$(TargetDir).signed\$(TargetFileName)" > <Exec Command="powershell -command $(MSBuildThisFileDirectory)\strongnamer.ps1 $(TargetDir) $(TargetFileName)" /> </Target> <PropertyGroup> <BuildDependsOn> $(BuildDependsOn); StrongName </BuildDependsOn> </PropertyGroup> <Target Name="Build" DependsOnTargets="$(BuildDependsOn)" /> </Project> ``` and ``` param( [string]$inPath=".\", # the directory containing the build [string]$targetfileName="a.dll" # The name of the dll to be registered ( relative to $outpath ) ) [char[]]$trimChars = '\\' function FixTerminatingSlash ($root) { return $root.TrimEnd($trimChars) } $outPath = "$(FixTerminatingSlash(Get-Item $inPath).FullName).Signed\" echo "InPath is $inPath" echo "OutPath is $outPath" ################################################################# # Key generation tool. We generate a new key every time. Why not? # All we care about is that each addin has a different identity. We # are not really caring exactly what that identity is. ################################################################# $keyFile = "$outPathStrongName.snk" $netfxpath = "C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools" $sn = "$netfxpath\sn.exe" echo "NETFX Path is $sn" &$sn -k 2048 $keyFile ############################# # Setup tools ############################# # Strong name assembly signing tool stored in nuget package $strongNameSigner = "$(gci $PSScriptRoot\packages\Brutal.Dev.StrongNameSigner.*)\tools\StrongNameSigner.Console.exe" ############################# # Signing process # # Copies the build to a new directory, signs all dlls and then registers # the main dll in the GAC ############################# robocopy /mir $inPath $outPath &$strongNameSigner -in $inPath -out $outPath -k $keyFile ```
Author
Owner

@bradphelan commented on GitHub (Apr 27, 2016):

Ok I think I fixed the debug symbols as part of my pull request https://github.com/brutaldev/StrongNameSigner/pull/22

<!-- gh-comment-id:215049442 --> @bradphelan commented on GitHub (Apr 27, 2016): Ok I think I fixed the debug symbols as part of my pull request https://github.com/brutaldev/StrongNameSigner/pull/22
Author
Owner

@brutaldev commented on GitHub (May 5, 2016):

PDB symbol reading and writing added to release 1.8.0.

<!-- gh-comment-id:217248668 --> @brutaldev commented on GitHub (May 5, 2016): PDB symbol reading and writing added to release [1.8.0](https://github.com/brutaldev/StrongNameSigner/releases/tag/v1.8.0).
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/StrongNameSigner#7
No description provided.