Enable VisualFSharpDebug VSIX to override F# compiler path via MSBuild props #19083
+32
−0
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
When building VisualFSharpDebug.vsix for local F# compiler development, the VSIX installs language service and editor components but MSBuild continues using the system-installed compiler from
Common7/IDE/CommonExtensions/Microsoft/FSharp/Tools/. This PR adds automatic compiler path redirection to use the VSIX-bundled compiler.Changes
Microsoft.FSharp.VSIX.Debug.Overrides.props(new): MSBuild props file that setsFSharpCompilerPathto VSIX Tools directory when not already set and compiler exists. Includes build warning to indicate override is active.VisualFSharpDebug.csproj: Added ItemGroup to deploy props file to VSIX root with<IncludeInVSIX>true</IncludeInVSIX>.Source.extension.vsixmanifest: Registered props file asMicrosoft.VisualStudio.MsBuildPropsasset for automatic import by Visual Studio.Mechanism
The props file leverages
$(MSBuildThisFileDirectory)to compute the VSIX Tools path and setsFSharpCompilerPathbefore the existing shim inMicrosoft.FSharp.ShimHelpers.propsevaluates (line 10 checks for pre-existingFSharpCompilerPath).Debug VSIX only — production VSIX (
VisualFSharpFull.csproj) unchanged.Checklist
Test cases added
Performance benchmarks added in case of performance changes
Release notes entry updated:
Original prompt
Enable VisualFSharpDebug VSIX to Override F# Compiler Path
Problem
When developers build and install VisualFSharpDebug.vsix for local F# development, the VSIX installs the language service and editor components but does NOT update the F# compiler (fscAnyCpu.exe) used by MSBuild when building F# projects.
Currently:
%LOCALAPPDATA%\Microsoft\VisualStudio\<version>\Extensions\...C:\Program Files\Microsoft Visual Studio\<version>\Common7\IDE\CommonExtensions\Microsoft\FSharp\Tools\This means locally built compiler changes are not used when building F# projects, which is a major pain point for F# compiler development.
Solution
Deploy an MSBuild .props file via the VSIX that automatically overrides the
FSharpCompilerPathproperty to point to the VSIX's Tools directory where the custom-built compiler is located.The F# build system uses a shim mechanism (in
vsintegration/shims/Microsoft.FSharp.ShimHelpers.props) that checks forFSharpCompilerPathand uses it to load the compiler. By setting this property before the shims evaluate, we can redirect all F# builds to use the VSIX compiler.Implementation Details
File 1: Create New Props File
Path:
vsintegration/Vsix/VisualFSharpFull/Microsoft.FSharp.VSIX.Debug.Overrides.propsContent:
File 2: Modify VisualFSharpDebug.csproj
Path:
vsintegration/Vsix/VisualFSharpFull/VisualFSharpDebug.csprojChange: Add the following ItemGroup after line 86 (before the closing
</Project>tag):File 3: Modify VSIX Manifest
Path:
vsintegration/Vsix/VisualFSharpFull/Source.extension.vsixmanifestChange: Add the following Asset element in the
<Assets>section (after the existing Asset elements, around line 43):How It Works
Microsoft.VisualStudio.MsBuildPropsasset$(MSBuildThisFileDirectory)FSharpCompilerPathto point to the VSIX Tools directory (only if not already set)vsintegration/shims/Microsoft.FSharp.ShimHelpers.props) usesFSharpCompilerPathto load the compilerTesting
After these changes:
🔧 [F# Debug VSIX] Using custom F# compiler from: <path to VSIX>\Tools\Safety
FSharpCompilerPathis not already setThis pull request was created as a result of the following prompt from Copilot chat.
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.