有没有人知道在使用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>
答案 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()