Closed dmitry-a-morozov closed 5 years ago
@dmitry-a-morozov I would normally do this:
Capture output of msbuild -v:n
or msbuild -v:d
in args.txt
and trim out the rubbish leaving just the command line arguments to the F# compiler, usually starting with -o:
Run an explicit invocation of the compiler using:
"c:\Program Files\dotnet\dotnet.exe" "C:\Program Files\dotnet\sdk\2.1.401\FSharp\fsc.exe" @args.txt
Debug that invocation using
devenv /debugexe "c:\Program Files\dotnet\dotnet.exe" "C:\Program Files\dotnet\sdk\2.1.401\FSharp\fsc.exe" @args.txt
However be careful to make sure Visual Studio debugging type is set to ".NET Core" (right click properties on dotnet
and set debug type)
Set first-catch exception handling (Ctrl-Alt-E, select all CLR exceptions) and set Just My Code off
Added docs on this to the README.md
It's related to https://github.com/fsprojects/FSharp.TypeProviders.SDK/issues/244 How do I debug TPDTC external assemblies loading failures when type provider triggered from .NET SDK command line? Usual type provider technique invoking one VS instance from another simply doesn't work because VS uses it's own F# compiler and things are fine. I tried
dotnet ...
as debug targetDebugger.Break()
printf
Nothing worked.
So I had to go with a low-tech solution writing to file from
AsserblyResolve
event which is ok-ish but I wonder if there is a better way.