-
-
Notifications
You must be signed in to change notification settings - Fork 278
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
force roll forward when discovered .NET version is greater than FSAC TFM #1889
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -207,7 +207,7 @@ Consider: | |
} | ||
|
||
/// runs `dotnet --version` in the current rootPath to determine the resolved sdk version from the global.json file. | ||
let runtimeVersion () = | ||
let sdkVersion () = | ||
promise { | ||
let! dotnet = tryFindDotnet () | ||
|
||
|
@@ -683,11 +683,11 @@ Consider: | |
|
||
if availableTFMs |> Seq.contains tfm then | ||
printfn "TFM match found" | ||
node.path.join (basePath, tfm, "fsautocomplete.dll") | ||
tfm, node.path.join (basePath, tfm, "fsautocomplete.dll") | ||
else | ||
// find best-matching | ||
let tfm = findBestTFM availableTFMs tfm | ||
node.path.join (basePath, tfm, "fsautocomplete.dll") | ||
tfm, node.path.join (basePath, tfm, "fsautocomplete.dll") | ||
|
||
let isNetFolder (folder: string) = | ||
printfn $"checking folder %s{folder}" | ||
|
@@ -697,7 +697,8 @@ Consider: | |
&& let stat = node.fs.statSync (!!folder) in | ||
stat.isDirectory () | ||
|
||
let fsacPathForTfm (tfm: string) = | ||
/// locates the FSAC dll and TFM for that dll given a host TFM | ||
let fsacPathForTfm (tfm: string): string * string = | ||
match fsacNetcorePath with | ||
| null | ||
| "" -> | ||
|
@@ -706,7 +707,8 @@ Consider: | |
probePathForTFMs binPath tfm | ||
| userSpecified -> | ||
if userSpecified.EndsWith ".dll" then | ||
userSpecified | ||
let tfm = node.path.basename(node.path.dirname userSpecified) | ||
tfm, userSpecified | ||
else | ||
// if dir has tfm folders, probe | ||
let filesAndFolders = | ||
|
@@ -720,7 +722,8 @@ Consider: | |
probePathForTFMs userSpecified tfm | ||
else | ||
// no tfm paths, try to use `fsautocomplete.dll` from this directory | ||
node.path.join (userSpecified, "fsautocomplete.dll") | ||
let tfm = node.path.basename(node.path.dirname userSpecified) | ||
tfm, node.path.join (userSpecified, "fsautocomplete.dll") | ||
|
||
let tfmForSdkVersion (v: SemVer) = | ||
match int v.major, int v.minor with | ||
|
@@ -732,64 +735,51 @@ Consider: | |
|
||
let discoverDotnetArgs () = | ||
promise { | ||
let! (rollForwardArgs, necessaryEnvVariables, fsacPath) = | ||
promise { | ||
let! sdkVersionAtRootPath = runtimeVersion () | ||
|
||
match sdkVersionAtRootPath with | ||
| Error e -> | ||
printfn $"FSAC (NETCORE): {e}" | ||
return [], [], "" | ||
| Ok v -> | ||
printfn "Parsed SDK version at root path: %s" v.raw | ||
let tfm = tfmForSdkVersion v | ||
printfn "Parsed SDK version to tfm: %s" tfm | ||
let fsacPath = fsacPathForTfm tfm | ||
printfn "Parsed TFM to fsac path: %s" fsacPath | ||
return [], [], fsacPath | ||
// if v.major >= 6.0 then | ||
// // when we run on a sdk higher than 6.x (aka what FSAC is currently built/targeted for), | ||
// // we have to tell the runtime to allow it to actually run on that runtime (instead of presenting 6.x as 5.x) | ||
// // in order for msbuild resolution to work | ||
// let args = [ "--roll-forward"; "LatestMajor" ] | ||
|
||
// let envs = | ||
// if v.prerelease <> null || v.prerelease.Count > 0 then | ||
// [ "DOTNET_ROLL_FORWARD_TO_PRERELEASE", box 1 ] | ||
// else | ||
// [] | ||
|
||
// return args, envs, fsacPath | ||
// else | ||
// return [], [], fsacPath | ||
} | ||
|
||
let userDotnetArgs = "FSharp.fsac.dotnetArgs" |> Configuration.get [||] | ||
|
||
let hasUserRollForward = | ||
userDotnetArgs | ||
|> Array.tryFindIndex (fun a -> a = "--roll-forward") | ||
|> Option.map (fun _ -> true) | ||
|> Option.defaultValue false | ||
|
||
let hasUserFxVersion = | ||
userDotnetArgs | ||
|> Array.tryFindIndex (fun a -> a = "--fx-version") | ||
|> Option.map (fun _ -> true) | ||
|> Option.defaultValue false | ||
|
||
let shouldApplyImplicitRollForward = not (hasUserFxVersion || hasUserRollForward) | ||
|
||
let args = | ||
[ if shouldApplyImplicitRollForward then | ||
yield! rollForwardArgs | ||
yield! userDotnetArgs ] | ||
|
||
let envVariables = | ||
[ if shouldApplyImplicitRollForward then | ||
yield! necessaryEnvVariables ] | ||
|
||
return args, envVariables, fsacPath | ||
let! sdkVersionAtRootPath = sdkVersion () | ||
|
||
match sdkVersionAtRootPath with | ||
| Error e -> | ||
printfn $"Error finding dotnet version: {e}" | ||
return failwith "Error finding dotnet version, do you have dotnet installed and on the PATH?" | ||
| Ok sdkVersion -> | ||
printfn "Parsed SDK version at root path: %s" sdkVersion.raw | ||
let sdkTfm = tfmForSdkVersion sdkVersion | ||
printfn "Parsed SDK version to tfm: %s" sdkTfm | ||
let fsacTfm, fsacPath = fsacPathForTfm sdkTfm | ||
printfn "Parsed TFM to fsac path: %s" fsacPath | ||
|
||
let userDotnetArgs = "FSharp.fsac.dotnetArgs" |> Configuration.get [||] | ||
|
||
let hasUserRollForward = | ||
userDotnetArgs | ||
|> Array.tryFindIndex (fun a -> a = "--roll-forward") | ||
|> Option.map (fun _ -> true) | ||
|> Option.defaultValue false | ||
|
||
let hasUserFxVersion = | ||
userDotnetArgs | ||
|> Array.tryFindIndex (fun a -> a = "--fx-version") | ||
|> Option.map (fun _ -> true) | ||
|> Option.defaultValue false | ||
|
||
let shouldApplyImplicitRollForward = | ||
not (hasUserFxVersion || hasUserRollForward) | ||
&& sdkTfm <> fsacTfm // if the SDK doesn't match one of our FSAC TFMs, then we're in compat mode | ||
|
||
let args = | ||
userDotnetArgs | ||
|
||
let envVariables = | ||
[ if shouldApplyImplicitRollForward then | ||
"DOTNET_ROLL_FORWARD", box "LatestMajor" | ||
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. pertinent change 1 |
||
match sdkVersion.prerelease with | ||
| null -> () | ||
| pres when pres.Count > 0 -> | ||
"DOTNET_ROLL_FORWARD_TO_PRERELEASE", box "true" | ||
| _ -> () ] | ||
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. if the sdk in use is a preview we must apply another flag to let the runtime float forward to those previews |
||
|
||
return args, envVariables, fsacPath | ||
} | ||
|
||
let spawnNetCore dotnet : JS.Promise<Executable> = | ||
|
@@ -803,7 +793,7 @@ Consider: | |
if parallelReferenceResolution then | ||
yield "FCS_ParallelReferenceResolution", box "true" ] | ||
|
||
printfn $"FSAC (NETCORE): '%s{fsacPath}'" | ||
printfn $"""FSAC (NETCORE): '%s{fsacPath}'""" | ||
|
||
let exeOpts = createEmpty<ExecutableOptions> | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
core of the change is here - if the derived 'default' TFM of the SDK in use is not the TFM of the version of FSAC that we just chose (e.g. net8.0 on a 8.0.100-preview SDK with a net7.0 TFM FSAC binary), then we must apply rollforward flags to force the runtime to choose 8.0 bits. otherwise on a system with 7.0 bits installed we'll use those.