Merge pull request #1641 from nagilson/nagilson-stderr-insr
Dont treat stderr as error for Install Scripts
This commit is contained in:
Коммит
7bacf7e79c
|
@ -43,13 +43,16 @@ You will need to restart VS Code after these changes. If PowerShell is still not
|
|||
this.fileUtilities = new FileUtilities();
|
||||
}
|
||||
|
||||
public async installDotnet(installContext: IDotnetInstallationContext): Promise<void> {
|
||||
public async installDotnet(installContext: IDotnetInstallationContext): Promise<void>
|
||||
{
|
||||
const winOS = os.platform() === 'win32';
|
||||
const installCommand = await this.getInstallCommand(installContext.version, installContext.installDir, installContext.installRuntime, installContext.architecture);
|
||||
const installKey = DotnetCoreAcquisitionWorker.getInstallKeyCustomArchitecture(installContext.version, installContext.architecture);
|
||||
|
||||
return new Promise<void>(async (resolve, reject) => {
|
||||
try {
|
||||
return new Promise<void>(async (resolve, reject) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
let windowsFullCommand = `powershell.exe -NoProfile -NonInteractive -NoLogo -ExecutionPolicy unrestricted -Command "& { [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12; & ${installCommand} }"`;
|
||||
if(winOS)
|
||||
{
|
||||
|
@ -59,37 +62,52 @@ You will need to restart VS Code after these changes. If PowerShell is still not
|
|||
|
||||
cp.exec(winOS ? windowsFullCommand : installCommand,
|
||||
{ cwd: process.cwd(), maxBuffer: 500 * 1024, timeout: 1000 * installContext.timeoutSeconds, killSignal: 'SIGKILL' },
|
||||
async (error, stdout, stderr) => {
|
||||
if (error) {
|
||||
if (stdout) {
|
||||
async (error, stdout, stderr) =>
|
||||
{
|
||||
if (error)
|
||||
{
|
||||
if (stdout)
|
||||
{
|
||||
this.eventStream.post(new DotnetAcquisitionScriptOutput(installKey, TelemetryUtilities.HashAllPaths(stdout)));
|
||||
}
|
||||
if (stderr) {
|
||||
if (stderr)
|
||||
{
|
||||
this.eventStream.post(new DotnetAcquisitionScriptOutput(installKey, `STDERR: ${TelemetryUtilities.HashAllPaths(stderr)}`));
|
||||
}
|
||||
|
||||
const online = await isOnline();
|
||||
if (!online) {
|
||||
if (!online)
|
||||
{
|
||||
const offlineError = new Error('No internet connection: Cannot install .NET');
|
||||
this.eventStream.post(new DotnetOfflineFailure(offlineError, installKey));
|
||||
reject(offlineError);
|
||||
} else if (error.signal === 'SIGKILL') {
|
||||
}
|
||||
else if (error.signal === 'SIGKILL') {
|
||||
error.message = timeoutConstants.timeoutMessage;
|
||||
this.eventStream.post(new DotnetAcquisitionTimeoutError(error, installKey, installContext.timeoutSeconds));
|
||||
reject(error);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
this.eventStream.post(new DotnetAcquisitionInstallError(error, installKey));
|
||||
reject(error);
|
||||
}
|
||||
} else if (stderr && stderr.length > 0) {
|
||||
this.eventStream.post(new DotnetAcquisitionScriptError(new Error(TelemetryUtilities.HashAllPaths(stderr)), installKey));
|
||||
reject(stderr);
|
||||
} else {
|
||||
}
|
||||
else if (stderr && stderr.length > 0)
|
||||
{
|
||||
this.eventStream.post(new DotnetAcquisitionScriptOutput(installKey, `STDERR: ${TelemetryUtilities.HashAllPaths(stderr)}`));
|
||||
this.eventStream.post(new DotnetAcquisitionCompleted(installKey, installContext.dotnetPath, installContext.version));
|
||||
resolve();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.eventStream.post(new DotnetAcquisitionCompleted(installKey, installContext.dotnetPath, installContext.version));
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
}
|
||||
catch (error)
|
||||
{
|
||||
this.eventStream.post(new DotnetAcquisitionUnexpectedError(error as Error, installKey));
|
||||
reject(error);
|
||||
}
|
||||
|
@ -103,7 +121,8 @@ You will need to restart VS Code after these changes. If PowerShell is still not
|
|||
'-Version', version,
|
||||
'-Verbose'
|
||||
];
|
||||
if (installRuntime) {
|
||||
if (installRuntime)
|
||||
{
|
||||
args = args.concat('-Runtime', 'dotnet');
|
||||
}
|
||||
if(arch !== 'auto')
|
||||
|
@ -116,12 +135,15 @@ You will need to restart VS Code after these changes. If PowerShell is still not
|
|||
}
|
||||
|
||||
private escapeFilePath(pathToEsc: string): string {
|
||||
if (os.platform() === 'win32') {
|
||||
if (os.platform() === 'win32')
|
||||
{
|
||||
// Need to escape apostrophes with two apostrophes
|
||||
const dotnetInstallDirEscaped = pathToEsc.replace(/'/g, `''`);
|
||||
// Surround with single quotes instead of double quotes (see https://github.com/dotnet/cli/issues/11521)
|
||||
return `'${dotnetInstallDirEscaped}'`;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
return `"${pathToEsc}"`;
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче