2

好的,我愿意接受这个建议:

  • 我正在使用TeamCityMSBuild将 MVC 站点部署到远程服务器。
  • 我还希望在部署时加密我的 Web.Config。
  • 我一直在使用aspnet_regiis.exe推荐行在本地执行此操作,但不确定如何在远程部署中执行此操作。

我目前使用的命令是这样的:

aspnet_regiis.exe -pe "connectionStrings" -app "/" -site "my.IIS.site.name.here"

非常感谢任何帮助...是否有 TeamCity 的“远程命令行”工具(有本地命令行选项),或者这应该是msproj xml文件的一部分吗?还是完全有另一种方法?

4

1 回答 1

1

我在 Application_Start 中添加了一个函数:

public static void EncryptConfig(string path, string configSection)
{
    Configuration config = WebConfigurationManager.OpenWebConfiguration(path);
    ConfigurationSection section = config.GetSection(configSection);

    if (section == null || section.SectionInformation.IsProtected) return;

    section.SectionInformation.ProtectSection("RsaProtectedConfigurationProvider");
    config.Save();
}

例如,路径变量可以用 Request.AbsolutePath 填充,configSection 可以是“connectionStrings”。奇迹般有效!

于 2013-06-13T15:46:16.637 回答