-
Notifications
You must be signed in to change notification settings - Fork 330
findPath API Finds Extension Managed Runtimes #2293
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ import { DOTNET_INFORMATION_CACHE_DURATION_MS } from './CacheTimeConstants'; | |
import { IAcquisitionWorkerContext } from './IAcquisitionWorkerContext'; | ||
import { IDotnetConditionValidator } from './IDotnetConditionValidator'; | ||
import { IDotnetListInfo } from './IDotnetListInfo'; | ||
import { InstallRecordWithPath } from './InstallRecordWithPath'; | ||
import * as versionUtils from './VersionUtilities'; | ||
|
||
type simplifiedVersionSpec = 'equal' | 'greater_than_or_equal' | 'less_than_or_equal' | | ||
|
@@ -172,35 +173,11 @@ Please set the PATH to a dotnet host that matches the architecture ${requirement | |
|
||
if (availableMinor === requestedMinor && requestedPatch) | ||
{ | ||
const availablePatchStr: string | null = requirement.acquireContext.mode !== 'sdk' ? | ||
versionUtils.getRuntimePatchVersionString(availableVersion, this.workerContext.eventStream, this.workerContext) | ||
: | ||
(() => | ||
{ | ||
const band = versionUtils.getSDKCompleteBandAndPatchVersionString(availableVersion, this.workerContext.eventStream, this.workerContext); | ||
if (band) | ||
{ | ||
return band; | ||
} | ||
return null; | ||
})(); | ||
const availablePatch = availablePatchStr ? Number(availablePatchStr) : null; | ||
|
||
const availableBandStr: string | null = requirement.acquireContext.mode === 'sdk' ? | ||
(() => | ||
{ | ||
const featureBand = versionUtils.getFeatureBandFromVersion(availableVersion, this.workerContext.eventStream, this.workerContext, false); | ||
if (featureBand) | ||
{ | ||
return featureBand; | ||
} | ||
return null; | ||
})() : null; | ||
const availableBand = availableBandStr ? Number(availableBandStr) : null; | ||
const availablePatch = this.getPatchOrFeatureBandWithPatch(availableVersion, requirement); | ||
|
||
switch (adjustedVersionSpec) | ||
{ | ||
// the 'availablePatch' must exist, since the version is from --list-runtimes or --list-sdks. | ||
// the 'availablePatch' must exist, since the version is from --list-runtimes or --list-sdks, or our internal tracking of installs. | ||
case 'equal': | ||
return availablePatch === requestedPatch; | ||
case 'greater_than_or_equal': | ||
|
@@ -209,6 +186,7 @@ Please set the PATH to a dotnet host that matches the architecture ${requirement | |
case 'less_than_or_equal': | ||
return availablePatch! <= requestedPatch; | ||
case 'latestPatch': | ||
const availableBand = this.getFeatureBand(availableVersion, requirement); | ||
const requestedBandStr = requirement.acquireContext.mode === 'sdk' ? versionUtils.getFeatureBandFromVersion(requestedVersion, this.workerContext.eventStream, this.workerContext, false) ?? null : null; | ||
const requestedBand = requestedBandStr ? Number(requestedBandStr) : null; | ||
return availablePatch! >= requestedPatch && (availableBand ? availableBand === requestedBand : true); | ||
|
@@ -226,7 +204,10 @@ Please set the PATH to a dotnet host that matches the architecture ${requirement | |
return availableMinor <= requestedMinor; | ||
case 'latestPatch': | ||
case 'latestFeature': | ||
return false | ||
const availableBand = this.getFeatureBand(availableVersion, requirement); | ||
const requestedBandStr = requirement.acquireContext.mode === 'sdk' ? versionUtils.getFeatureBandFromVersion(requestedVersion, this.workerContext.eventStream, this.workerContext, false) ?? null : null; | ||
const requestedBand = requestedBandStr ? Number(requestedBandStr) : null; | ||
return availableMinor === requestedMinor && (availableBand ? availableBand === requestedBand : true); | ||
} | ||
} | ||
} | ||
|
@@ -247,6 +228,45 @@ Please set the PATH to a dotnet host that matches the architecture ${requirement | |
} | ||
} | ||
|
||
private getFeatureBand(availableVersion: string, requirement: IDotnetFindPathContext): number | null | ||
{ | ||
const availableBandStr: string | null = requirement.acquireContext.mode === 'sdk' ? | ||
(() => | ||
{ | ||
const featureBand = versionUtils.getFeatureBandFromVersion(availableVersion, this.workerContext.eventStream, this.workerContext, false); | ||
if (featureBand) | ||
{ | ||
return featureBand; | ||
} | ||
return null; | ||
})() : null; | ||
return availableBandStr ? Number(availableBandStr) : null; | ||
} | ||
|
||
private getPatchOrFeatureBandWithPatch(availableVersion: string, requirement: IDotnetFindPathContext): number | null | ||
{ | ||
const availablePatchStr: string | null = requirement.acquireContext.mode !== 'sdk' ? | ||
versionUtils.getRuntimePatchVersionString(availableVersion, this.workerContext.eventStream, this.workerContext) | ||
: | ||
(() => | ||
{ | ||
Comment on lines
+250
to
+252
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: Is this style intended? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is auto-formatted within the style guidelines set by the project, so in a way, yes.. |
||
const band = versionUtils.getSDKCompleteBandAndPatchVersionString(availableVersion, this.workerContext.eventStream, this.workerContext); | ||
if (band) | ||
{ | ||
return band; | ||
} | ||
return null; | ||
})(); | ||
|
||
const availablePatch = availablePatchStr ? Number(availablePatchStr) : null; | ||
return availablePatch; | ||
} | ||
|
||
public filterValidPaths(recordPaths: InstallRecordWithPath[], requirement: IDotnetFindPathContext): InstallRecordWithPath[] | ||
{ | ||
return recordPaths.filter(installInfo => this.stringVersionMeetsRequirement(installInfo.installRecord.dotnetInstall.version, requirement.acquireContext.version, requirement)); | ||
} | ||
|
||
private stringArchitectureMeetsRequirement(outputArchitecture: string, requiredArchitecture: string | null | undefined): boolean | ||
{ | ||
return !requiredArchitecture || !outputArchitecture || FileUtilities.dotnetInfoArchToNodeArch(outputArchitecture, this.workerContext.eventStream) === requiredArchitecture; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Licensed to the .NET Foundation under one or more agreements. | ||
* The .NET Foundation licenses this file to you under the MIT license. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
import { InstallRecord } from './InstallRecord'; | ||
|
||
/** | ||
* Represents a .NET installation record along with its filesystem path | ||
*/ | ||
export interface InstallRecordWithPath | ||
{ | ||
installRecord: InstallRecord; | ||
path: string; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Our SDKs are global, so they will be picked up by the existing logic.