Change App.config during installation

我的未来我决定 提交于 2019-12-04 05:33:39

In a similar project, I'm doing it in a slightly different way:

  1. Ship your setup with no "myapp.exe.config" file.
  2. Instead, ship a "myapp.exe.config.default" file that contains placeholders like "{Branch}".
  3. During setup, load the "myapp.exe.config.default" as a string into memory.
  4. Replace the placeholders with the actual values (e.g. your "30000").
  5. Write the replaced string as the actual file "myapp.exe.config".
  6. Bonus: Before writing the config check whether any existing config file is present and copy it as a backup to keep the previous version.

This runs pretty smooth in our applications.

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