サーバー上の web.config の connectionStrings セクションを暗号化し、この暗号化されたセクションを web.[CONFIGURATION_FOR_SERVER].config 変換ファイルに追加します。キーは、元の web.config の connectionStrings 部分をこの新しい暗号化された値に置き換えることを示す最初の行です。公開先のサーバーごとに新しい変換ファイルが必要になります。Visual Studio は警告 (エラーではない) を発生させます。
Warning 15 The element 'connectionStrings' has invalid child element 'EncryptedData' in namespace 'http://www.w3.org/2001/04/xmlenc#'. List of possible elements expected: 'add, remove, clear'. C:\DevTFS\YourProject\Web.Stage.config 14 6 YourProject
この変換ファイルの形式について - これを回避するための正しい構文が見つからないので、提案を受け付けていますが、それでも機能するので満足しています。これに関する完全なブログ エントリ: http://randomdotnetnuggets.blogspot.com.au/2013/05/publishing-encrypted-connection-strings.html
<connectionStrings configProtectionProvider="RsaProtectedConfigurationProvider" xdt:Transform="Replace">
<EncryptedData Type="http://www.w3.org/2001/04/xmlenc#Element"
xmlns="http://www.w3.org/2001/04/xmlenc#">
<EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#tripledes-cbc" />
<KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
<EncryptedKey xmlns="http://www.w3.org/2001/04/xmlenc#">
<EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-1_5" />
<KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
<KeyName>Rsa Key</KeyName>
</KeyInfo>
<CipherData>
<CipherValue>t8p7aOZTjMo...zE6FAAI=</CipherValue>
</CipherData>
</EncryptedKey>
</KeyInfo>
<CipherData>
<CipherValue>Vy1TZWY8....ic+Qg6T7U</CipherValue>
</CipherData>
</EncryptedData>