Publish Profile Encryption

爱⌒轻易说出口 提交于 2019-12-25 01:33:23

问题


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!! 

Thank You in advance.

<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>

回答1:


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

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

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- Update your profiles for using this Build Configuration.

Hope this helps.



来源:https://stackoverflow.com/questions/47538285/publish-profile-encryption

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!