
Quickly Sign Assemblies #54
Chapter 6, Speed Hacks
|
211
HACK
HACK
#54
Quickly Sign Assemblies Hack #54
Use a macro to sign an assembly with a strong name.
Strongly signing assemblies is one of the more tedious processes that you
have to perform when developing with the .NET Framework. The normal
process to strongly sign an assembly is as follows:
1. Create a .snk file using the sn.exe command prompt utility.
2. Move the .snk file into your project.
3. Point to the .snk file using the
AssemblyKeyFile attribute.
This is the process that you will reproduce using a macro. Follow these steps
to create a macro that will automatically sign assemblies for you:
1. Open the Macro IDE.
2. Create a new module.
3. Copy the following code into the module:
Imports EnvDTE
Imports System.Diagnostics
Imports Microsoft.VisualBasic
Imports Microsoft.VisualBasic.ControlChars
Imports System.Windows
Imports System.Windows.Forms
Imports System
Public Module Module1
Public Class WinWrapper
Implements System.Windows.Forms.IWin32Window
Overridable ReadOnly Property Handle( ) As System.IntPtr Implements _
System.Windows.Forms.IWin32Window.Handle
Get
Dim iptr As New System.IntPtr(DTE.MainWindow.HWnd)
Return iptr
End Get
End Property
End Class
Sub AddStrongNameToProject( )
Dim init_dir, outfile_name, outdirectory As String
Dim stemp, Macroprojname As String
Dim prjSolution As EnvDTE.Project
Dim prjVSProject As VSLangProj.VSProject
Dim openfile ...