From 6349f1e7fc3382c18105a0c6b02fa29d4381cf7f Mon Sep 17 00:00:00 2001 From: "Andres G. Aragoneses" Date: Fri, 15 Sep 2023 06:54:41 +0800 Subject: [PATCH] scripts: support VS2022 without VS2019 Don't ask me why %ProgramFiles% maps properly to C:\Program Files\ in the .bat file but within .NET it maps to C:\Program Files(x86)\ (so that's why we need to use %ProgramW6432% in that case instead. --- scripts/configure.fsx | 19 +++++++++++++------ scripts/fsi.bat | 36 ++++++++++++++++++++++++++++-------- 2 files changed, 41 insertions(+), 14 deletions(-) diff --git a/scripts/configure.fsx b/scripts/configure.fsx index ed8469b7f..396a565ff 100644 --- a/scripts/configure.fsx +++ b/scripts/configure.fsx @@ -118,18 +118,25 @@ let buildTool: string = | Some xbuildCmd -> xbuildCmd | Misc.Platform.Windows -> - let programFiles = Environment.GetFolderPath Environment.SpecialFolder.ProgramFilesX86 - let msbuildPathPrefix = Path.Combine(programFiles, "Microsoft Visual Studio", "2019") - let GetMsBuildPath vsEdition = + let GetMsBuildPath vsEdition (old: bool) = + let programFiles, vsVersion = + if not old then + Environment.GetEnvironmentVariable "ProgramW6432", "2022" + else + Environment.GetFolderPath Environment.SpecialFolder.ProgramFilesX86, "2019" + let msbuildPathPrefix = Path.Combine(programFiles, "Microsoft Visual Studio", vsVersion) Path.Combine(msbuildPathPrefix, vsEdition, "MSBuild", "Current", "Bin", "MSBuild.exe") // FIXME: we should use vscheck.exe match ConfigCommandCheck [ - GetMsBuildPath "Community" - GetMsBuildPath "Enterprise" - GetMsBuildPath "BuildTools" + GetMsBuildPath "Community" false + GetMsBuildPath "Enterprise" false + GetMsBuildPath "BuildTools" false + GetMsBuildPath "Community" true + GetMsBuildPath "Enterprise" true + GetMsBuildPath "BuildTools" true ] true with diff --git a/scripts/fsi.bat b/scripts/fsi.bat index 362c346da..b3a2187f3 100644 --- a/scripts/fsi.bat +++ b/scripts/fsi.bat @@ -1,11 +1,19 @@ @ECHO OFF -SET ENTERPRISE="%ProgramFiles(x86)%\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\CommonExtensions\Microsoft\FSharp\Tools\fsi.exe" -SET ENTERPRISE_OLD="%ProgramFiles(x86)%\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\CommonExtensions\Microsoft\FSharp\fsi.exe" -SET COMMUNITY="%ProgramFiles(x86)%\Microsoft Visual Studio\2019\Community\Common7\IDE\CommonExtensions\Microsoft\FSharp\Tools\fsi.exe" -SET COMMUNITY_OLD="%ProgramFiles(x86)%\Microsoft Visual Studio\2019\Community\Common7\IDE\CommonExtensions\Microsoft\FSharp\fsi.exe" -SET BUILDTOOLS="%ProgramFiles(x86)%\Microsoft Visual Studio\2019\BuildTools\Common7\IDE\CommonExtensions\Microsoft\FSharp\Tools\fsi.exe" -SET BUILDTOOLS_OLD="%ProgramFiles(x86)%\Microsoft Visual Studio\2019\BuildTools\Common7\IDE\CommonExtensions\Microsoft\FSharp\fsi.exe" +SET VS_ROOT=%ProgramFiles%\Microsoft Visual Studio\2022 +SET VS_ROOT_OLD=%ProgramFiles(x86)%\Microsoft Visual Studio\2019 + +SET ENTERPRISE="%VS_ROOT%\Community\Common7\IDE\CommonExtensions\Microsoft\FSharp\Tools\fsi.exe" +SET ENTERPRISE_OLD="%VS_ROOT_OLD%\Enterprise\Common7\IDE\CommonExtensions\Microsoft\FSharp\Tools\fsi.exe" +SET ENTERPRISE_OLD_OLD="%VS_ROOT_OLD%\Enterprise\Common7\IDE\CommonExtensions\Microsoft\FSharp\fsi.exe" + +SET COMMUNITY="%VS_ROOT%\Community\Common7\IDE\CommonExtensions\Microsoft\FSharp\Tools\fsi.exe" +SET COMMUNITY_OLD="%VS_ROOT_OLD%\Community\Common7\IDE\CommonExtensions\Microsoft\FSharp\Tools\fsi.exe" +SET COMMUNITY_OLD_OLD="%VS_ROOT_OLD%\Community\Common7\IDE\CommonExtensions\Microsoft\FSharp\fsi.exe" + +SET BUILDTOOLS="%VS_ROOT%\BuildTools\Common7\IDE\CommonExtensions\Microsoft\FSharp\Tools\fsi.exe" +SET BUILDTOOLS_OLD="%VS_ROOT_OLD%\BuildTools\Common7\IDE\CommonExtensions\Microsoft\FSharp\Tools\fsi.exe" +SET BUILDTOOLS_OLD_OLD="%VS_ROOT_OLD%\BuildTools\Common7\IDE\CommonExtensions\Microsoft\FSharp\fsi.exe" IF EXIST %ENTERPRISE% ( SET RUNNER=%ENTERPRISE% @@ -25,8 +33,20 @@ IF EXIST %ENTERPRISE% ( IF EXIST %BUILDTOOLS_OLD% ( SET RUNNER=%BUILDTOOLS_OLD% ) ELSE ( - ECHO fsi.exe not found, is F# installed? - EXIT /b 1 + IF EXIST %ENTERPRISE_OLD_OLD% ( + SET RUNNER=%ENTERPRISE_OLD_OLD% + ) ELSE ( + IF EXIST %COMMUNITY_OLD_OLD% ( + SET RUNNER=%COMMUNITY_OLD_OLD% + ) ELSE ( + IF EXIST %BUILDTOOLS_OLD_OLD% ( + SET RUNNER=%BUILDTOOLS_OLD_OLD% + ) ELSE ( + ECHO fsi.exe not found, is F# installed? + EXIT /b 1 + ) + ) + ) ) ) )