First option: Using the built-in MSBuild Exec Task, run your own utility program that can encrypt the configuration file.
Second option: MSBuild's own task
I believe that you can write a simple MSBuild task that will find the App.Config file and then encrypt it during the solution build.
- Create new MSBuild targets, for example
EncryptConfig.targets - Update
csproj file <Import Project="EncryptConfig.targets" /> - Add
DependsOnTargets for standard AfterBuild goals in csproj:
<Target Name="AfterBuild" DependsOnTargets="EncryptConfig.targets" />
4) Write your own task and execute it in EncryptConfig.targets
How to create your own task:
source share