Currently, my application automatically encrypts its own App.config file the first time the application is launched.
I'm using the ConfigurationManager
class as demonstrated in this article:
Now I want the App.config to already be encrypted before the application launches the first time.
Reason why is that I have added an installer to my solution and I don't want an installer that drops an un-encrypted App.config. I want the process to be automated.
(only thing I came up with so far is attaching an .exe to the Post-Build Event, but isn't there a more straight forward way?)
First Option: Using built in MSBuild Exec Task execute own utility program which is able to encrypt configuration file.
Second Option: Own MSBuild task
I believe you can write a simple MSBuild
Task which will find App.Config
file and then encrypt it whilst Solution build.
EncryptConfig.targets
csproj
file by <Import Project="EncryptConfig.targets" />
DependsOnTargets
for standard AfterBuild
targets in csproj: <Target Name="AfterBuild" DependsOnTargets="EncryptConfig.targets" />
4) Write own task and execute it in EncryptConfig.targets
How-to write own task:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With