Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Insert instead of InsertBefore when the delta only exist in target #10

Open
chucklu opened this issue Dec 7, 2021 · 1 comment
Open

Comments

@chucklu
Copy link

chucklu commented Dec 7, 2021

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>
@chucklu
Copy link
Author

chucklu commented Dec 7, 2021

The reason why I would like to use Insert instead of InsertBefore is, when I remove and add another section . I can not smoothly write the xdt manually with InsertBefore.
However I can manually write transform file with 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>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant