Hi @kenth.jonsson,
As you say you have 1 working, my assumption here may be something misconfigured with the scoping of the variables themselves or the variables are not being passed in correctly. It may be worth double-checking this.
A good thing to check here would be to write your variables out to the task log:
You can add the following variables to your variables section within your project using the Octopus System Variables:
OctopusPrintEvaluatedVariables = True
OctopusPrintVariables = True
I made a mock of your variables like below:
After my “new” deployment has completed I can inspect the verbose task logs for my deployment to see what variables Octopus has used for my deployment:
I also did a new transform test here:
Here is my code for my fictional config file “SAML.Web.Transform.config”:
<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<connectionStrings>
<add name="DefaultConnection" providerName="System.Data.SqlClient" connectionString="DataSource=localhost\SQLExpress;Databasename=master;Integrated Security=true;" xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
</connectionStrings>
<MyCustomSettingsSection>
<TestMode xdt:Transform="Replace">#{My.Octopus.Variable}</TestMode>
</MyCustomSettingsSection>
<system.web>
<compilation debug="true" targetFramework="x.0" xdt:Transform="InsertIfMissing"/>
<identity impersonate="false" xdt:Transform="Replace"/>
</system.web>
<system.webServer>
<add accessType="Allow" users="#{IISUsers}" xdt:Transform="SetAttributes(users)"/>
<basicAuthentication enabled="true" defaultLogonDomain="#{DefaultLogonDomain}" xdt:Transform="SetAttributes(defaultLogonDomain)" />
</system.webServer>
</configuration>
Here is my “Web.config” file:
<?xml version="1.0"?>
<configuration>
<connectionStrings>
<add name="DefaultConnection" providerName="System.Data.SqlClient" connectionString=""/>
</connectionStrings>
<MyCustomSettingsSection>
<TestMode>True</TestMode>
</MyCustomSettingsSection>
<system.web>
<identity impersonate="true" other="true"/>
<compilation debug="true" targetFramework="x.0">
<assemblies>
<add assembly="System.Web.Abstractions, Version=x.0.0.0, Culture=neutral, PublicKeyToken=xxxxxxxxxxxxxxxxxxxx" />
<add assembly="System.Web.Helpers, Version=x.0.0.0, Culture=neutral, PublicKeyToken=xxxxxxxxxxxxxxxxxxxx" />
<add assembly="System.Web.Routing, Version=x.0.0.0, Culture=neutral, PublicKeyToken=xxxxxxxxxxxxxxxxxxxx" />
<add assembly="System.Web.Mvc, Version=x.0.0.0, Culture=neutral, PublicKeyToken=xxxxxxxxxxxxxxxxxxxx" />
<add assembly="System.Web.WebPages, Version=x.0.0.0, Culture=neutral, PublicKeyToken=xxxxxxxxxxxxxxxxxxxx" />
</assemblies>
</compilation>
</system.web>
<system.webServer>
<add accessType="Allow" users="VariableToReplace" />
<basicAuthentication enabled="true" defaultLogonDomain="VariableToReplace" />
</system.webServer>
</configuration>
After deployment, my config file resembles the following (with my variables substituted):
If I run the deployment and my variable has been scoped incorrectly (in my case I scoped this to another environment that was not the environment I was deploying to) then I can see the following in my config (where my variable has not been substituted for users)
</system.web>
<system.webServer>
<add accessType="Allow" users="#{IISUsers}" />
<basicAuthentication enabled="true" defaultLogonDomain="saml.org" />
</system.webServer>
And I am missing the variable within my task log as Octopus has not picked this up due not being scoped to my environment I am deploying to:
This was tested against the version you are running.
Please also note the warning regarding printing out your variables with production environments. These variables should only be used to help debug issues and used as a temporary measure.
I hope this helps
Doug