I'm trying to create custom configuration depending on the environment and it seems that the best way is to use config transforms. I'm trying to have the transform happen on build (to test locally), but the changes don't seem to work. Any ideas? Also what is the correct way to have "layered config" for environment on asp.net ?
have a go at this for me...
in the web.config (base) add this configuration under the appSettings node
..
<appSettings>
<!-- Application Settings -->
<add key="IsTest" value="true" />
then in then right click the web.config and add a transformation (Add Config Transform) if you haven't already
and in that config you will only add the transform for that case in particular
<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<appSettings>
<add key="IsTest" value="false" xdt:Transform="Replace" xdt:Locator="Match(key)" />
...
If you are debugging from visual studio your try to keep your "Debug" values in the root config, and then lets say if you add a UAT_Release configuration and a UAT_Release transformation then when publishing your application check that the transforms have applied to your web config (these should be merged back in the base config)
for none web.config
transforms ( app.config
for example) these do seem to get transformed based on the build configuration
the underlying issue with web configs is that the "original" can not be preserved because the bin for www uses the .config from the project directly. it is not staged as part of the build so applying the transform would perm change the the web config. (there was an attempt extension to solve this for VS but not seeing one for rider just yet)
my solution was to
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.