Transforming config files not included in Nuget package

pnolan's Avatar

pnolan

09 Jan, 2018 01:00 AM

Hi,

As part of my deployment I need to significantly modify an existing SharePoint web.config file.

I have a nuget package which deploys assets into the SharePoint hive so I can use this step to leverage the Octopus Configuration Transforms Feature.

Below is my proposed strategy. Could you confirm if this is considered a good approach?

  1. Use the Pre-deployment script Feature to copy the SharePoint web.config file to the location where the package is extracted to.
  2. Allow the Configuration Transforms Feature to transform the config file using a transform file contained in package.
  3. Use the Post-deployment script Feature to copy the SharePoint web.config file back to its original location

If this approach is valid, should I use the "Octopus.Action[name].Output.Package.InstallationDirectoryPath" variable to determine the location of the extracted package?

Although I've looked around I haven't found any other documentation discussing this concept. Would you happen to know of any?

Thanks heaps!

  1. Support Staff 1 Posted by Kenneth Bates on 10 Jan, 2018 12:25 AM

    Kenneth Bates's Avatar

    Hi,

    Thanks for getting in touch! In your config transformation definition, you can actually use absolute paths for files that aren't included in the package you're deploying. We have some examples outlined in our documentation.
    https://octopus.com/docs/deployment-process/configuration-files/adv...

    I think this would be an easier solution for you. Let me know what you think, and if you have any further questions, don't hesitate to reach out. :)

    Best regards,

    Kenny

  2. 2 Posted by pnolan on 11 Jan, 2018 09:02 PM

    pnolan's Avatar

    Hi Kenny,

    My interpretation of the documentation is that you can provide an absolute path to the transform file but the config file has to be relative to the package.

    Is this incorrect?

    Also I have another related question if you don't mind.

    My process is now the following (see below), however step 3 appears to be happening before step 2. Looking at the Package deployment feature ordering doco (link below) this seems to be correct. However, this doesn't make sense. I would have thought the most common scenario would be to insert variables via the Configuration Transforms Feature and then replace these variables via the Substitute Variables in Files Feature. Is there any way of making this happen?

    https://octopus.com/docs/deployment-process/package-deployment-feat...

    1. Use the Pre-deployment script Feature to copy the SharePoint web.config file to the location where the package is extracted to.

    2. Allow the Configuration Transforms Feature to transform the config file using a transform file contained in package.

    3. Allow the Substitute Variables in Files Feature to replace variables

    4. Use the Post-deployment script Feature to copy the SharePoint web.config file back to its original location

  3. Support Staff 3 Posted by Kenneth Bates on 15 Jan, 2018 06:30 AM

    Kenneth Bates's Avatar

    Hi,

    Thanks for following up. You are right, the transform files can use absolute paths, whereas the config file has to be relative to the package. I'm sorry I mixed those two up in my initial reply. :)

    The order you've outlined is indeed correct. The solution that we would recommend is to store the destination variables in the transform file itself. Alternatively, you could potentially take advantage of a community written step template called Variables - Substitute in Files. Using this as a dedicated step after your package step, instead of the Substitute Variables in Files feature could allow you to manipulate this order.

    I hope this helps!

    Kind regards,

    Kenny

  4. 4 Posted by pnolan on 16 Jan, 2018 10:38 PM

    pnolan's Avatar

    Thanks Kenny I have gone with the community written step.

    I still believe that the more logical default order would be Configuration Transforms Feature and then the Substitute Variables in Files Feature. I understand changing the default order is probably not possible as it would break things for people. However, having the ability to customise the order that features are executed would not be a problem and would be a great capability.

  5. pnolan closed this discussion on 16 Jan, 2018 10:38 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac