问题
I'm using a web.config transform to replace settings with the settings of the selected solution configuration. However, I would like to add a setting that stores the datetime of the publish process. The reason for this is to be able to show a "Last published on" for my customers.
Using config transforms, is there a way to replace a setting with the current date?
回答1:
I think you're going to need to use a customer MSBuild task to apply the change.
My wife blogged about adding custom tasks to the build process (as she understands these things better than I).
You might find some useful information on her blog (there are a few related posts).
Alternatively, maybe you could pick up the Last Modified date from a file in your deployment, rather than having it in Web.config?
回答2:
You could post it with that setting blank, then in Application_Start, check to see if it's blank and populate it with the current date if it is.
来源:https://stackoverflow.com/questions/6827978/how-to-replace-a-web-config-setting-with-the-current-date-while-using-webdeploy