Last active
November 7, 2017 08:15
-
-
Save anthonychu/1375b3a633a9b6db4289ba2772bdffa8 to your computer and use it in GitHub Desktop.
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
FROM microsoft/aspnet | |
WORKDIR /inetpub/wwwroot | |
COPY . . | |
ENTRYPOINT ["powershell.exe", ".\\Startup.ps1"] |
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 ( | |
[string]$webConfig = ".\Web.config.test" | |
) | |
$doc = (Get-Content $webConfig) -as [Xml]; | |
$appSettingPrefix = "APPSETTING_"; | |
$connectionStringPrefix = "CONNSTR_"; | |
Get-ChildItem env:* | ForEach-Object { | |
if ($_.Key.StartsWith($appSettingPrefix)) { | |
$key = $_.Key.Substring($appSettingPrefix.Length); | |
$appSetting = $doc.configuration.appSettings.add | Where-Object {$_.key -eq $key}; | |
if ($appSetting) { | |
$appSetting.value = $_.Value; | |
Write-Host "Replaced appSetting" $_.Key $_.Value; | |
} | |
} | |
if ($_.Key.StartsWith($connectionStringPrefix)) { | |
$key = $_.Key.Substring($connectionStringPrefix.Length); | |
$connStr = $doc.configuration.connectionStrings.add | Where-Object {$_.name -eq $key}; | |
if ($connStr) { | |
$connStr.connectionString = $_.Value; | |
Write-Host "Replaced connectionString" $_.Key $_.Value; | |
} | |
} | |
} | |
$doc.Save($webConfig); |
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
.\Set-WebConfigSettings.ps1 -webConfig .\Web.config | |
C:\ServiceMonitor.exe w3svc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment