Web.Config Transformations with Octopus Deploy
Asked Answered
Z

2

6

I want to apply web.config transformations with Octopus Deploy, but only on the production environment.

I don't want to create separate configs for all of our other environments.

At the moment i'm using this following custom expression but it doesn't apply the transformation

enter image description here

Zigrang answered 29/4, 2014 at 11:4 Comment(0)
D
6

Are you specifically trying to change key/value pairs within the web.config file of your project? XML transforms are a different function altogether. Read the documentation here: http://docs.octopusdeploy.com/display/OD/Configuration+files. That documentation will refer as well to MS documentation on transforms: http://msdn.microsoft.com/en-us/library/dd465326.aspx

Having said that, it looks like you mean to say you want to change the value of configuration variables within Octopus. Octopus can definitely do that; especially when targeting a specific environment. Go to the "Variables" tab in your project. Within the variable tab, the "Name" column refers to the value you want to change in your web.config or app.config. This is the EXACT name as it appears in the file so you don't have to change anything directly in the file to match.

The value is of course the value to appear. Then the Variable Scope column will allow you to specify the environment, server, roles and even step within the process (mine doesn't appear as this is a blank project).

enter image description here

Edit: Read this documentation from Octopus Deploy on config files (and further down is web transformations). It looks like your custom expression for the transform are incorrect if you're trying to remove the debug mode flag. Judging by the expression you input, it will render as "TrueProduction.Production" which really doesn't describe any type of transformation. You should probably try this instead:

<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
  <system.web>
    <compilation xdt:Transform="RemoveAttributes(debug)" />
  </system.web>
</configuration>

Make sure you have your production Web config file as: Web.Production.config if you only want to apply it for Production. Make sure that Web..Config matches that environment name in Octopus. Again, it's in the documentation on the Octopus Deploy site.

Dodgem answered 30/4, 2014 at 15:7 Comment(1)
Basically, i just want to turn debug mode off when in production, without creating separate web.config transformations for all of our environmentsZigrang
C
0

What you have to do is create a Web.Production.config transformation file where "Production" is the name of your production environment. Once you enable the XML transformation within your Octopus Deploy task, Octopus will apply the production transformation only when it's deploying to be production environment. This might be also true if you create a Web.Release.config transformation file instead of specific environment file but I am not sure.

Carty answered 30/4, 2017 at 17:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.