Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Transforms XML files e.g. Web.Release.config to Web.config
[string] $SourceFile,
[string] $TargetFile
if (!$SourceFile -or !(Test-Path -path $SourceFile -PathType Leaf)) {
throw "File not found. $xml";
if (!$TargetFile -or !(Test-Path -path $TargetFile -PathType Leaf)) {
throw "File not found. $TargetFile";
Add-Type -LiteralPath "Microsoft.Web.XmlTransform.dll"
$xmldoc = New-Object Microsoft.Web.XmlTransform.XmlTransformableDocument;
$xmldoc.PreserveWhitespace = $true
$transf = New-Object Microsoft.Web.XmlTransform.XmlTransformation($TargetFile);
if ($transf.Apply($xmldoc) -eq $false)
throw "Transformation failed."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.