How to replace a web.config setting with the current date while using webdeploy?

与世无争的帅哥 提交于 2019-12-07 02:48:46

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!