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 6 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
20 changes: 2 additions & 18 deletions BotProject/Templates/CSharp/Scripts/build_runtime.ps1
Original file line number Diff line number Diff line change
@@ -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
dotnet build
2 changes: 1 addition & 1 deletion Composer/packages/client/src/store/action/bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,26 +61,31 @@ 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) {
buildDebug('%s', str);
});
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);
}
});
});
};
Expand Down Expand Up @@ -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`;
};

Expand All @@ -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;
}
};

Expand Down