Introduction:
Sometimes, you may encounter a
situation that you want your web.config of staging server to be different with the
web.config of production server. For example, the connection string of staging
server should be different from that of production server (one is for test
database, and one is for client database).
How to create our own transform web.config?
Note: Originally, VS create “Debug”
and “Release” configuration for us.
Then you can see the following
picture to create a new configuration.
After creating
our customized configuration, on Solution Explorer right click on the web.config,
then click “Add Config Transform”.
Then, you can
see the one we created has been shown.
How to know the difference through using different transform config?
As default, VS
will create “Debug” and “Release” configuration for us. We can use those to be
example to declare this question. We found there is only one-line difference
between Debug and Release.
<compilation xdt:Transform="RemoveAttributes(debug)" />
|
From above
instruction, we assume that on “Release” build we want to delete the debug
attributes.
Then select
Folder option.
Then go the
file path “source/repos/ConfigTransform/ConfigTransform/bin/Release/PublishOutput”
to check the transform web.config.
On the other hand, we want to
change the build configuration to “Debug”.
Then you can notice
that the web.config has been changed! The Debug version contains debug
information.
No comments:
Post a Comment