Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 15 additions & 10 deletions BotProject/Templates/CSharp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,32 @@ public static IHostBuilder CreateHostBuilder(string[] args) =>
.ConfigureAppConfiguration((hostingContext, builder) =>
{
var env = hostingContext.HostingEnvironment;

builder.AddJsonFile($"ComposerDialogs/settings/appsettings.json", optional: true, reloadOnChange: true)
.AddJsonFile("appsetting.json", optional: true, reloadOnChange: true)
.UseLuisConfigAdaptor()
.UseLuisSettings();

builder.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);

if (env.IsDevelopment())
{
// Local Debug
builder.AddJsonFile("appsettings.development.json", optional: true, reloadOnChange: true);
}
else

var configuration = builder.Build();

// Hard code the settings path to 'ComposerDialogs' while deployment
var botRoot = configuration.GetValue<string>("bot") ?? "ComposerDialogs";
var configFile = Path.GetFullPath(Path.Combine(botRoot, @"settings/appsettings.json"));

builder.AddJsonFile(configFile, optional: true, reloadOnChange: true);

// Need to put this part here to override the any customized settings
if (!env.IsDevelopment())
{
//Azure Deploy
builder.AddJsonFile("appsettings.deployment.json", optional: true, reloadOnChange: true);
}

if (!env.IsDevelopment())
{
builder.AddUserSecrets<Startup>();
}
builder.UseLuisConfigAdaptor()
.UseLuisSettings();

builder.AddEnvironmentVariables()
.AddCommandLine(args);
Expand Down
17 changes: 9 additions & 8 deletions BotProject/Templates/CSharp/Scripts/deploy.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,18 @@ dotnet publish -c release -o $publishFolder -v q > $logFile

# Copy bot files to running folder
$remoteBotPath = $(Join-Path $publishFolder "ComposerDialogs")
$localBotPath = $(Join-Path $projFolder "ComposerDialogs")
Remove-Item $remoteBotPath -Recurse -ErrorAction Ignore

if ($botPath) {
Write-Host "Publishing dialogs from external bot project: $($botPath)"
Copy-Item -Path $botPath -Recurse -Destination $remoteBotPath -Container -Force
}
else {
Copy-Item -Path $localBotPath -Recurse -Destination $publishFolder -Container -Force

if (-not $botPath) {
# If don't provide bot path, then try to copy all dialogs except the runtime folder in parent folder to the publishing folder (bin\Realse\ Folder)
$botPath = '..'
}

$botPath = $(Join-Path $botPath '*')
Write-Host "Publishing dialogs from external bot project: $($botPath)"
Copy-Item -Path (Get-Item -Path $botPath -Exclude ('runtime', 'generated')).FullName -Destination $remoteBotPath -Recurse -Force -Container

# Try to get luis config from appsettings
$settings = Get-Content $(Join-Path $projFolder appsettings.deployment.json) | ConvertFrom-Json
$luisSettings = $settings.luis
Expand Down Expand Up @@ -135,7 +136,7 @@ if ($luisAuthoringKey -and $luisAuthoringRegion) {
else {
Write-Host "bf luis:build does not exist, use the following command to install:"
Write-Host "1. npm config set registry https://botbuilder.myget.org/F/botframework-cli/npm/"
Write-Host "2. npm install -g @microsoft/botframework-cli"
Write-Host "2. npm install -g @microsoft/botframework-cli/4.9.0-preview.121555"
Write-Host "3. npm config set registry http://registry.npmjs.org"
Break
}
Expand Down
3 changes: 2 additions & 1 deletion BotProject/Templates/CSharp/appsettings.Deployment.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{

"bot": "ComposerDialogs",
"root": "ComposerDialogs"
}
3 changes: 2 additions & 1 deletion BotProject/Templates/CSharp/appsettings.Development.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{

"bot": "../",
"root": "../"
}
1 change: 0 additions & 1 deletion BotProject/Templates/CSharp/appsettings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"microsoftAppId": "",
"bot": "../",
"cosmosDb": {
"authKey": "",
"collectionId": "botstate-collection",
Expand Down