diff --git a/extensions/sql-database-projects/src/test/netCoreTool.test.ts b/extensions/sql-database-projects/src/test/netCoreTool.test.ts index 2fc458d856..5bb3bc1210 100644 --- a/extensions/sql-database-projects/src/test/netCoreTool.test.ts +++ b/extensions/sql-database-projects/src/test/netCoreTool.test.ts @@ -9,9 +9,8 @@ import * as fs from 'fs'; import * as path from 'path'; import * as vscode from 'vscode'; import * as sinon from 'sinon'; -import { NetCoreTool, DBProjectConfigurationKey, DotnetInstallLocationKey, NetCoreNonWindowsDefaultPath } from '../tools/netcoreTool'; +import { NetCoreTool, DBProjectConfigurationKey, DotnetInstallLocationKey } from '../tools/netcoreTool'; import { getQuotedPath } from '../common/utils'; -import { isNullOrUndefined } from 'util'; import { generateTestFolderPath } from './testUtils'; import { createContext, TestContext } from './testContext'; @@ -48,14 +47,20 @@ describe('NetCoreTool: Net core tests', function (): void { if (os.platform() === 'win32') { // check that path should start with c:\program files - let result = isNullOrUndefined(netcoreTool.netcoreInstallLocation) || netcoreTool.netcoreInstallLocation.toLowerCase().startsWith('c:\\program files'); - should(result).true('dotnet is either not present or in programfiles by default'); + let result = !netcoreTool.netcoreInstallLocation || netcoreTool.netcoreInstallLocation.toLowerCase().startsWith('c:\\program files'); + should(result).true('dotnet not present in programfiles by default'); } - if (os.platform() === 'linux' || os.platform() === 'darwin') { + if (os.platform() === 'linux'){ + //check that path should start with /usr/share + let result = !netcoreTool.netcoreInstallLocation || netcoreTool.netcoreInstallLocation.toLowerCase() === '/usr/share/dotnet'; + should(result).true('dotnet not present in /usr/share'); + } + + if (os.platform() === 'darwin') { //check that path should start with /usr/local/share - let result = isNullOrUndefined(netcoreTool.netcoreInstallLocation) || netcoreTool.netcoreInstallLocation.toLowerCase().startsWith(NetCoreNonWindowsDefaultPath); - should(result).true('dotnet is either not present or in /usr/local/share by default'); + let result = !netcoreTool.netcoreInstallLocation || netcoreTool.netcoreInstallLocation.toLowerCase() === '/usr/local/share/dotnet'; + should(result).true('dotnet not present in /usr/local/share'); } }); diff --git a/extensions/sql-database-projects/src/tools/netcoreTool.ts b/extensions/sql-database-projects/src/tools/netcoreTool.ts index 9d3e656be2..cce0eb293a 100644 --- a/extensions/sql-database-projects/src/tools/netcoreTool.ts +++ b/extensions/sql-database-projects/src/tools/netcoreTool.ts @@ -20,7 +20,8 @@ export const DBProjectConfigurationKey: string = 'sqlDatabaseProjects'; export const NetCoreInstallLocationKey: string = 'netCoreSDKLocation'; export const DotnetInstallLocationKey: string = 'dotnetSDK Location'; export const NetCoreDoNotAskAgainKey: string = 'netCoreDoNotAsk'; -export const NetCoreNonWindowsDefaultPath = '/usr/local/share'; +export const NetCoreMacDefaultPath = '/usr/local/share'; +export const NetCoreLinuxDefaultPath = '/usr/share'; export const winPlatform: string = 'win32'; export const macPlatform: string = 'darwin'; export const linuxPlatform: string = 'linux'; @@ -101,14 +102,20 @@ export class NetCoreTool extends ShellExecutionHelper { private get defaultLocalInstallLocationByDistribution(): string | undefined { switch (this.osPlatform) { case winPlatform: return this.defaultWindowsLocation; - case macPlatform: - case linuxPlatform: return this.defaultnonWindowsLocation; + case macPlatform: return this.defaultMacLocation; + case linuxPlatform: return this.defaultLinuxLocation; default: return undefined; } } - private get defaultnonWindowsLocation(): string | undefined { - return this.getDotnetPathIfPresent(NetCoreNonWindowsDefaultPath) || //default folder for net core sdk + private get defaultMacLocation(): string | undefined { + return this.getDotnetPathIfPresent(NetCoreMacDefaultPath) || //default folder for net core sdk on Mac + this.getDotnetPathIfPresent(os.homedir()) || + undefined; + } + + private get defaultLinuxLocation(): string | undefined { + return this.getDotnetPathIfPresent(NetCoreLinuxDefaultPath) || //default folder for net core sdk on Linux this.getDotnetPathIfPresent(os.homedir()) || undefined; }