-
Notifications
You must be signed in to change notification settings - Fork 831
Centralize Visual Studio installation discovery and assembly resolution in test infrastructure #19085
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: T-Gro <[email protected]>
- Move AssemblyResolver logic to VSInstallDiscovery.fs as a new module - Update both AssemblyResolver.fs files to delegate to centralized implementation - Add VSInstallDiscovery.fs as linked file to Salsa project (fixes missing reference) - Reduces code duplication further (~70 lines total removed) Co-authored-by: T-Gro <[email protected]>
The AssemblyName.CodeBase property is deprecated but still needed for assembly resolution in VS integration tests. Suppress warning 44 in FSharp.Test.Utilities project. Co-authored-by: T-Gro <[email protected]>
✅ No release notes required |
T-Gro
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot :
Pls rename it to avoid conflicts.
D:\a_work\1\s\tests\FSharp.Test.Utilities\CompilerAssert.fs(32,8): error FS0248: Two modules named 'FSharp.Test.AssemblyResolver' occur in two parts of this assembly [D:\a_work\1\s\tests\FSharp.Test.Utilities\FSharp.Test.Utilities.fsproj::TargetFramework=net472]
D:\a_work\1\s\tests\FSharp.Test.Utilities\VSInstallDiscovery.fs(140,8): error FS0248: Two modules named 'FSharp.Test.AssemblyResolver' occur in two parts of this assembly [D:\a_work\1\s\tests\FSharp.Test.Utilities\FSharp.Test.Utilities.fsproj::TargetFramework=net472]
0 Warning(s)
2 Error(s)
Fixes FS0248 error: Two modules named 'FSharp.Test.AssemblyResolver' were occurring because CompilerAssert.fs already has an AssemblyResolver module. Renamed the new module to VSAssemblyResolver to avoid conflict. Co-authored-by: T-Gro <[email protected]>
|
/azp run |
|
Azure Pipelines successfully started running 2 pipeline(s). |
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 attemptedVSAssemblyResolvermodule - centralizes assembly resolution logic for VS integration tests (named to avoid conflict with existingAssemblyResolvermodule inCompilerAssert.fs)Updated consumer files:
AssemblyResolver.fsfiles now delegate to centralizedFSharp.Test.VSAssemblyResolvermoduleVsMocks.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: