Visual Studio 2010 PFX Code Signing
-
28-02-2021 - |
Question
Sorry if asked before.
Using Visual Studio 2010, I am trying to sign my assemblies with a pfx file so that on build it does the same work as:
signtool sign /f myKey.pfx /p password1 myDll.dll
I have myKey.pfx
set as the strong name key file with 'Sign the assembly' checked in the Project Properties -> Signing tab.
Is this what the Signing tab does or am I trying to use it for something incorrectly.
I'm sure that I am missing something simple what is it?
Edit: just to clarify, I'm looking for alternatives to just adding a Post-Build script to shell the signing.
Solution
Solved using a VB Script in the PreBuild event of my Setup / Deployment Project which ran over all .DLL and .EXE files in the OBJ folders for my project and ran the signtool command (including full path to the SDK)
Sub ShowSubFolders(keyFile, fFolder)
Set objFolder = objFSO.GetFolder(fFolder.Path)
Set colFiles = objFolder.Files
For Each objFile in colFiles
If UCase(objFSO.GetExtensionName(objFile.name)) = "DLL" Or UCase(objFSO.GetExtensionName(objFile.name)) = "EXE" Then
'Wscript.Echo objFile
Dim objResult
Set objShell = WScript.CreateObject("WScript.Shell")
objResult = objShell.Run("""C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\signtool"" sign /f " & keyFile & " """ & objFile & """", 0, True)
End If
Next
For Each Subfolder in fFolder.SubFolders
Call ShowSubFolders(keyFile, Subfolder)
Next
End Sub