Transformed web.config is not copied to localcontent directory

Evdk's Avatar

Evdk

10 Oct, 2017 01:52 PM

Hello,

We're using Octopus 3.11.16, and are experiencing a problem with the deployment to our cloud service in Azure.
We use Teamcity to build our project, which is created fine.

When deploying to Azure though, a "Work/<uuid>/staging" directory is generated on the Octopus server, that contains a directory called configtransforms. This directory contains all the transform files we have. The relevant files we have for the deployment we are trying to create are named "Web.AzureTest.config" and "Web.Release.config".

In the process we have added the "Web.AzureTest.config => Web.config" expression in the additional transforms textbox.
In fact, this does seem to work just fine, as the Web.config file in the configtransforms directory looks great.

There also exists a directory under /staging/ called "LocalContent" which seems to contain all data that is actually copied to the cloud service. The Web.config file we find under this directory are not transformed, and seem to be equal to the Web.config in our solution.

This makes us think that there's supposed to be a copy action from the /configtransforms/ directory to wherever these Web.config files are sent. I can't detect any step in the proces that resembles this action, which makes me think this is something that is supposed to happen within the core of Octopus.

Has anyone else encountered this problem before? Is there anyone that knows how to copy this transformed file so it is actually used?

Thanks in advance,

Erik

  1. Support Staff 1 Posted by Shannon Lewis on 12 Oct, 2017 07:25 AM

    Shannon Lewis's Avatar

    Hi Erik,

    Thanks for getting in touch. By default Octopus will only look for Web.Release.config and Web.Environment.config, but there are some advanced options to cover your scenario. Check out our documentation on Advanced Configuration Transforms.

    Hope that helps and if I can assist with anything further just let me know.

    Regards
    Shannon

  2. 2 Posted by Erik van der Kr... on 12 Oct, 2017 08:04 AM

    Erik van der Kramer's Avatar

    Hi Shannon,

    Like I said in my original post, the actual transform is working fine! I’ve added the expression “Web.AzureTest.config => Web.config” in the additional transform field (which is described in your link as well) within the process page in Octopus. This seems to go fine.
    However, the transformed file (called Web.config) is then not used, as it lives in the directory called “configtransforms” which is a sibling to the directory “LocalContent” in which the Web.config file is living that will be deployed.
    What seemingly needs to happen is copying the transformed file to the file that is deployed. Any idea how we can achieve that?

    Thanks,

    Erik

  3. Support Staff 3 Posted by Shannon Lewis on 13 Oct, 2017 05:31 AM

    Shannon Lewis's Avatar

    Hi Erik,

    Sorry if I'm misunderstanding you're configuration. Let me ask a couple of question to help make sure I'm clear.

    In the configtransforms folder, you have both a Web.AzureTest.config and a Web.config file? And that AzureTest file is correctly being applied to the Web.config in the configtransforms folder?

    You also have a Web.config in staging/LocalContent, is there also a Web.AzureTest.config file in there? I believe the files will only be applied by default if they are in the same folder.

    I haven't done this personally, but I've talked to the team and they believe that if you use the relative paths illustrated here then you should be able to get it to apply a transform from one directory to a config in another.

    I think it'd be something like configtransforms\Web.AzureTest.config => staging\LocalContent\Web.config

    If that doesn't cover what you need, you may have to fall back to a PreDeploy script to copy the Web.AzureTest.config to staging\LocalContent, or a PostDeploy script to copy configtransforms\Web.config to staging\LocalContent. This would depend on whether just the transform to apply is the same or whether the resulting Web.config should be the same.

    Regards
    Shannon

  4. 4 Posted by Erik van der Kr... on 13 Oct, 2017 08:21 AM

    Erik van der Kramer's Avatar

    Hey Shannon,

    Everything you state is correct except for the Web.AzureTest.config in the staging/LocalContent, so you’re not misunderstanding our configuration.
    I will try the relative paths suggestion, I think it makes sense, however it seems strange to me that this configtransforms directory is made in the first place.
    Is the generation of this directory not something that is done by Octopus itself?
    You seem to suggest that this part is generated by some external script/process. This could be, as this project was transferred over to me (and I might not have found this script). I did disable the PreDeploy script though, which was running some old Octopus 2 stuff.

    Like I said, I will try the relative paths out, and I’ll get back to you with the results.

    Thanks a lot for your help so far.

    Kind regards,

    Erik

  5. 5 Posted by Erik van der Kr... on 17 Oct, 2017 09:42 AM

    Erik van der Kramer's Avatar

    Hey Shannon,

    I’ve tried your suggestion and unfortunately it did not work. Whenever I use a relative path in the additional transform field in the process section, the transforms are simply ignored… I paid careful attention to specifying the paths, I made sure they lead to the right targets. Whenever I use the simple “Web.AzureTest.config => Web.config”, it does apply the transform, only in the configtransform directory.

    What I’d like to know from you at this time (besides a perfect answer if there is one, obviously) is what the role is of the configtransform directory. Currently I assume that this directory is generated by Octopus itself, and that Octopus would normally copy the transformed Web.config to the LocalContent directory. Since this is not happening for us, I’d like to understand how this process works so that I might reason where our issue originates from.

    I’d also like to know, if there’s a way to execute a (powershell)script that might perform this copy after the transforms have been done. I know that I can add PreDeploy.ps1 and PostDeploy.ps1, however I’d need something like a PostTransform.ps1 as the other 2 mentioned are executed at too early or too late time. If I had this option, I could simply copy the transformed files myself, making this a lot easier.

    Thanks for your help,

    Erik

  6. Support Staff 6 Posted by Shannon Lewis on 18 Oct, 2017 01:53 AM

    Shannon Lewis's Avatar

    Hi Erik,

    I've been able to track down a test that I believe is designed to ensure the scenario you're trying to use works, see https://github.com/OctopusDeploy/Calamari/blob/c38fad270ec5d5ca0edb...

    In debugging through that test locally, I can see there should be information about which transforms are being applied and/or skipped going in to the task log. Would you be able to check, and possibly attach, the task log for one of the deployments? Please redact any sensitive data or feel free to make this conversation private.

    As for the configtransform, I can't find anything to suggest that's coming from Octopus. I'd suspect that is most likely coming from the source for your cloud service, or the packaging. Are you able to attach any screenshot or setup info about the project and how it's being built/packaged? Could we get a log from the packaging process?

    Regards
    Shannon

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

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