Tuesday, May 08, 2007

Different signing options depending on configuration


There was a question in the MSBuild newsgroup about the possibility to have different signing settings depending on configuration.


Basically, let's pretend pretend that what we want is the following:



  • Debug: Delay sign using PublicKey.pk

  • Release: Sign using KeyPair.pfx



From within Visual Studio it seems impossible, due to the fact that the configuration boxes are grayed out. All is not lost though, by moving the code signing options into the appropriate configurations (by directly editing the project file).


Debug:


<PropertyGroupCondition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">


<snip/>


<SignAssembly>true</SignAssembly>


<DelaySign> true</DelaySign>


<AssemblyOriginatorKeyFile>PublicKey.pk</AssemblyOriginatorKeyFile>


</PropertyGroup>


Release:


<PropertyGroupCondition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">


<snip/>


<SignAssembly>true</SignAssembly>


<AssemblyOriginatorKeyFile>PrivateKey.pfx</AssemblyOriginatorKeyFile>


</PropertyGroup>


And there you go!


(The obvious? drawback with this method is that the signing behavior isn't directly visible from within the Visual Studio project properties.)




Technorati : ,

No comments: