Custom tags in web.config

ruf-u
(Patricia) #1

Hi everyone! My web.config looks like this:

  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="..." />
      </parameters>
    </defaultConnectionFactory>
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
    </providers>
  </entityFramework>

  <externalApiConfiguration url="..." userTimeout="5000" applicationTimeout="3000" authHeader="..." /> 

Does anyone has suggestions or ideas on what’s the smartest way to perform a substitution of the entityFramework tag parameter value and the externalApiConfiguration url and authHeader values in Octopus?

(Shannon Lewis) #3

Hi Patricia,

Thanks for getting in touch. One way we’ve used to solve this is to have a Release.config file that transforms the desired value to an Octopus variable. For example, you might transform the externalApiConfiguration.url value to something like #{ExternalApiUrl}.

Then in your Octopus define ExternalApiUrl as a variable with the required values per environment etc and enable the Configuration Variables feature on the deployment step.

Hope that helps and let me know if you have any further questions.

Regards
Shannon

(Patricia) #4

Hi Shannon,

Thanks for posting! Unfortunately that’s what I did, but it didn’t worked out. I guess I’m missing some configuration somewhere, because the deploy process is not failing but is not applying the transformations. What am I doing wrong or missing? Thanks!

(externalUrl variable properly defined for the target environment)

(Shannon Lewis) #5

Ok, so I think you’re right, it’ll just be something slightly out in the configuration somewhere.

Let’s double check a few things:

  • Is the transform file called web.Release.config ?
  • Is it definitely in the package?
  • Is the Configuration Variables feature enabled on the step?
  • Is the task log for the deployment showing any signs that it’s trying to do the transforms? In the Verbose logs I think it should says where it’s search for transforms to apply.

If you’re able to attach any screenshots or task logs that would be good. If they have sensitive information you can send to support@octopus.com with a link to this thread.

Regards
Shannon

(Patricia) #6

Hi Shannon,

Thanks very much. I was able to solve this issue, however I would like to check if Octopus works like this or if maybe some setting is not properly configured.

1- The transform file exists and it’s named Web.Release.config.
2- Declared Web.Release.config => Web.config explicitly in the extra transformations box.
3- The transformation rule is valid, I tested it using Visual Studio.
4- All variables are properly declared

What happened was:

  • Octopus did not applied transformations
  • Web.Release.config was not in the Octopus package, but it was in the Build package.

How I made it “work”:

  • Added an extra tag for web.release.config inside my csproj file.
  • Maintained explicit Web.Release.config => Web.config declaration
  • Declared Web.Release.config explicitly in the extra substitutions box (without this one it replaced the custom keys in Web.config for the ones in the Web.Release.config, but without any variable substitutions, so it was showing #{variable_name} instead of the variable value for each variable used)

Now I see:

  • Web.Release.config is deployed, as well as all the files (I just want this file to be used when the Release is being created), so I guess I have to add an step for deleting it after the Deployment step)

What I was expecting was:
Octopus will find out I have a Web.Release.config file and (as it has the default naming and those boxes I used they all say “extra”) it will apply the transformations to my Web.config without any extra explicit instructions to do so and to substitute the variables once the Web.config is already transformed.

My question is now:
Is Octopus supposed to work like I was expecting it to work or in the way it is actually behaving? Thanks very much!