diff --git a/BotProject/Templates/CSharp/Scripts/build_runtime.ps1 b/BotProject/Templates/CSharp/Scripts/build_runtime.ps1 index dc6cd87d9a..0579956909 100644 --- a/BotProject/Templates/CSharp/Scripts/build_runtime.ps1 +++ b/BotProject/Templates/CSharp/Scripts/build_runtime.ps1 @@ -1,25 +1,9 @@ -Param( - [object] $config, - [string] $customSettingFolder, - [string] $luisAuthroingKey, - [SecureString] $appPassword, - [string] $projFolder = $(Join-Path $(Get-Location) BotProject CSharp) -) - -if ($PSVersionTable.PSVersion.Major -lt 6){ - Write-Host "! Powershell 6 is required, current version is $($PSVersionTable.PSVersion.Major), please refer following documents for help." - Write-Host "For Windows - https://docs.microsoft.com/en-us/powershell/scripting/install/installing-powershell-core-on-windows?view=powershell-6" - Write-Host "For Mac - https://docs.microsoft.com/en-us/powershell/scripting/install/installing-powershell-core-on-macos?view=powershell-6" - Break -} - if ((dotnet --version) -lt 3) { - Write-Host "! dotnet core 3.0 is required, please refer following documents for help." - Write-Host "https://dotnet.microsoft.com/download/dotnet-core/3.0" + throw "! dotnet core 3.0 is required, please refer following documents for help. https://dotnet.microsoft.com/download/dotnet-core/3.0" Break } # This command need dotnet core more than 3.0 dotnet user-secrets init -dotnet build \ No newline at end of file +dotnet build diff --git a/Composer/packages/client/src/store/action/bot.ts b/Composer/packages/client/src/store/action/bot.ts index e35dd7f6e5..1dacccf9af 100644 --- a/Composer/packages/client/src/store/action/bot.ts +++ b/Composer/packages/client/src/store/action/bot.ts @@ -28,7 +28,7 @@ export const connectBot: ActionCreator = async (store, settings) => { status: 'unConnected', }, }); - throw new Error(err.response.data.message); + throw new Error(err.response?.data?.message || err.message); } }; diff --git a/Composer/packages/server/src/models/connector/csharpBotConnector.ts b/Composer/packages/server/src/models/connector/csharpBotConnector.ts index d6d825e605..860f54bb5b 100644 --- a/Composer/packages/server/src/models/connector/csharpBotConnector.ts +++ b/Composer/packages/server/src/models/connector/csharpBotConnector.ts @@ -61,15 +61,16 @@ export class CSharpBotConnector implements IBotConnector { // build bot runtime return new Promise((resolve, reject) => { let shell = 'sh'; - let script = './Scripts/build_runtime.sh'; + let script = ['./Scripts/build_runtime.sh']; if (process.platform === 'win32') { - shell = 'pwsh'; - script = './Scripts/build_runtime.ps1'; + shell = 'powershell'; + script = ['-executionpolicy', 'bypass', '-file', './Scripts/build_runtime.ps1']; } - const build = spawn(`${shell}`, [`${script}`], { + const build = spawn(`${shell}`, script, { cwd: dir, stdio: ['pipe', 'pipe', 'pipe'], }); + let errorMsg = ''; buildDebug('building bot runtime: %d', build.pid); build.stdout && build.stdout.on('data', function(str) { @@ -77,10 +78,14 @@ export class CSharpBotConnector implements IBotConnector { }); build.stderr && build.stderr.on('data', function(err) { - reject(err.toString()); + errorMsg = errorMsg + err.toString(); }); build.on('exit', function(code) { - resolve(code); + if (code !== 0) { + reject(errorMsg); + } else { + resolve(code); + } }); }); }; @@ -162,6 +167,7 @@ export class CSharpBotConnector implements IBotConnector { connect = async (_: BotEnvironments, __: string) => { const originPort = urlParse(this.endpoint).port; const port = await getPort({ host: 'localhost', port: parseInt(originPort || '3979') }); + this.endpoint = `http://localhost:${port}`; return `http://localhost:${port}/api/messages`; }; @@ -177,7 +183,7 @@ export class CSharpBotConnector implements IBotConnector { } catch (err) { this.stop(); this.status = BotStatus.NotConnected; - throw new Error('Error while syncing bot runtime.'); + throw err; } };