diff --git a/BotProject/Templates/CSharp/Program.cs b/BotProject/Templates/CSharp/Program.cs index d386d076f7..fd4a5e14f0 100644 --- a/BotProject/Templates/CSharp/Program.cs +++ b/BotProject/Templates/CSharp/Program.cs @@ -2,6 +2,7 @@ // Licensed under the MIT License. using System; +using System.Diagnostics; using System.IO; using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; @@ -22,14 +23,23 @@ public static IWebHost BuildWebHost(string[] args) => { var env = hostingContext.HostingEnvironment; var luisAuthoringRegion = Environment.GetEnvironmentVariable("LUIS_AUTHORING_REGION") ?? "westus"; - var luisSettingFiles = Directory.GetFiles($"ComposerDialogs\\generated", "luis.settings.*.json"); config .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true) .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true, reloadOnChange: true) .AddJsonFile($"ComposerDialogs/settings/appsettings.json", optional: true, reloadOnChange: true) - .AddJsonFile(luisSettingFiles.Length > 0 ? luisSettingFiles[0] : string.Empty, optional: true, reloadOnChange: true) .AddJsonFile($"luis.settings.{env.EnvironmentName}.{luisAuthoringRegion}.json", optional: true, reloadOnChange: true) .AddJsonFile($"luis.settings.{Environment.UserName}.{luisAuthoringRegion}.json", optional: true, reloadOnChange: true); + try + { + foreach (string filePath in Directory.GetFiles($"ComposerDialogs", "generated/luis.settings.*.json")) + { + config.AddJsonFile(filePath, optional: true, reloadOnChange: true); + } + } + catch (Exception ex) + { + Trace.WriteLine(ex.Message); + } if (env.IsDevelopment()) { @@ -41,6 +51,5 @@ public static IWebHost BuildWebHost(string[] args) => .AddCommandLine(args); }).UseStartup() .Build(); - } } diff --git a/Composer/packages/server/src/models/connector/build_runtime.ps1 b/BotProject/Templates/CSharp/Scripts/build_runtime.ps1 similarity index 100% rename from Composer/packages/server/src/models/connector/build_runtime.ps1 rename to BotProject/Templates/CSharp/Scripts/build_runtime.ps1 diff --git a/Composer/packages/server/src/models/connector/csharpBotConnector.ts b/Composer/packages/server/src/models/connector/csharpBotConnector.ts index a31aa030fe..44a6a6a0d0 100644 --- a/Composer/packages/server/src/models/connector/csharpBotConnector.ts +++ b/Composer/packages/server/src/models/connector/csharpBotConnector.ts @@ -49,7 +49,7 @@ export class CSharpBotConnector implements IBotConnector { private buildProcess = async (dir: string): Promise => { return new Promise((resolve, reject) => { - const startScript = Path.resolve(__dirname, './build_runtime.ps1'); + const startScript = Path.resolve(dir, './Scripts/build_runtime.ps1'); console.log(startScript); const build = spawn(`pwsh ${startScript}`, { cwd: dir, @@ -144,23 +144,20 @@ export class CSharpBotConnector implements IBotConnector { stdio: ['ignore', 'ignore', 'inherit'], } ); + console.log(`start runtime at ${this.runtime.pid}`); this.addListeners(this.runtime, this.stop); }; connect = async (_: BotEnvironments, __: string) => { // confirm bot runtime is listening here - try { - const dir = this.getBotPath(); - await this.buildProcess(dir); - return Promise.resolve(`${this.endpoint}/api/messages`); - } catch (err) { - throw new Error(err); - } + return Promise.resolve(`${this.endpoint}/api/messages`); }; sync = async (config: DialogSetting) => { try { + this.stop(); const dir = this.getBotPath(); + await this.buildProcess(dir); await this.start(dir, config); } catch (err) { this.stop(); diff --git a/Composer/packages/server/src/models/environment/defaultEnvironment.ts b/Composer/packages/server/src/models/environment/defaultEnvironment.ts index c18d8a9290..21a3b00f4d 100644 --- a/Composer/packages/server/src/models/environment/defaultEnvironment.ts +++ b/Composer/packages/server/src/models/environment/defaultEnvironment.ts @@ -18,6 +18,7 @@ export class DefaultEnvironment implements IEnvironment { public constructor(config: IEnvironmentConfig) { this.config = config; this.settingManager = new DefaultSettingManager(this.config.basePath); + console.log(this.config.basePath); this.botConnector = new CSharpBotConnector(this.config.endpoint); }