Skip to content

Commit bbfd8f7

Browse files
authored
Update aspnetcore-set-environment-variable-iis to support '=' (#1532)
1 parent 811251b commit bbfd8f7

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

step-templates/aspnetcore-set-environment-variable-iis.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
"Name": "ASP.NET Core Set Environment Variables Via IIS Config",
55
"Description": "Set environment variables in IIS config (no web.config)",
66
"ActionType": "Octopus.Script",
7-
"Version": 1,
7+
"Version": 2,
88
"Packages": [],
99
"Properties": {
10-
"Octopus.Action.Script.ScriptBody": "function AddOrReplaceEnvironmentVariable {\n param\n (\n [string] $variableName, \n [string] $variableValue,\n [string] $siteName,\n [string] $appCmd\n )\n\n Try {\n [xml] $xmlConfig = (&$appCmd list config $sev_siteName -section:system.webServer/aspNetCore)\n }\n Catch {\n Write-Host $sev_siteName 'either does not exist or is not an AspNetCore site!'\n exit -1\n }\n\n if($xmlConfig.selectNodes(\"//environmentVariable[@name='$variableName']\")) {\n &$appCmd set config $sev_siteName -section:system.webServer/aspNetCore /-\"environmentVariables.[name='$variableName',value='$variableValue']\" /commit:apphost\n }\n \n &$appCmd set config $sev_siteName -section:system.webServer/aspNetCore /+\"environmentVariables.[name='$variableName',value='$variableValue']\" /commit:apphost\n}\n\n[string] $sev_siteName=$OctopusParameters['sev_siteName']\n[string] $sev_envVariables=$OctopusParameters['sev_envVariables']\n[string] $sev_appCmdPath=$OctopusParameters['sev_appCmdPath']\n\nWrite-Host \"---------------------------\"\nWrite-Host $sev_envVariables\nWrite-Host $sev_appCmdPath\nWrite-Host \"---------------------------\"\n\n$appCmd = Join-Path $sev_appCmdPath 'appcmd.exe'\n\nforeach($line in $sev_envVariables -split '\\r?\\n') {\n $keyValuePair = $line -split '='\n\n AddOrReplaceEnvironmentVariable $keyValuePair[0] $keyValuePair[1] $sev_siteName $appCmd\n}\n",
10+
"Octopus.Action.Script.ScriptBody": "function AddOrReplaceEnvironmentVariable {\n param\n (\n [string] $variableName, \n [string] $variableValue,\n [string] $siteName,\n [string] $appCmd\n )\n\n Try {\n [xml] $xmlConfig = (&$appCmd list config $sev_siteName -section:system.webServer/aspNetCore)\n }\n Catch {\n Write-Host $sev_siteName 'either does not exist or is not an AspNetCore site!'\n exit -1\n }\n\n if($xmlConfig.selectNodes(\"//environmentVariable[@name='$variableName']\")) {\n &$appCmd set config $sev_siteName -section:system.webServer/aspNetCore /-\"environmentVariables.[name='$variableName',value='$variableValue']\" /commit:apphost\n }\n \n &$appCmd set config $sev_siteName -section:system.webServer/aspNetCore /+\"environmentVariables.[name='$variableName',value='$variableValue']\" /commit:apphost\n}\n\n[string] $sev_siteName=$OctopusParameters['sev_siteName']\n[string] $sev_envVariables=$OctopusParameters['sev_envVariables']\n[string] $sev_appCmdPath=$OctopusParameters['sev_appCmdPath']\n\nWrite-Host \"---------------------------\"\nWrite-Host $sev_envVariables\nWrite-Host $sev_appCmdPath\nWrite-Host \"---------------------------\"\n\n$appCmd = Join-Path $sev_appCmdPath 'appcmd.exe'\n\nforeach($line in $sev_envVariables -split '\\r?\\n') {\n $indexOfEquals = $line.IndexOf('=')\n if ($indexOfEquals -eq -1) {\n Write-Host \"Invalid environment variable format: $line\"\n continue\n }\n $key = $line.Substring(0, $indexOfEquals)\n $value = $line.Substring($indexOfEquals + 1)\n\n AddOrReplaceEnvironmentVariable $key $value $sev_siteName $appCmd\n}\n",
1111
"Octopus.Action.Script.Syntax": "PowerShell",
1212
"Octopus.Action.Script.ScriptSource": "Inline",
1313
"Octopus.Action.RunOnServer": "false"
@@ -44,11 +44,11 @@
4444
}
4545
}
4646
],
47-
"LastModifiedBy": "waxtell",
47+
"LastModifiedBy": "geeknz",
4848
"$Meta": {
49-
"ExportedAt": "2020-08-11T17:06:34.462Z",
50-
"OctopusVersion": "2020.1.4",
49+
"ExportedAt": "2024-07-15T22:40:29.070Z",
50+
"OctopusVersion": "2024.2.9220",
5151
"Type": "ActionTemplate"
5252
},
5353
"Category": "dotnetcore"
54-
}
54+
}

0 commit comments

Comments
 (0)