XML ファイル (構成ファイルなど) 内のノードを「変換する必要がある」とマークし、変換ファイル内で指定しないと変換が失敗することは可能ですか?
たとえば、変換する必要があるノードを含む次の構成ファイルの例を見てください。.config
<?xml version="1.0"?>
<configuration>
<appSettings>
<!-- Mark this key to be transformed -->
<add key="MyValue" MustBeTransformed="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5.2" />
<httpRuntime targetFramework="4.5.2" />
</system.web>
</configuration>
キー値は としてマークされているためMustBeTransformed
、次のようにすると正しく変換されます。
<?xml version="1.0" encoding="utf-8"?>
<!-- For more information on using web.config transformation visit http://go.microsoft.com/fwlink/?LinkId=125889 -->
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<appSettings>
<!-- Without the line below, the transform would fail -->
<add key="MyValue" xdt:Transform="Set a value" />
</appSettings>
<system.web>
<compilation xdt:Transform="RemoveAttributes(debug)" />
</system.web>
</configuration>
.ps1
現時点では、スクリプトと XPathを使用してこれが可能であるとしか見ていないため、これを尋ねます