Skip to content

Conversation

DedSec256
Copy link
Contributor

@DedSec256 DedSec256 commented Oct 3, 2025

The FSharpChecker.GetProjectOptionsFromScript method has an optional parameter sdkDirOverride, which allows specifying the SDK with which the script will be analyzed in the IDE. However, for restoring NuGet packages, this info is not used, which leads to some unpredictable behavior. In some cases, for example, when using a new version of .NET installed in a non-standard location, restoring NuGet packages becomes impossible with an error like

error NETSDK1045: The current .NET SDK does not support targeting .NET 9.0. Either target .NET 8.0 or lower, or use a version of the .NET SDK that supports .NET 9.0

This PR fixes this issue, taking into account the sdkDirOverride parameter for NuGet restoring in the default FSharpDependencyManager.

It also improves additional log info in the generated Project.fsproj.fsx, showing the correct path to the used dotnet.exe instead of the outdated hardcoded.

Copy link
Contributor

github-actions bot commented Oct 3, 2025

❗ Release notes required


✅ Found changes and release notes in following paths:

Change path Release notes path Description
src/Compiler docs/release-notes/.FSharp.Compiler.Service/11.0.0.md

@DedSec256 DedSec256 changed the title F# Scripts: fix a dotnet host path if sdk dir is passed [WIP] F# Scripts: Fix resolving the dotnet host path when an SDK directory is specified [WIP] Oct 3, 2025
@DedSec256 DedSec256 changed the title F# Scripts: Fix resolving the dotnet host path when an SDK directory is specified [WIP] F# Scripts: Fix resolving the dotnet host path when an SDK directory is specified Oct 3, 2025
@DedSec256 DedSec256 marked this pull request as ready for review October 6, 2025 02:46
@DedSec256 DedSec256 requested a review from a team as a code owner October 6, 2025 02:46
Comment on lines +167 to +169
let n = arguments.Length

seq { for i in n - 1 .. -1 .. 0 -> arguments[0..i] }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get the intention.

But still, I believe future human and non-human coders would appreciate a few comments about what is being done here and especially why.

Copy link
Member

@T-Gro T-Gro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What changes, docs or implementation or some limited guidance perhaps, are to be done towards 3rd party Dependency Providers together with this change?

In this case, the purpose (fixing nuget, the dominant provider) is justified and I think it's OK to expand the possibility of sdkDirOverride to other providers - do I understand it right that now every provider can retrieve this info?

(I am coming from a philosophical question if a direct string param is correct here and if it does not close too many future-expansion points.

After all, the construction logic is driven via constructor overloads and locking down string option as a constructor argument might be kick as back later.

Have you considered ways of making this parameter more semantic, either by changing construction logic or by also utilizing the parameter's name on top of the GetConstructor search perhaps?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: New
Development

Successfully merging this pull request may close these issues.

2 participants