Config transform issue

Hello,

I’m having a problem with configuration transforms.
We have a deployment package that contains around 20 or so executable files with corresponding config files.
For example:
B001_01_01Batch.exe
B001_01_01Batch.exe.config
B001_01_02Batch.exe
B001_01_02Batch.exe.config
B001_02_01Batch.exe
B001_02_01Batch.exe.config
etc…

We also have configuration transform files like this:
app.IT2-STUB.config
app.IT2-NOSTUB.config
etc…

In the deployment step I have added the following to ‘Additional transforms’:
app.#{ScopeCode}-#{StubFlag}.config => *.exe.config

On deployment, this results in the transform file being explictly set to ‘app.IT2-NOSTUB.config’.
My intention is to have that configuration transform applied to all of the executable config files. However, it is only being applied to the very first config file it finds, which is ‘B001_01_01Batch.exe.config’. The rest of the exe.config files are untouched.

Here is a snippet of the log:

13:50:30 Verbose | Extracting package to: C:\Octopus\Applications\Staging (IT2)\RFC-GW-Integrator\20160109.190-DeployPreparation_1
13:50:30 Verbose | Extracted 79 files
13:50:30 Info | Performing variable substitution on 'C:\Octopus\Applications\Staging (IT2)\RFC-GW-Integrator\20160109.190-DeployPreparation_1\app.IT2-STUB.config’
13:50:30 Info | Transforming ‘C:\Octopus\Applications\Staging (IT2)\RFC-GW-Integrator\20160109.190-DeployPreparation_1\B001_01_01Batch.exe.config’ using ‘C:\Octopus\Applications\Staging (IT2)\RFC-GW-Integrator\20160109.190-DeployPreparation_1\app.IT2-STUB.config’.
13:50:30 Verbose | Executing Replace (transform line 6, 70)
13:50:30 Verbose | on /configuration/SystemConfiguration/retrySettings/retrySetting[@id=‘B001_01_02’]
13:50:30 Verbose | Applying to ‘retrySetting’ element (source line 8, 8)
13:50:30 Verbose | Replaced ‘retrySetting’ element
13:50:30 Verbose | Done executing Replace



13:50:30 Verbose | Executing Replace (transform line 29, 49)
13:50:30 Verbose | on /configuration/appSettings/add[@key=‘Rfc.IsEnabledProxy’]
13:50:30 Verbose | Applying to ‘add’ element (source line 127, 6)
13:50:30 Verbose | Replaced ‘add’ element
13:50:30 Verbose | Done executing Replace
13:50:30 Verbose | Looking for appSettings, applicationSettings, and connectionStrings in any .config files
13:50:30 Info | No matching appSetting, applicationSetting, nor connectionString names were found in: C:\Octopus\Applications\Staging (IT2)\RFC-GW-Integrator\20160109.190-DeployPreparation_1\app.IT1-NOSTUB.config
13:50:31 Info | No matching appSetting, applicationSetting, nor connectionString names were found in: C:\Octopus\Applications\Staging (IT2)\RFC-GW-Integrator\20160109.190-DeployPreparation_1\app.IT1-STUB.config
13:50:31 Info | No matching appSetting, applicationSetting, nor connectionString names were found in: C:\Octopus\Applications\Staging (IT2)\RFC-GW-Integrator\20160109.190-DeployPreparation_1\app.IT2-NOSTUB.config
13:50:31 Verbose | File ‘C:\Octopus\Applications\Staging (IT2)\RFC-GW-Integrator\20160109.190-DeployPreparation_1\app.IT2-STUB.config’ was interpreted as an XML configuration transform; variable substitution won’t be attempted.
13:50:31 Info | No matching appSetting, applicationSetting, nor connectionString names were found in: C:\Octopus\Applications\Staging (IT2)\RFC-GW-Integrator\20160109.190-DeployPreparation_1\app.PRO-NOSTUB.config
13:50:31 Info | No matching appSetting, applicationSetting, nor connectionString names were found in: C:\Octopus\Applications\Staging (IT2)\RFC-GW-Integrator\20160109.190-DeployPreparation_1\app.ST-NOSTUB.config
13:50:31 Info | No matching appSetting, applicationSetting, nor connectionString names were found in: C:\Octopus\Applications\Staging (IT2)\RFC-GW-Integrator\20160109.190-DeployPreparation_1\app.ST-STUB.config
13:50:31 Info | Updating appSettings, applicationSettings, and connectionStrings in: C:\Octopus\Applications\Staging (IT2)\RFC-GW-Integrator\20160109.190-DeployPreparation_1\B001_01_01Batch.exe.config

