Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Insert DateTime.Now to a Web.Config during publish/deploy

I want to have a date when an application was deployed/published in my Web.Config.

Is there a way to achieve that with web.config transformations?

With xdt:Transform="Replace" I can replace any node with predefined value, but is there a way to use some custom function to calculate that value (like DateTime.Now)?

like image 533
Shaddix Avatar asked May 25 '12 06:05

Shaddix


1 Answers

I don't think you can do this with the config transforms (although I'm not 100% certain).

I would suggest using the MSBuild Extension Pack which contains a DateAndTime task to get the current Date and a Detokenise task to perform token replacement on a file.

You could then either:

  1. edit your website csproj file remove the comments around the AfterBuild target, and place your tasks there
  2. write a separate MSBuild script and run that after your site builds.

Hope that helps.

like image 115
KazR Avatar answered Oct 13 '22 19:10

KazR