So I’m using RM with powershell scripts to deploy a simple web app. One of my scripts was modifying the Web.config file with Out-File. Everything seemed to be working just fine except after the deployment, I got a 500 server error.
The Web.config file looked perfectly fine, but after some excruciating analysis, I finally figured out that Out-File was writing the config file in UTF-8 with the BOM (Byte-Order Mark, three chars placed at the beginning of the file: 0xEF, 0xBB, 0xBF) . What I needed was some way to output the file with no BOM. Here is what I did:
$content = Get-Content $SomePath
$Utf8NoBomEncoding = New-Object System.Text.UTF8Encoding($False)
[System.IO.File]::WriteAllLines($ConfigFile, $content, $Utf8NoBomEncoding)
Voila, RM deployed my app, my powershell modified my config file without the BOM and everything worked just fine.