fsprojects / FSharp.TypeProviders.SDK

The SDK for creating F# type providers
https://fsprojects.github.io/FSharp.TypeProviders.SDK/
MIT License
298 stars 94 forks source link

Debugging TPDTC assemblies loading failures when invoked from .NET Core SDK command line. #245

Closed dmitry-a-morozov closed 5 years ago

dmitry-a-morozov commented 6 years ago

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

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.

dsyme commented 5 years ago

@dmitry-a-morozov I would normally do this:

  1. 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:

  2. 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

  3. 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)

  4. Set first-catch exception handling (Ctrl-Alt-E, select all CLR exceptions) and set Just My Code off

dsyme commented 5 years ago

Added docs on this to the README.md