Octopus Post 部署加密应用程序设置

Octopus Post Deploy Encrypt Application Settings

有谁知道是否有教程介绍如何在 PostDeploy 中对 ApplicationSettings 进行加密。ps1 使用 Octopus 进行部署时?或者可以给我一个 powershell 脚本应该是什么样子的例子吗?

编辑:

这是我要加密的 App.config 区域的示例:

 <?xml version="1.0"?>
  <configuration>
    <applicationSettings>
        <SmsSurveysWeb.Properties.Settings>
            <setting name="WebSiteUrl" serializeAs="String">
                <value>http://myurl</value>
            </setting>
            <setting name="SmsSurveysConnectionString" serializeAs="String">
               <value>Database=MyDatabase;Data Source=MySource;User ID=MyUser;Password=MyPassword;Application Name=My Application;</value>
            </setting>
        </SmsSurveysWeb.Properties.Settings>
    </applicationSettings>
 </configuration>

我明白了。我需要使用 OpenMappedExeConfiguration 方法。

$configurationFileMap = New-Object -TypeName System.Configuration.ExeConfigurationFileMap
$configurationFileMap.ExeConfigFilename = ".\Web.config"

$c =[System.Configuration.ConfigurationManager]::OpenMappedExeConfiguration($configurationFileMap, [System.Configuration.ConfigurationUserLevel]"None")
$s=$c.GetSection("applicationSettings/ProjectName.Properties.Settings")

$s.SectionInformation.ProtectSection("DataProtectionConfigurationProvider")
$c.Save()