Centralize Visual Studio installation discovery and assembly resolution in test infrastructure #19085
+67
−122
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Consolidates VS installation discovery and assembly resolution logic scattered across test files. Four files had duplicate fallback code;
VsMocks.fshardcodedVS170COMNTOOLSinstead of using centralized discovery. TwoAssemblyResolver.fsfiles contained identical assembly resolution logic.Changes
Added to
VSInstallDiscovery.fs:getVSInstallDirOrFail()- fails with detailed error showing discovery methods attemptedAssemblyResolvermodule - centralizes assembly resolution logic for VS integration testsUpdated consumer files:
AssemblyResolver.fsfiles now delegate to centralizedFSharp.Test.AssemblyResolvermoduleVsMocks.fsuses centralized discovery via linkedVSInstallDiscovery.fsfilefun h args→fun _ args)Project structure changes:
VSInstallDiscovery.fsas linked file to Salsa project (avoids NuGet reference warnings)AssemblyName.CodeBaseproperty (still needed for assembly resolution)Impact
Checklist
Original prompt
Unify Visual Studio Installation Discovery Across Test Infrastructure
Overview
Currently, the codebase has Visual Studio installation discovery logic duplicated across multiple test files, with some files still hardcoding specific VS version environment variables (like
VS170COMNTOOLS). We have a centralizedVSInstallDiscovery.fsmodule that handles this properly, but not all files are using it correctly.Goals
Current Problems
VsMocks.fsstill hardcodesVS170COMNTOOLSinstead of using centralized discoveryFiles to Modify
1.
tests/FSharp.Test.Utilities/VSInstallDiscovery.fsAdd a new helper function at the end of the file (after the existing
getVSInstallDirWithLoggingfunction):This should be added after line 128 (after the
getVSInstallDirWithLoggingfunction).2.
vsintegration/tests/UnitTests/AssemblyResolver.fsReplace the entire file content with:
Key changes from original:
match tryGetVSInstallDir()...tolet vsInstallDir = getVSInstallDirOrFail ()fun h args ->tofun _ args ->(unused parameter)(probingPaths )→probingPaths3.
vsintegration/tests/FSharp.Editor.Tests/Helpers/AssemblyResolver.fsReplace the entire file content with: