diff --git a/src/Fantomas.Client/CHANGELOG.md b/src/Fantomas.Client/CHANGELOG.md index 142bc3a77..9428707ac 100644 --- a/src/Fantomas.Client/CHANGELOG.md +++ b/src/Fantomas.Client/CHANGELOG.md @@ -2,6 +2,11 @@ This is the changelog for the Fantomas.Client package specifically. It's distinct from that of the overall libraries and command-line tool. +## [Unreleased] + +### Changed +* Fixed: Fantomas.Client does not respect DOTNET_CLI_HOME env variable. [#3104](https://github.com/fsprojects/fantomas/issues/3104) + ## 0.9.0 - 2023-02-24 * Fix JSON serialization of new cursor API. [#2778](https://github.com/fsprojects/fantomas/issues/2778) diff --git a/src/Fantomas.Client/FantomasToolLocator.fs b/src/Fantomas.Client/FantomasToolLocator.fs index c4303cfa3..b2f00633b 100644 --- a/src/Fantomas.Client/FantomasToolLocator.fs +++ b/src/Fantomas.Client/FantomasToolLocator.fs @@ -202,11 +202,16 @@ let createFor (startInfo: FantomasToolStartInfo) : Result - let userProfile = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + + let globalToolsPath = + match Option.ofObj (Environment.GetEnvironmentVariable("DOTNET_CLI_HOME")) with + | Some s -> Path.Combine(s, "tools") + | None -> + Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".dotnet", "tools") let fantomasExecutable = let fileName = if isWindows then "fantomas.exe" else "fantomas" - Path.Combine(userProfile, ".dotnet", "tools", fileName) + Path.Combine(globalToolsPath, fileName) let ps = ProcessStartInfo(fantomasExecutable) ps.Arguments <- "--daemon"