Package resolution doesn't correctly resolve references when guided by --targetprofile:
- Dominant language
- F#
- Stars
- 4.3k
- Forks
- 876
- Avg merge
- 4d 11h
- Merged PRs (30d)
- 131
Description
This test does not achieve it's goal -
``can resolve nuget packages to right target framework for different frameworks regardless of execution environment``
I think there is a bug here, when targeting --targetprofile:mscorlib then #r nuget should correctly gather desktop dependencies rather than the netstandard2.0 dependencies. The current behaviour is fsi specific, whereas #r nuget is also compilable.
The proof of that is that there is a #if NETFRAMEWORK which adds a testcase that only works on the desktop framework.
Also the assumeDotNetFramework 'true' is execution environment
````
#if NETFRAMEWORK
// See https://github.com/dotnet/fsharp/pull/13994#issuecomment-1259663865
//
// .NET Core-based tooling can't resolve nuget packages to .NET Framework references
[]
#endif
[]
[]
let ``can resolve nuget packages to right target framework for different frameworks regardless of execution environment``(assumeNetFx, useSdk, flags) =
let path = Path.GetTempPath()
let file = tryCreateTemporaryFileName () + ".fsx"
let tempFile = Path.Combine(path, file)
let scriptSource = """
#r "nuget: FSharp.Data, 3.3.3"
open System
let pi = Math.PI
"""
let options, errors =
checker.GetProjectOptionsFromScript(tempFile, SourceText.ofString scriptSource, assumeDotNetFramework = assumeNetFx, useSdkRefs = useSdk, otherFlags = flags)
|> Async.RunImmediate
match errors with
| [] -> ()
| errors -> failwithf "Error while parsing script with assumeDotNetFramework:%b, useSdkRefs:%b, and otherFlags:%A:\n%A" assumeNetFx useSdk flags errors
let expectedReferenceText = (if assumeNetFx then "net45" else "netstandard2.0")
let found = options.OtherOptions |> Array.exists (fun s -> s.Contains(expectedReferenceText) && s.Contains("FSharp.Data.dll"))
Assert.IsTrue(found)
````
Contributor guide
Assessment
This issue has not been assessed yet.