发布配置文件加密 [英] Publish Profile Encryption

查看:89
本文介绍了发布配置文件加密的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想加密我的连接字符串和应用程序设置.目前,我有多个发布配置文件,每个配置文件都有其变换.

I want to encrypt my connection string and app settings. Currently, I have multiple publish profiles with each profile having it's transform.

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>

推荐答案

如果无法完成该工作,则可以尝试以下步骤:

If you cannot make that work, you can try these steps:

1-创建一个新的构建配置(在调试/发布"菜单下,转到"配置管理器".,然后在配置列上创建一个新配置).

1- Create a new Build configuration (under Debug/Release menu go to Configuration manager.. then on the Configuration column create a New configuration).

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

2- On a Postbuild event (Project properties > Build events > Post build event command line) add something like:

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

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

3- Update your profiles for using this Build Configuration.

希望这会有所帮助.

这篇关于发布配置文件加密的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