Variable Substitution Ordering

Hi
I have a .nupkg file which contains a 7 zip file. The deployment process is, Octopus takes the nupkg --> extracts it on the tentacle which reveals the 7zip file. I then have a deployment script which extracts the 7 zip file to the correct location on disk where I then point IIS to the file structure etc.

I now need to substitute some variables into a web.release.config file and then transform that file into the web.config. The problem I am having is that it seems it wants to substitute the variables immediately after extracting the nupkg but of course that just reveals the 7 zip file. Is there any way I can perform the substitution after the 7 zip extraction ? Any other suggestions ?

Thanks

Hi Lee,

Thanks for getting in touch! You’re correct that the variable substitution will be performed after extracting the NuGet package, and we won’t look within your 7zip file. What I’d suggest trying is the community-written Variables - Substitute in Files library step template available. You should be able to configure this step after you unzip your 7zip package to find your config file to perform substitution on. You can find the step template here.
https://library.octopusdeploy.com/step-templates/a3078bc0-0615-4220-84e8-bb1f271a90f9/actiontemplate-variables-substitute-in-files

Let me know if this helps and if you have any further questions. :slight_smile:

Best regards,

Kenny

Thanks Kenny.

This worked fine, how would I then carry out a configuration transform with this newly updated web.release.config? i.e. web.release.config => web.config is part of the package deployment step, but I am substituting variables after that step.

Hi Lee,

Thanks for following up, and I’m happy to hear that the step is working for you! I have a couple of thoughts which I think may help.

The first solution to come to mind is to extract your 7zip file in a predeploy script. These scripts are run before the variable substitution and config transforms features are run in a package step. This would mean you wouldn’t need to rely on the community steps, and let Octopus follow its normal order for your package step. You can refer to our package deployment feature ordering doc section.
https://octopus.com/docs/reference/package-deployment-feature-ordering#package-deployment-feature-ordering

Can I ask what the reason you’re needing to use a 7zip file within your NuGet package? If this isn’t really needed, the easiest solution would be to just remove this step, and Octopus can just take care of these tasks. It would allow you to avoid having to use these community steps, or extracting it in a predeploy script.

Additionally, this may theoretically work by using another library step for the config transforms after the variable substitution step (however, I haven’t tested it). This is the XML Transform using XDT that can be found here.
https://library.octopusdeploy.com/step-templates/569a5f1b-bb57-491a-9c4e-a6d6e44e6b26/actiontemplate-xml-transform-using-xdt

Let me know what you think and how you go!

Kind regards,

Kenny