As you can see from the log above, only B001_01_01Batch.exe.config is transformed.

I’m using the latest Octopus version 3.2.15. Any help would be much appreciated.

I have tried not using a wildcard for the configuration file target and setting it explicitly as follows:
app.#{ScopeCode}-#{StubFlag}.config => B001_01_01Batch.exe.config
app.#{ScopeCode}-#{StubFlag}.config => B001_01_02Batch.exe.config
etc…

But still, only the first config file, B001_01_01Batch.exe.config was transformed.

So then I swapped the first and second lines around, like so:
app.#{ScopeCode}-#{StubFlag}.config => B001_01_02Batch.exe.config
app.#{ScopeCode}-#{StubFlag}.config => B001_01_01Batch.exe.config

But it still transforms only B001_01_01Batch.exe.config, regardless of the order in ‘Additional transforms’

The only thing I could think of that might be tripping up the config transform logic was that all the exe.config files are exactly the same. They have all been produced from the same app.config when compiled. So I deliberately altered a config file to make it different and tried again, but still no luck. Only B001_01_01Batch.exe.config was a target for transforms.

Hi Peter,

I’ve had a quick look into the wildcard config transforms and seems it is not working. It is strange that the explicit definitions do not work either.

I’ve created an issue: https://github.com/OctopusDeploy/Issues/issues/2286 to investigate further and resolve.

Thanks for letting us know.

Cheers,
Shane

Thank you Shane.
In the meantime, if you discover a workaround that will allow us to get the transforms working please let us know.

Hi Peter,

It turns out we are only allowing a transform file to be applied to a single target file, so unfortunately no workaround.

Will have a fix out for you in the next release which I expect to be sometime this week.

Cheers,
Shane

Shane,
Thank you for the update.
Looking forward to the fix!

Hi Peter,

The fix is out in version 3.2.17. https://octopus.com/downloads

Please let me know if you encounter any more issues.

Cheers,
Shane

We’ve upgraded to 3.2.17 but still can’t get config file transforms to work. Our App.config looks like this:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <appSettings>
    <add key="Interval" value="00:00:05" />
    <add key="ServiceUrl" value="https://localhost:5000" />
  </appSettings>
</configuration>

Our App.Test.config file has been set to ‘Copy to Output’ and is showing up in our NuGet package. It looks like this:

<?xml version="1.0" encoding="utf-8" ?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
  <appSettings>
    <add xdt:Transform="SetAttributes"
         xdt:Locator="Match(key)"
         key="Interval"
         value="00:10:00"/>
    <add xdt:Transform="SetAttributes"
         xdt:Locator="Match(key)"
         key="ServiceUrl"
         value="http://myservice"/>
  </appSettings>
</configuration>

We receive the following error in the deployment log:

No matching appSetting, applicationSetting, nor connectionString names were found in: C:\Octopus\Applications\Test\MyService\1.0.0193_1\App.Test.config

“Automatically run configuration transformation files” has been enabled and no additional transforms have been configured. What are we doing wrong? Is this a bug?

It turns out that because it’s a Windows Service it has the ‘.exe’ file extension we need to use the “Additional transforms” setting:

App.#{Octopus.Environment.Name}.config => Bridge.Payments.WindowsService.exe.config

The above works but is less magical than it should be.

Hi,

App.config should be transformed by App.Test.config when you deploy to the environment Test. The message:

No matching appSetting, applicationSetting, nor connectionString names were found in: C:\Octopus\Applications\Test\MyService\1.0.0193_1\App.Test.config

is because you have variable substitutions enabled and no variables could be substituted in App.Test.config.

If config transform automatically found a match for this rule:

App.#{Octopus.Environment.Name}.config => Bridge.Payments.WindowsService.exe.config

it would indeed be magical. There must be some kind of a file name match, in your case your transform file would be applied automatically if it was called Bridge.Payments.WindowsService.exe.Test.config.

Hope this helps.

Cheers,
Shane

Shane,
Just want to let you know we have tested version 3.2.17 and the transforms seem to be working fine.
Thank you for the quick fix!