Cannot use locally built F# compiler within VS
See original GitHub issueWhen building F# project using custom build F# compiler with custom keywords from Visual Studio error happens
FSC error FS2020: The assembly 'C:\d\github\dotnet\fsharp\artifacts/bin/fsc/Debug/net7.0/fsc.dll' is listed on the command line. Assemblies should be referenced using a command line flag such as '-r'. [C:\d\github\funsharp\ісх\ВеселШарп.Бібліотека.fsproj]
Even if build in VS does not works, what working
- Build using
dotnet build
- Colorization within VS. New keywords correctly highlighted.
Repro steps
- Clone F# repo to
C:\d\github\dotnet\fsharp
- Add aliases to existing F# keywords, For example add
let
=>leet
- Create project which use these custom keywords.
- Add following properties in the
Directory.Build.props
of the F# project
<PropertyGroup>
<FSharpRoot>C:\d\github\dotnet\fsharp\</FSharpRoot>
<DotnetFscCompilerPath>$(FSharpRoot)artifacts/bin/fsc/Debug/net7.0/fsc.dll</DotnetFscCompilerPath>
<Fsc_DotNET_DotnetFscCompilerPath>$(FSharpRoot)artifacts/bin/fsc/Debug/net7.0/fsc.dll</Fsc_DotNET_DotnetFscCompilerPath>
<!-- these experiments and probably do not affect anything -->
<FSharpPreferNetFrameworkTools>false</FSharpPreferNetFrameworkTools>
<FSharpCompilerPath>$(FSharpRoot)artifacts/bin/fsc/Debug/net7.0/</FSharpCompilerPath>
</PropertyGroup>
- Open VisualFSharp.sln
- Run VisualFSharpDebug project
- Open F# project with custom keywords.
- Build project in the VS
In case if this is needed.
- Custom F# compiler https://github.com/kant2002/fsharp
- Test F# solution which used custom keywords https://github.com/kant2002/funsharp/tree/головна-фшарп
** Investigation **
From what I see DotnetFscCompilerPath
passed to the Fsc
task. And then FSC task produces
C:\d\github\dotnet\fsharp\artifacts\bin\fsc\Debug\net7.0\fsc.exe C:\d\github\dotnet\fsharp\artifacts/bin/fsc/Debug/net7.0/fsc.dll -o:obj\Debug\net7.0\ВеселШарп.Бібліотека.dll
-g
...
skipped
...
My understanding that proper call should be
dotnet.exe C:\d\github\dotnet\fsharp\artifacts/bin/fsc/Debug/net7.0/fsc.dll -o:obj\Debug\net7.0\ВеселШарп.Бібліотека.dll
-g
...
skipped
...
Issue Analytics
- State:
- Created 10 months ago
- Comments:9 (9 by maintainers)
Top Results From Across the Web
Cannot obtain value of local or argument as it is not ...
Go to Project Properties and under Build Make sure that the "Optimize Code" checkbox is unchecked. Also, set the "Debug Info" dropdown to...
Read more >Cannot debug net6.0-macos Apps - Developer Community
When I hit debug, the following error is shown in the Terminal: Possible reasons for this include: * You misspelled a built-in dotnet...
Read more >C/C++ extension FAQ
Frequently asked questions about the C/C++ extension in Visual Studio Code.
Read more >Troubleshoot broken references - Visual Studio
To fix this problem, use one of the following methods: Delete the broken reference and then replace it by using the Add Reference...
Read more >Troubleshoot Visual C++ Compiler or Visual C++ Linker
Open up a Visual Studio Command Prompt. · Create the LINK_REPRO environment variable pointing to an existing and empty directory, for example: ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@kant2002 – okay I believe I have a much better 1 property solution. https://github.com/dotnet/fsharp/pull/14422
Once the PR is merged you will be able to do this:
The following works for me in both VS and CLI:
It may fail to work if shipped runtime in VS is a lower version than the compiler tfm.