【问题标题】:Publish Profile Encryption发布配置文件加密
【发布时间】:2017-11-28 18:12:09
【问题描述】:

我想加密我的连接字符串和应用设置。目前,我有多个发布配置文件,每个配置文件都有它的转换。

Below is my pubxml file code but for some reason my target with exec command is not getting triggered. Can some one familiar with the subject matter please help!! 

提前谢谢你。

<project toolsversion="4.0" xmlns="http://schemas.microsoft.co...">
    <propertygroup>
    <webpublishmethod>FileSystem</webpublishmethod>
    <lastusedbuildconfiguration>Release</lastusedbuildconfiguration>
    <lastusedplatform>Any CPU</lastusedplatform>
    <siteurltolaunchafterpublish/>
    <launchsiteafterpublish>True</launchsiteafterpublish>
    <excludeapp_data>False</excludeapp_data>
    <publishurl>e:\Test_Deployment</publishurl>
    <deleteexistingfiles>False</deleteexistingfiles>
    <msdeployenablewebconfigencryptrule>true</msdeployenablewebconfigencryptrule>

    </propertygroup>
    <target name="CustomPostPublishActions" aftertargets="MSDeployPublish">
    <exec command="C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe -pe appSettings -app $(publishUrl)/MyProj"/>
    <exec command="C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe -pef connectionStrings $(publishUrl) -prov MyProviderKey"/>
    </target>

    </project>

【问题讨论】:

    标签: c# asp.net encryption visual-studio-2015 publish-profiles


    【解决方案1】:

    如果您无法做到这一点,您可以尝试以下步骤:

    1- 创建一个新的 Build 配置(在 Debug/Release 菜单下转到 Configuration manager.. 然后在 Configuration 列上创建一个新配置)。

    2- 在构建后事件(项目属性 > 构建事件 > 构建后事件命令行)上添加如下内容:

    if "$(ConfigurationName)" == "MyNewBuildConfiguration"(
    execute commands in here
    )
    

    3- 更新您的配置文件以使用此构建配置。

    希望这会有所帮助。

    【讨论】:

    • 感谢您的回复。我有多个配置文件,所以我需要在 exec 命令中保留 $publishurl 变量。我该怎么做?
    猜你喜欢
    • 1970-01-01
    • 2013-08-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-14
    • 1970-01-01
    • 1970-01-01
    • 2015-09-18
    相关资源
    最近更新 更多