Search code examples
asp.netweb.config-transform

dynamic web.config appsetting


I have a web application that we publish and provide for users to install and run on their local network. They choose whether they run it as an internet, or intranet application.

When we publish the application we label the folder with the publish date (e.g. 20140815) so we know which version they have. However, when they contact support, it is a pain for them to get on the server to see the folder information.

I want to add an appsetting for cloudVersion and display it on the license page so they can easily provide it from wherever if needed. Also, they feel better seeing the version increase so they know they are getting value with the service contract.

<add key="cloudVersion" value="20140815"/>

I would like to automate the version in the appsettings. I was hoping I could use a Web.Config transform to set it with a dynamic yyyymmdd, but can't see how to do that and have found nothing in my web search.

<appSettings>
    <add key="cloudVersion" value="GETDATE()" xdt:Transform="Replace" xdt:Locator="Match(key)"/>
</appSettings>

Is this possible? If so, how? If not, is there a better approach to achieve the same result?


Solution

  • Short of finding a great solution for this, I have elected for the following:

    After publication, I run a bat file that does the following:

    1. copy the published directory and rename with today's date
    2. update the Web.Config appSetting value
    3. compress the updated directory using 7zip
    4. upload the compressed directory to Google Drive so my support team can provide it to our users.

    You can see how I modified the string here:

    bat file to modify web.config setting