Welcome again to another BizTalk Server Best practices, Tips, and Tricks blog post! In my previous blog posts, I discussed some essential tips and tricks for BizTalk Server administrators:
And for BizTalk Server Developers:
Today I’m going to speak about another critical Best practice, Tips and Tricks for BizTalk Server developers: How to configure Visual Studio BizTalk Server Signing Properties easily.
In my previous tip, I provided a PowerShell script to fix or configure the Deployment Properties of a BizTalk project. However, before deploying a BizTalk project, we must first strongly sign the assemblies involved in the project to give them a unique identification for allowing them to be installed into the GAC.
GAC (Global Assembly Cache) is a machine code cache that stores assemblies that can be shared by multiple applications on the computer. These assemblies need to be strongly signed to have unique identification in the GAC.
A strong-named assembly provides several security benefits:
While deploying a BizTalk solution, Visual Studio first builds the assemblies. The deployment process requires that each assembly is strongly signed. You can strongly sign your assemblies by associating the project with a strong name assembly key file.
The task of strongly signing an assembly is a straightforward and easy task – you can know more about it here – but now imagine that you have almost 200 projects inside a unique Visual Studio Solution! It will be an insane and time-consuming operation.
With this PowerShell script, you will be able to parameterize all projects inside a Visual Studio Solution running a single line of code and avoid spending numerous hours doing this task manually.
So, is there a better and fast way?
Yes, there is, and that is why I like PowerShell! We can easily script these tasks with a simple PowerShell script and reuse it for all projects.
For example, with this PowerShell: Fixing BizTalk Project Signing Properties with PowerShell, you can sign all projects inside a Visual Studio Solution running a single line of code and avoid spending numerous hours doing this task manually.
$allPropertyGroup = $xml .Project.PropertyGroup
foreach ( $node in $allPropertyGroup )
{
if ( $node .AssemblyOriginatorKeyFile -ne $null )
{
$addNewKeyNodeFlag = $false ;
$node .AssemblyOriginatorKeyFile= $keyName ;
}
if ( $node .SignAssembly -ne $null )
{
$addNewSignNodeFlag = $false ;
$node .SignAssembly= $true ;
}
}
if ( $addNewKeyNodeFlag -eq $true )
{
$childItemGroup = $xml .CreateElement( "PropertyGroup" , $xdNS )
$childNone = $xml .CreateElement( "AssemblyOriginatorKeyFile" , $xdNS )
$childNone .AppendChild( $xml .CreateTextNode( $keyName ));
$childItemGroup .AppendChild( $childNone )
$xml .Project.InsertBefore( $childItemGroup , $xml .Project.ItemGroup[0])
}
if ( $addNewSignNodeFlag -eq $true )
{
$childItemGroup = $xml .CreateElement( "PropertyGroup" , $xdNS )
$childNone = $xml .CreateElement( "SignAssembly" , $xdNS )
$childNone .AppendChild( $xml .CreateTextNode( $true ));
$childItemGroup .AppendChild( $childNone )
$xml .Project.InsertBefore( $childItemGroup , $xml .Project.ItemGroup[0])
}
$allItemGroup = $xml .Project.ItemGroup.None;
foreach ( $node in $allItemGroup )
{
if ( $node .Include -eq $keyName )
{
$addKeyToSolutionFlag = $false ;
}
}
if ( $addKeyToSolutionFlag -eq $true )
{
$childItemGroup = $xml .CreateElement( "ItemGroup" , $xdNS )
$childNone = $xml .CreateElement( "None" , $xdNS )
$childNone .SetAttribute( "Include" , $keyName )
$childItemGroup .AppendChild( $childNone )
$xml .Project.InsertBefore( $childItemGroup , $xml .Project.Import[0])
} |
THIS POWERSHELL IS PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND.
You can download Visual Studio: Fixing BizTalk Project Signing Properties with PowerShell from GitHub here.
Stay tuned for the following BizTalk Server Best practices, Tips, and Tricks.