Just a quick one this, but useful for mature BizTalk solutions, where over time the configuration settings can get confused, meaning Debug configurations building in Release mode, or Deployment configurations building in Development mode. That can cause issues in the build which aren’t obvious, so it’s good to fix up the configurations.

It’s time-consuming in VS or in a text editor, so this bit of PowerShell may come in useful – just substitute your own solution path in the $path variable:

$path = ‘C:\x\y\z\x.y.z.Integration.sln’
$backupPath = [System.String]::Format(‘{0}.bak’, $path)
[System.IO.File]::Copy($path, $backupPath, $True)

$sln = [System.IO.File]::ReadAllText($path)

$sln = $sln.Replace(‘.Debug|.NET.Build.0 = Deployment|.NET’, ‘.Debug|.NET.Build.0 = Development|.NET’)
$sln = $sln.Replace(‘.Debug|.NET.Deploy.0 = Deployment|.NET’, ‘.Debug|.NET.Deploy.0 = Development|.NET’)
$sln = $sln.Replace(‘.Debug|Any CPU.ActiveCfg = Deployment|.NET’, ‘.Debug|Any CPU.ActiveCfg = Development|.NET’)
$sln = $sln.Replace(‘.Deployment|.NET.ActiveCfg = Debug|Any CPU’, ‘.Deployment|.NET.ActiveCfg = Release|Any CPU’)
$sln = $sln.Replace(‘.Deployment|Any CPU.ActiveCfg = Debug|Any CPU’, ‘.Deployment|Any CPU.ActiveCfg = Release|Any CPU’)
$sln = $sln.Replace(‘.Deployment|Any CPU.Build.0 = Debug|Any CPU’, ‘.Deployment|Any CPU.Build.0 = Release|Any CPU’)
$sln = $sln.Replace(‘.Deployment|Mixed Platforms.ActiveCfg = Debug|Any CPU’, ‘.Deployment|Mixed Platforms.ActiveCfg = Release|Any CPU’)
$sln = $sln.Replace(‘.Deployment|Mixed Platforms.Build.0 = Debug|Any CPU’, ‘.Deployment|Mixed Platforms.Build.0 = Release|Any CPU’)
$sln = $sln.Replace(‘.Deployment|.NET.ActiveCfg = Debug|Any CPU’, ‘.Deployment|.NET.ActiveCfg = Release|Any CPU’)
$sln = $sln.Replace(‘.Debug|.NET.ActiveCfg = Deployment|.NET’, ‘.Debug|.NET.ActiveCfg = Development|.NET’)

[System.IO.File]::WriteAllText($path, $sln)

The script creates a backup of the solution file first, and then fixes up all the configs to use the correct builds. It’s a simple search and replace list, so if there are any patterns that need to be added let me know and I’ll update the script.

A RegEx replace would be neater, but when it comes to hacking solution files, I prefer the conservative approach of knowing exactly what you’re changing.