Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 220
citronas Avatar asked Jul 26 '11 09:07

citronas


People also ask

What happens when you change the web config file at run time?

the answer i found :- ASP.NET invalidates the existing cache and assembles a new cache. Then ASP.NET automatically restarts the application to apply the changes.

How to Add Web Config transformation file?

If you have a web application project, Right-click on web. config and choose Add Config Transform. This will add any config transforms that are missing from your project based on build configurations (i.e. if you have Production and Staging build configs, both will get a transform added).

What is Webconfig?

A web. config file is a Windows file that lets you customize the way your site or a specific directory on your site behaves. For example, if you place a web. config file in your root directory, it will affect your entire site (www.coolexample.com).


1 Answers

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?

like image 171
Steve Morgan Avatar answered Oct 18 '22 06:10

Steve Morgan