Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here is what I ended up with...</p> <p>I used WiX and DTF to created a managed code Custom Action to encrypt a given section of a config file:</p> <pre><code> public static void EncryptConfig(Session session) { var configPath = session["APPCONFIGPATH"]; var sectionToEncrypt = session["SECTIONTOENCRYPT"]; var fileMap = new ExeConfigurationFileMap(); fileMap.ExeConfigFilename = configPath; var configuration = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None); ConfigurationSection section = configuration.GetSection(sectionToEncrypt); if (!section.SectionInformation.IsProtected) { section.SectionInformation.ProtectSection("DataProtectionConfigurationProvider"); section.SectionInformation.ForceSave = true; configuration.Save(ConfigurationSaveMode.Modified); } } </code></pre> <p>Part of my lack of understanding that prompted this question was not knowing that you can safely create custom actions in managed code using DTF. Documentation is sparse on DTF, but once you get it working, it is great. </p> <p>I found that this only worked if I scheduled the custom action after InstallFinalize.</p> <p>Here is the WiX config to make it happen:</p> <pre><code>&lt;InstallExecuteSequence&gt; &lt;Custom Action="EncryptConfigurationFiles" After="InstallFinalize" /&gt; &lt;/InstallExecuteSequence&gt; &lt;Fragment&gt; &lt;Binary Id="YourProject.CustomActions.dll" SourceFile="$(var.YourProject.CustomActions.TargetDir)$(var.YourProject.CustomActions.TargetName).CA.dll" /&gt; &lt;CustomAction Id="EncryptConfigurationFiles" BinaryKey="YourProject.CustomActions.dll" DllEntry="EncryptConfig" Return="check" /&gt; &lt;/Fragment&gt; </code></pre> <p>These blogs/sites helped me get there and much of the code from above was derived from them:</p> <p><a href="http://geekswithblogs.net/afeng/Default.aspx" rel="nofollow noreferrer">http://geekswithblogs.net/afeng/Default.aspx</a> <a href="http://blog.torresdal.net/2008/10/24/WiXAndDTFUsingACustomActionToListAvailableWebSitesOnIIS.aspx" rel="nofollow noreferrer">http://blog.torresdal.net/2008/10/24/WiXAndDTFUsingACustomActionToListAvailableWebSitesOnIIS.aspx</a> <a href="http://blogs.msdn.com/jasongin/archive/2008/07/09/votive-project-platform-configurations.aspx" rel="nofollow noreferrer">http://blogs.msdn.com/jasongin/archive/2008/07/09/votive-project-platform-configurations.aspx</a></p> <p>@PITADeveloper... Thanks for the response. I found that I did not need to load the assembly to encrypt the config file. </p> <p>If you use this, you should use a try catch and return an ActionResult... The above is pseudo-code.</p> <p>Finally, I'm using the DataProtectionConfigurationProvider. For the RSA Provider, I think there are a couple more hoops to jump through.</p> <p>I hope this helps someone!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload