Web.Config AppSetting Replace

Hi All,

I am new to Octopusdeploy so I apologies if my question has been asked before, I couldn’t find anything to help searching.

I have a simple setup, I have an MVC project which is checked into GIT, Team City listens for a check-in, packages up, sends the package to Octopus then sends a release to a ‘Development’ environment.

This is all working great, however, as it’s a website, I would like to show on the website in the footer, which version of the package is currently running.

To do this, I thought I could create some fields in the AppSettings, output the values to the website footer, then when Octopus deploys the package, replace the AppSetting with the version. This I am having trouble with.

I’ve managed to replace the value of the AppSetting, but not able to put the actual package version into it, I’ve been looking into System Variables, but can’t seem to get anything to work, is this even feasible? Can anyone advise on a way to achieve this?

Many thanks in advance

Hi Jamie,

Assuming you want to use the release number, you can create a variable in Octopus defined like this:

MyAppVersion = #{Octopus.Release.Number}

Then in your web.config, you can define:

   <add key="MyAppVersion" value="1.0.0" />

During deployment, Octopus will look for appSettings with a key which matches a variable defined in Octopus, and replace the value if found.

I see you already found the special variables page - that plus the page on configuration files should explain these features in more details:

Hope this helps!


Thanks very much Paul, it works great.