Skip to content

Commit

Permalink
scripts: support VS2022 without VS2019
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
knocte committed Sep 14, 2023
1 parent d7cff49 commit 6349f1e
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 14 deletions.
19 changes: 13 additions & 6 deletions scripts/configure.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
36 changes: 28 additions & 8 deletions scripts/fsi.bat
Original file line number Diff line number Diff line change
@@ -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%
Expand All @@ -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
)
)
)
)
)
)
Expand Down

0 comments on commit 6349f1e

Please sign in to comment.