I have Octopus 3.6.0 and Web application that I’m deploying using Octopus.
This is the error I’m getting from Octopus when it tries to deploy my app.
File C:\Octopus\Applications\Development\Atomia.Ail.Api\0.3.1013\Web.Development.config, line 5, position 6:
January 31st 2017 17:53:02Warning
No element in the source document matches ‘/configuration/appSettings/add[@key=‘AilConnectionString’]’
This is my current setup:
- Web.config (main template file)
- Web.AppSettings.config (This is not transformation file. This is just appSettings chunk splitted into separate file.)
- Web.Development.config (environment specific file. Environment is called Development)
- and variable that contains connection string for Development environment “#{AilConnectionString}”
- Octopus settings (http://prntscr.com/e2rbzr) (see attachment)
- All configuration files are packaged in nuget file
Web.config
<configuration>
<appSettings configSource="Web.AppSettings.config"></appSettings>
.....
Web.AppSettings.config
<?xml version="1.0" encoding="utf-8"?>
<appSettings>
<add key="AilConnectionString" value="mongodb://localhost:27017" />
</appSettings>
Web.Development.config
<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<appSettings>
<add key="AilConnectionString" value="#{AilConnectionString}" xdt:Transform="SetAttributes" xdt:Locator="Match(key)" />
My understanding is that Octopus will see Web.config in combination with AppSettings chunk as Web.config template file and then apply transformations from Web.Development.config file (with variable replacement).
Am I missing some configuration here?
I’m adding here result of the deployment
Web application location on web server:
C:\Octopus\Applications\Development\Atomia.Ail.Api\0.3.1013 (0.3.1013 failed release)
Content in “0.3.1013/” folder:
- Web.config (main web.config file)
- Web.AppSettings.config (appSettings chunk )
- Web.Development.config (transformation for Development environment)
Web.config content
<configuration>
<appSettings configSource="Web.AppSettings.config"></appSettings>
....
Web.AppSettings.config
<appSettings>
<add key="AilConnectionString" value="mongodb://localhost:27017" />
....
We.Development.config
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<appSettings>
<add key="AilConnectionString" value="<This is actually replaces with real connection string for Development environment>" xdt:Transform="SetAttributes" xdt:Locator="Match(key)" />
...
Expected behavior is
We.Development.config transformation is applied to Web.AppSettings.config and connection string is replaces with #{AilConnectionString} value.
Hi Aleksandar,
Thank you for getting in touch. The error you are seeing is due to the release process attempting to apply Web.Development.config
to Web.config
. The transform process does not know about configSource
as it treats it as a standard XML file, so it doesn’t know to look in the other file.
Also, as you mentioned the Web.AppSettings.config
file is not a transform file, so it can’t be applied to Web.config
. The configSource
feature is designed so that both the web.config
and referenced chunk file exist and are used at runtime. What you want to end up with is the contents of the Web.config
and Web.AppSettings.config
exactly as you have shown in your last message.
To get the transforms working:
- Prevent the above transformation being applied, either by renaming
Web.Development.config
to Web.AppSettings.Development.config
or unchecking the Automatically run...
checkbox
- Change the line in
Additional Transforms
to Web.AppSettings.Development.config => Web.AppSettings.config
(if you chose the first option in 1). You may want to replace Development
with #{Octopus.Environment.Name}
.
However you may not even need to do a transform at all. If you enable the configuration variables feature in your step, it should find the Web.AppSettings.config
file and replace the appSettings
value if the key
value matches up with the variable name.
Hope that helps.
Robert W