Octopus Post Deploy加密应用程序设置

时间:2016-05-06 15:33:54

标签: powershell encryption octopus-deploy

有没有人知道在使用Octopus进行部署时是否有教程显示如何在PostDeploy.ps1中对ApplicationSettings进行加密?或者只是向我展示一下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>

1 个答案:

答案 0 :(得分:0)

我明白了。我需要使用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()