Last active
December 14, 2015 22:59
-
-
Save azzlack/5162132 to your computer and use it in GitHub Desktop.
Sample install.ps1 for a NuGet package that patches the umbracoSettings config file
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
param($rootPath, $toolsPath, $package, $project) | |
if ($project) { | |
$projectDestinationPath = Split-Path $project.FullName -Parent | |
### Change single element value or attribute ### | |
$umbracoConfigFile = Join-Path $projectDestinationPath "Config\umbracoSettings.config" | |
$umbracoConfig = [XML](Get-Content $umbracoConfigFile) | |
# Set domain prefixes to true | |
$umbracoConfig.settings.requestHandler.useDomainPrefixes = $true | |
$umbracoConfig.Save($umbracoConfigFile) | |
### Insert chunck of XML ### | |
$dashboardConfigFile = Join-Path $projectDestinationPath "Config\Dashboard.config" | |
$dashboardConfig = [XML](Get-Content $dashboardConfigFile) | |
# Add new section to dashboard | |
$mySection = [xml]@' | |
<section alias="liveLogger"> | |
<areas> | |
<area>developer</area> | |
</areas> | |
<tab caption="Live Logger"> | |
<control>/App_Plugins/LiveLogger/usercontrols/ViewLogs.ascx</control> | |
</tab> | |
</section> | |
'@ | |
$mySection.PreserveWhitespace = $true | |
$n = $dashboardConfig.ImportNode($mySection.DocumentElement, $true) | |
$dashboardConfig.dashBoard.AppendChild($n) | |
$dashboardConfig.Save($dashboardConfigFile) | |
### Change element with specific attribute value ### | |
$webConfigFile = Join-Path $projectDestinationPath "Web.config" | |
$webConfig = [XML](Get-Content $webConfigFile) | |
# Change connection string | |
$connectionStringElement = $webConfig.connectionStrings.add | Where { $_.name -eq "umbracoDbDSN" } | |
$connectionStringElement.connectionString = "Datasource=|DataDirectory|Umbraco.sdf" | |
$connectionStringElement.providerName = "System.Data.SqlServerCe.4.0" | |
$webConfig.Save($webConfigFile) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment