From cd144bc9ffde0d113b28e1383c411650441816bc Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 20 Oct 2026 13:14:19 +0000 Subject: [PATCH] Add regression test for FCS PATH isolation Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../ScriptOptionsTests.fs | 31 +++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/tests/FSharp.Compiler.Service.Tests/ScriptOptionsTests.fs b/tests/FSharp.Compiler.Service.Tests/ScriptOptionsTests.fs index fd2bb7cd311..42ad31d2468 100644 --- a/tests/FSharp.Compiler.Service.Tests/ScriptOptionsTests.fs +++ b/tests/FSharp.Compiler.Service.Tests/ScriptOptionsTests.fs @@ -2,13 +2,17 @@ [] module FSharp.Compiler.Service.Tests.ScriptOptionsTests -open Xunit +open System open System.IO -open FSharp.Compiler.Service.Tests.Common + open FSharp.Compiler.CodeAnalysis +open FSharp.Compiler.Service.Tests.Common open FSharp.Compiler.Text + open TestFramework +open Xunit + // Add additional imports/constructs into this script text to verify that common scenarios // for FCS script typechecking can be supported let scriptSource = """ @@ -63,6 +67,29 @@ let pi = Math.PI let found = options.OtherOptions |> Array.exists (fun s -> s.Contains(expectedReferenceText) && s.Contains("FSharp.Data.dll")) Assert.True(found) +// https://github.com/dotnet/fsharp/issues/12708 +[] +let ``Issue 12708 - editor-side NuGet resolution does not alter host PATH`` () = + let originalPath = Environment.GetEnvironmentVariable("PATH") + + try + let file = Path.Combine(Path.GetTempPath(), getTemporaryFileName () + ".fsx") + let localChecker = FSharpChecker.Create() + + let _, errors = + localChecker.GetProjectOptionsFromScript( + file, + SourceText.ofString """#r "nuget: System.Json, 4.6.0" """, + assumeDotNetFramework = false, + useSdkRefs = true + ) + |> Async.RunSynchronouslyImmediate + + Assert.Empty errors + Assert.Equal(originalPath, Environment.GetEnvironmentVariable("PATH")) + finally + Environment.SetEnvironmentVariable("PATH", originalPath) + /// `SourceFiles` is exactly the single script; the fsi default-reference injection for a missing `#load` /// is a host-layout detail (not product behaviour) and is intentionally not asserted. /// Desktop-only: it asserts .NET Framework GAC assemblies (`System.Runtime.Remoting`/`System.Transactions`)