FatAntelope
FatAntelope copied to clipboard
Use Insert instead of InsertBefore when the delta only exist in target
source file
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
<appSettings>
<add key="test20180421" value="1" />
<add key="test20180422" value="2" />
</appSettings>
</configuration>
target file
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
<appSettings>
<add key="test20180421" value="1" />
<add key="test20180422" value="2" />
<add key="test20180423" value="3" />
<add key="test20180424" value="4" />
</appSettings>
</configuration>
The generated patch file is
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<appSettings>
<add key="test20180424" value="4" xdt:Transform="Insert" />
<add key="test20180423" value="3" xdt:Transform="InsertBefore(/configuration/appSettings/add[(@key='test20180424')])" />
</appSettings>
</configuration>
The expected format should be, which is good for manually maintain
<?xml version="1.0" encoding="utf-8"?>
<!--For more information on using transformations see the web.config examples at http://go.microsoft.com/fwlink/?LinkId=214134. -->
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<appSettings>
<add key="test20180423" value="3" xdt:Transform="Insert" />
<add key="test20180424" value="4" xdt:Transform="Insert" />
</appSettings>
</configuration>
The reason why I would like to use Insert instead of InsertBefore is, when I remove Insert
<?xml version="1.0" encoding="utf-8"?>
<!--For more information on using transformations see the web.config examples at http://go.microsoft.com/fwlink/?LinkId=214134. -->
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<appSettings>
<add key="test20180423" value="3" xdt:Transform="Insert" />
<add key="test20180425" value="5" xdt:Transform="Insert" />
</appSettings>
</configuration>