Skip to content

Commit

Permalink
Merge branch 'main' into nagilson-does-install-still-exist
Browse files Browse the repository at this point in the history
  • Loading branch information
nagilson authored Jan 18, 2024
2 parents 9ddec9e + 9e31011 commit 6e264bd
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 4 deletions.
18 changes: 17 additions & 1 deletion vscode-dotnet-runtime-library/distro-data/distro-support.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,16 @@
"commandParts": ["-l", "{packageName}"]
}
],
"readSymLinkCommand":
[
{
"runUnderSudo": false,
"commandRoot": "readlink",
"commandParts": ["-f", "{path}"]
}
],
"expectedDistroFeedInstallDirectory" : "/usr/lib/dotnet",
"expectedMicrosoftFeedInstallDirectory" : "/usr/bin/dotnet",
"expectedMicrosoftFeedInstallDirectory" : "/usr/share/dotnet",
"installedSDKVersionsCommand":
[
{
Expand Down Expand Up @@ -255,6 +263,14 @@
]
}
],
"readSymLinkCommand":
[
{
"runUnderSudo": false,
"commandRoot": "readlink",
"commandParts": ["-f", "{path}"]
}
],
"expectedDistroFeedInstallDirectory": "/usr/lib64/dotnet/dotnet",
"expectedMicrosoftFeedInstallDirectory": "",
"installedSDKVersionsCommand": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import { IDistroDotnetSDKProvider } from './IDistroDotnetSDKProvider';

export class GenericDistroSDKProvider extends IDistroDotnetSDKProvider
{
protected resolvePathAsSymlink = true;

public async installDotnet(fullySpecifiedVersion : string, installType : LinuxInstallType): Promise<string>
{
await this.injectPMCFeed(fullySpecifiedVersion, installType);
Expand All @@ -37,6 +39,18 @@ export class GenericDistroSDKProvider extends IDistroDotnetSDKProvider
{
commandResult[0] = commandResult[0].trim();
}

if(commandResult && this.resolvePathAsSymlink)
{
let symLinkReadCommand = this.myDistroCommands(this.readSymbolicLinkCommandKey);
symLinkReadCommand = CommandExecutor.replaceSubstringsInCommands(symLinkReadCommand, this.missingPathKey, commandResult[0]);
const resolvedPath = (await this.commandRunner.executeMultipleCommands(symLinkReadCommand))[0];
if(resolvedPath)
{
return path.dirname(resolvedPath.trim());
}
}

return commandResult[0];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export abstract class IDistroDotnetSDKProvider {
protected searchCommandKey = 'searchCommand';
protected updateCommandKey = 'updateCommand';
protected packageLookupCommandKey = 'packageLookupCommand';
protected readSymbolicLinkCommandKey = 'readSymLinkCommand';
protected currentInstallPathCommandKey = 'currentInstallPathCommand';
protected isInstalledCommandKey = 'isInstalledCommand';
protected expectedMicrosoftFeedInstallDirKey = 'expectedMicrosoftFeedInstallDirectory';
Expand All @@ -51,6 +52,7 @@ export abstract class IDistroDotnetSDKProvider {
protected installedRuntimeVersionsCommandKey = 'installedRuntimeVersionsCommand';
protected currentInstallVersionCommandKey = 'currentInstallationVersionCommand';
protected missingPackageNameKey = '{packageName}';
protected missingPathKey = '{path}';

protected distroVersionsKey = 'versions';
protected versionKey = 'version';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,22 @@
* The .NET Foundation licenses this file to you under the MIT license.
* Licensed under the MIT License. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */
import { ICommandExecutor } from '../Utils/ICommandExecutor';
import { IUtilityContext } from '../Utils/IUtilityContext';
import { GenericDistroSDKProvider } from './GenericDistroSDKProvider';
import { IAcquisitionWorkerContext } from './IAcquisitionWorkerContext';
import { LinuxInstallType } from './LinuxInstallType';
import { DistroVersionPair } from './LinuxVersionResolver';
/* tslint:disable:no-any */

export class RedHatDistroSDKProvider extends GenericDistroSDKProvider
{
constructor(distroVersion : DistroVersionPair, context : IAcquisitionWorkerContext, utilContext : IUtilityContext, executor : ICommandExecutor | null = null)
{
super(distroVersion, context, utilContext, executor);
this.resolvePathAsSymlink = false;
}

protected myVersionDetails() : any
{
const distroVersions = this.distroJson[this.distroVersion.distro][this.distroVersionsKey];
Expand Down
4 changes: 3 additions & 1 deletion vscode-dotnet-runtime-library/src/Utils/CommandExecutor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ Please install the .NET SDK manually by following https://learn.microsoft.com/en
return new Promise<string>((resolve, reject) =>
{
// The '.' character is not allowed for sudo-prompt so we use 'NET'
const options = { name: `${this.context?.acquisitionContext?.requestingExtensionId} On behalf of NET Install Tool` };
let sanitizedCallerName = this.context?.acquisitionContext?.requestingExtensionId?.replace(/[^0-9a-z]/gi, ''); // Remove non-alphanumerics per OS requirements
sanitizedCallerName = sanitizedCallerName?.substring(0, 69); // 70 Characters is the maximum limit we can use for the prompt.
const options = { name: `${sanitizedCallerName ?? '.NET Install Tool'}` };
exec((fullCommandString), options, (error?: any, stdout?: any, stderr?: any) =>
{
let commandResultString = '';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ suite('Linux Distro Logic Unit Tests', () =>
if(shouldRun)
{
const microsoftFeedDir = await provider.getExpectedDotnetMicrosoftFeedInstallationDirectory();
assert.equal(microsoftFeedDir, '/usr/bin/dotnet');
assert.equal(microsoftFeedDir, '/usr/share/dotnet');
}
}).timeout(standardTimeoutTime);

Expand Down Expand Up @@ -104,7 +104,7 @@ Microsoft.NETCore.App 7.0.5 [/usr/lib/dotnet/shared/Microsoft.NETCore.App]`;
if(shouldRun)
{
await provider.getInstalledGlobalDotnetPathIfExists(installType);
assert.equal(mockExecutor.attemptedCommand, 'which dotnet');
assert.equal(mockExecutor.attemptedCommand, 'readlink -f /usr/bin/dotnet');
}
}).timeout(standardTimeoutTime);

Expand Down

0 comments on commit 6e264bd

Please sign in to comment.