-
Notifications
You must be signed in to change notification settings - Fork 831
Auto-set FSharpCompilerPath when debugging VisualFSharpDebug VSIX #19083
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
Conversation
Co-authored-by: T-Gro <46543583+T-Gro@users.noreply.github.com>
✅ No release notes required |
vsintegration/Vsix/VisualFSharpFull/Microsoft.FSharp.VSIX.Debug.Overrides.props
Outdated
Show resolved
Hide resolved
Co-authored-by: T-Gro <46543583+T-Gro@users.noreply.github.com>
Co-authored-by: T-Gro <46543583+T-Gro@users.noreply.github.com>
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
Wait what is actually the added value of this?
It does not accomplish anything at all.
I wanted the F5 behavior of the VisualFSharpDebug project to set the variable automatically, not that people have to set it on their own - they know they can do it already.
Just drop these changes, all of them, and focus on the launch settings.json file - in there, you shall be able to set the env var for the user.
Add it to Directory.Build.Props just how VSSDKTargetPlatformRegRootSuffix (search!!!) is added.
This should form the path to the FSharpCompilerPath that you must figure out from the context.
And the launch settings.json can set it as an env var for the started project.
Co-authored-by: T-Gro <46543583+T-Gro@users.noreply.github.com>
Refactored the approach in commit
This follows the same pattern as |
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 automatically sets theFSharpCompilerPathenvironment variable when pressing F5 on VisualFSharpDebug, so the locally built compiler is used.How It Works
The existing F# shim mechanism in
vsintegration/shims/Microsoft.FSharp.ShimHelpers.props(line 10) checks ifFSharpCompilerPathis set:$(VsInstallRoot)/Common7/IDE/CommonExtensions/Microsoft/FSharp/Tools/This PR follows the same pattern as
VSSDKTargetPlatformRegRootSuffix:vsintegration/Vsix/Directory.Build.props$(FSharpCompilerPath)inlaunchSettings.jsonChanges
vsintegration/Vsix/Directory.Build.props: AddedFSharpCompilerPathproperty pointing to$(ArtifactsDir)bin/fsc/$(Configuration)/net472/launchSettings.json: AddedenvironmentVariablessection that setsFSharpCompilerPathto$(FSharpCompilerPath)- Visual Studio expands this when launching the debug sessionVerification
/v:dand search forFSharpCompilerPathto verify it points to the artifacts folderNotes
VisualFSharpFull.csproj) unchangedChecklist
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.