Search code examples
.netmsbuildstrongnamesn.exe

cannot sign assembly using sn.exe in msbuild script file


I used this code to sign assembly in msbuild script file:

<Exec Command="$(SNexePath)\sn.exe -R $(TargetPath)\Exchange.dll" />

but I've got error: error MSB3073: The command "C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\sn.exe -R D:\Program\Exchange.dll" exited with code 1

After that I executed same command in Visual Studio command prompt to check if it will work with command prompt or not:

C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\sn.exe -R D:\Program\Exchange.dll but after that I've got this message:

Option -R takes 2 arguments

How to correctly sign assembly in msbuild script file?


Solution

  • To sign assembly you need to give sn.exe both assembly and keyfile:

    <Exec Command="$(SNexePath)\sn.exe -R $(TargetPath)\Exchange.dll Path\To\Keyfile.snk" />