Hi @supafly270,
Thank you for sending over the task logs.
I have had a look at trying to replicate (what I have understood from your example and question) and I have managed to get this working (I beleive).
Before I outline my steps I took, I just wanted to double check with you a couple of items.
For my test I ran this on Octopus Server version 2022.3, are you able to confirm the version of Octopus you are running this on. While I don’t believe we have modified the transform behavior within Octopus, I wanted to check in case this is an issue for the version of Octopus you may be running.
The next observation is that from your logs (as you mentioned) it appears to be replacing. Can I check how you have deployed the changes with the binaries modified? Are you creating a new release with a new package. If you are modifying the same package version, then chances are Octopus will be using the package from the cache, which is why the changes may not have been picked up.
As for my (simple) test, I did the following:
Create a Web.Config file:
<?xml version="1.0"?>
<configuration>
<connectionStrings>
<add name="DefaultConnection" providerName="System.Data.SqlClient" connectionString=""/>
</connectionStrings>
<MyCustomSettingsSection>
<TestMode>True</TestMode>
</MyCustomSettingsSection>
<system.web>
<identity impersonate="true" other="true"/>
<compilation debug="true" targetFramework="x.0">
<assemblies>
<add assembly="System.Web.Abstractions, Version=x.0.0.0, Culture=neutral, PublicKeyToken=xxxxxxxxxxxxxxxxxxxx" />
<add assembly="System.Web.Helpers, Version=x.0.0.0, Culture=neutral, PublicKeyToken=xxxxxxxxxxxxxxxxxxxx" />
<add assembly="System.Web.Routing, Version=x.0.0.0, Culture=neutral, PublicKeyToken=xxxxxxxxxxxxxxxxxxxx" />
<add assembly="System.Web.Mvc, Version=x.0.0.0, Culture=neutral, PublicKeyToken=xxxxxxxxxxxxxxxxxxxx" />
<add assembly="System.Web.WebPages, Version=x.0.0.0, Culture=neutral, PublicKeyToken=xxxxxxxxxxxxxxxxxxxx" />
</assemblies>
</compilation>
</system.web>
</configuration>
Create a Web.Development.Config file:
<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<connectionStrings>
<add name="DefaultConnection" providerName="System.Data.SqlClient" connectionString="DataSource=localhost\SQLExpress;Databasename=master;Integrated Security=true;" xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
</connectionStrings>
<MyCustomSettingsSection>
<TestMode xdt:Transform="Replace">false</TestMode>
</MyCustomSettingsSection>
<system.web>
<compilation debug="true" targetFramework="x.0" xdt:Transform="InsertIfMissing"/>
<identity impersonate="false" xdt:Transform="Replace"/>
</system.web>
</configuration>
I packaged these into a zip file and uploaded to my Octopus Server instance.
Set up a simple test within my local Octopus Server instance (2022.3):
Run a deployment, and this successfully transformed my XML:
Output of my deployed Web.Config:
<?xml version="1.0"?>
<configuration>
<connectionStrings>
<add name="DefaultConnection" providerName="System.Data.SqlClient" connectionString="DataSource=localhost\SQLExpress;Databasename=master;Integrated Security=true;"/>
</connectionStrings>
<MyCustomSettingsSection>
<TestMode>false</TestMode>
</MyCustomSettingsSection>
<system.web>
<identity impersonate="false"/>
<compilation debug="true" targetFramework="x.0">
<assemblies>
<add assembly="System.Web.Abstractions, Version=x.0.0.0, Culture=neutral, PublicKeyToken=xxxxxxxxxxxxxxxxxxxx" />
<add assembly="System.Web.Helpers, Version=x.0.0.0, Culture=neutral, PublicKeyToken=xxxxxxxxxxxxxxxxxxxx" />
<add assembly="System.Web.Routing, Version=x.0.0.0, Culture=neutral, PublicKeyToken=xxxxxxxxxxxxxxxxxxxx" />
<add assembly="System.Web.Mvc, Version=x.0.0.0, Culture=neutral, PublicKeyToken=xxxxxxxxxxxxxxxxxxxx" />
<add assembly="System.Web.WebPages, Version=x.0.0.0, Culture=neutral, PublicKeyToken=xxxxxxxxxxxxxxxxxxxx" />
</assemblies>
</compilation>
</system.web>
</configuration>
Looking at my RAW task logs I can see the transform using the InsertIfMissing
:
I also run the same test using the Web.config Transformation Tester (apphb.com) and my config transformed as expected.
I hope this helps.
All the best,
Doug