Force regeneration of Settings.settings file after change in app.config

后端 未结 2 1553
盖世英雄少女心
盖世英雄少女心 2021-01-23 16:32

I have an automated build process that sets up the application for a specified mode (e.g. Dev, uat, live). Depending on this mode I want to update Connection Strings to the rele

相关标签:
2条回答
  • 2021-01-23 16:39

    Yeah, you're doing it backwards. The IDE generates the .config file contents from the settings you define in the Settings designer. That doesn't work the other way around. If getting the connection string valid straight from the build is important then set the default in the Settings designer. Or don't store it in a setting.

    0 讨论(0)
  • 2021-01-23 16:43

    There is a way to override the settings.settings :

    Project.Properties.Settings.Default["ConnectionString"] = ConfigurationManager.ConnectionStrings["Project.Properties.Settings.ConnectionString"].ConnectionString;
    
    0 讨论(0)
提交回复
热议问题