forked from microsoft/BotFramework-Composer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate_runtime.ps1
49 lines (41 loc) · 1.75 KB
/
generate_runtime.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
Param(
[string] $destinationFolder,
[string] $luisAuthroingKey,
[SecureString] $appPassword,
[string] $projFolder = $(Join-Path $(Get-Location) "runtime/dotnet")
)
$destinationFolder = $(Join-Path $destinationFolder BotRuntime)
# Copy the whole project folder to destination folder
if (Test-Path $projFolder)
{
Copy-Item -Path $projFolder -Recurse -Destination $destinationFolder -Container -Force
}
# Merge the appsettings.json in destination folder with the customized appsettings.json in /settings folder
$settingFolder = $(Join-Path $destinationFolder .. settings)
if (Test-Path $settingFolder)
{
$customConfigFiles = Get-ChildItem -Path $settingFolder -Include appsettings.json -Recurse -Force
if ($customConfigFiles)
{
if (Test-Path $(Join-Path $destinationFolder appsettings.json)) {
$settings = Get-Content $(Join-Path $destinationFolder appsettings.json) | ConvertFrom-Json
}
else {
$settings = New-Object PSObject
}
$customConfig = @{}
$customSetting = Get-Content $customConfigFiles.FullName | ConvertFrom-Json
$customSetting.PSObject.Properties | Foreach-Object { $customConfig[$_.Name] = $_.Value }
foreach ($key in $customConfig.Keys) { $settings | Add-Member -Type NoteProperty -Force -Name $key -Value $customConfig[$key] }
$settings | Add-Member -Type NoteProperty -Force -Name bot -Value ..
$settings | ConvertTo-Json -depth 100 | Out-File $(Join-Path $destinationFolder appsettings.json)
}
}
if ($luisAuthroingKey)
{
dotnet user-secrets set "luis:endpointKey" $luisAuthroingKey --project $destinationFolder
}
if ($appPassword)
{
dotnet user-secrets set "MicrosoftAppPassword" $appPassword --project $destinationFolder
}