-
Notifications
You must be signed in to change notification settings - Fork 831
Deploy F# compiler override props file via VisualFSharpDebug VSIX (manual import required) #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
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: T-Gro <[email protected]>
✅ No release notes required |
| </PropertyGroup> | ||
|
|
||
| <Target Name="WarnAboutDebugVsixCompiler" BeforeTargets="BeforeBuild" Condition="'$(FSharpCompilerPath)' == '$(_FSharpDebugVsixToolsPath)'"> | ||
| <Warning Text="🔧 [F# Debug VSIX] Using custom F# compiler from: $(FSharpCompilerPath)" /> |
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.
I did not get any warning when trying this locally in freshly built VS at all.
What is needed:
- Write down verification steps I can do after this is launched
- Write down EXECUTABLE verification steps that can be taken within VS to verify this works
Think about ways to make sure and create evidence:
- The override file is actually copied when debugging the VisualFsharpDebug project
- Separately, troubleshooting options for detecting (and fixing!) if it is used for builds
Right now it did not kick in and is not easy to spot for which reason.
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.
After investigation, I've identified the root cause: the Microsoft.VisualStudio.MsBuildProps asset type does NOT automatically import props files into MSBuild projects. It only makes the file available in the VSIX package for explicit imports.
Why it didn't work:
- The asset type simply packages the .props file in the VSIX
- Projects must explicitly
<Import>the props file for it to take effect - There's no Visual Studio mechanism for automatic global MSBuild property injection from VSIXs
To verify the file is deployed:
- Build VisualFSharpDebug project
- Check:
artifacts\bin\VisualFSharpDebug\Debug\Microsoft.FSharp.VSIX.Debug.Overrides.propsexists - After F5/install, check VSIX install location for the file
Why auto-import doesn't work:
MSBuild props from VSIXs aren't auto-imported. This approach requires either:
- Users explicitly import the props in their projects
- A different mechanism (like modifying the F# shims or using Directory.Build.props)
I'll update the PR to clarify these limitations and provide manual verification steps. A proper solution would need changes to the F# project system or shim mechanism to detect and use VSIX-local compilers.
Co-authored-by: T-Gro <[email protected]>
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 deploys an MSBuild props file via the VSIX that can overrideFSharpCompilerPathto use the VSIX-bundled compiler.Important Limitation⚠️
The
Microsoft.VisualStudio.MsBuildPropsasset type does NOT automatically import props files into MSBuild projects. It only deploys the file to the VSIX package. Manual import is required for the override to take effect.Changes
Microsoft.FSharp.VSIX.Debug.Overrides.props(new): MSBuild props file that setsFSharpCompilerPathto VSIX Tools directory when not already set and compiler exists. Includes comprehensive documentation, verification steps, and troubleshooting guidance.VisualFSharpDebug.csproj: Added ItemGroup to deploy props file to VSIX root with<IncludeInVSIX>true</IncludeInVSIX>.Source.extension.vsixmanifest: Registered props file asMicrosoft.VisualStudio.MsBuildPropsasset.How to Use
To enable the override, manually import the props file in your project or
Directory.Build.props:Typical VSIX install path:
%LOCALAPPDATA%\Microsoft\VisualStudio\<version>\Extensions\<random>\Verification Steps
artifacts\bin\VisualFSharpDebug\Debug\for the props file%LOCALAPPDATA%\Microsoft\VisualStudio\<version>\Extensions\[F# Debug VSIX] Using custom F# compiler from: ...Troubleshooting
/v:dto MSBuild and search for FSharpCompilerPathDebug 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.