Last active
December 11, 2024 15:34
-
-
Save Axeltherabbit/cae3c1fda3fa611f01ab4621c5917113 to your computer and use it in GitHub Desktop.
ps1 script to switch asp.net webconfig profile locally, it's useful if you want to try another profile without publishing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (-not $($args[0])) { | |
Write-Host "The profile variable is null or empty." | |
} | |
$xml = Resolve-Path "../web.config"; | |
$xdtPath = "../web." + $($args[0]) + ".config" | |
$xdt = Resolve-Path $xdtPath; | |
Add-Type -LiteralPath "../Microsoft.Web.XmlTransform.dll" | |
$xmldoc = New-Object Microsoft.Web.XmlTransform.XmlTransformableDocument; | |
$xmldoc.PreserveWhitespace = $true | |
$xmldoc.Load($xml); | |
$transf = New-Object Microsoft.Web.XmlTransform.XmlTransformation($xdt); | |
if ($transf.Apply($xmldoc) -eq $false) | |
{ | |
throw "Transformation failed." | |
} | |
$xmldoc.Save($xml); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is the pre-build hook that can be used: