I have an app.config file that (initially) looks like this:
<configuration>
<appSettings>
<add key="MySetting" value="[MySetting]" />
</appSettings>
</configuration>
I need a way to update '[MySetting]' value in pre-build event without copying another .config file into this one. Is there any way to do that?
you can use powershell script that will replace the 'templates' with desired values.
[IO.File]::ReadAllText("$DIR\app.template.config").Replace("[MySetting]", $MySettingValue) | Set-Content "$DIR\app.config"
Update
If you want to mix build environments - linux and windows, make sure that you will have a script that either run on both systems (ie python) or use powershell or (xor ^_^) sed but make it runnable from both systems using cmd label that is ignored on linux - for more info see ie Cross-platform command line script (eg .bat and .sh)
example:
:; someLinuxCommand.sh
:; exit
windowsCommandHere.cmd
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.