question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

.NET Standard 2.0 TPDTC with external dependencies example

See original GitHub issue

I wanted to make https://github.com/demetrixbio/FSharp.Data.Npgsql true .NET Standard 2.0 TPDTC such that consuming projects can be compiled only with .NET Core SDK tools.

I followed https://github.com/fsprojects/FSharp.TypeProviders.SDK#making-a-net-standard-20-tpdtc and https://github.com/fsharp/fslang-design/blob/master/tooling/FST-1003-loading-type-provider-design-time-components.md but I get an error

error FS3033: The type provider 'FSharp.Data.Npgsql.NpgsqlProviders' reported an error: Could not load file or assembly 'Npgsql, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7'. The system cannot find the file specified.

So unless workaround applied consuming projects fail to compile.

After followed @dsyme suggestion https://twitter.com/mitekm/status/1024451317526233089

It helped with to solve TPDTC dependency loading issue but I got stuck with following error

error FS1108: The type 'Void' is required here and is unavailable. You must add a reference to assembly 'System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e'.

It’s not a first time I hit TPDTC dependency management issue while working on type provider that targets .NET Core runtime. It would be helpful either to extend BasicProvider.DesignTime project to demo how to handle external dependencies or create separate sample type provider to cover that case.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:22 (15 by maintainers)

github_iconTop GitHub Comments

4reactions
larjocommented, Apr 23, 2019

There is the same problem with the latest released version as well, v2.2.203.

My workaround is to replace

    <FscToolPath>C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\Common7\IDE\CommonExtensions\Microsoft\FSharp</FscToolPath>
    <FscToolExe>fsc.exe</FscToolExe>

with

    <FscToolPath>$(MSBuildThisFileDirectory)</FscToolPath>
    <FscToolExe>fscfix.bat</FscToolExe>

where fscfix.bat is

fsc %2

That is it ignores the first argument and calls fsc.exe (which I have in my path) with the file that is going to be compiled.

However this fix isn’t needed when building in visual studio 2019.

Edit:

This batch file works both with dotnet build and from visual studio:

for %%a in (%*) do set last=%%a
fsc %last%
2reactions
drk-mtrcommented, May 18, 2019

@larjo Thanks very much for posting your workaround, this was what eventually got it working for me (SqlProvider with MsSql).

I naively thought Type Providers might save me time, instead I spend my life just trying to get them working hehe.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to set dependencies when I use .NET Standard 2.0 ...
NET Standard 2.0 DLL library. I want to put my business object POCO classes here. This is supposed to have no dependencies. Core.Application ......
Read more >
Dependencies and .NET libraries
One way to reduce external NuGet package dependencies is to reference shared source packages. A shared source package contains source code files ...
Read more >
Proposal: Type provider design-time DLLs should be ...
I'm trying to build a project that consumes Example 3 type provider (.NET Standard design-time DLL) using .NET Core SDK command line. It...
Read more >
Please stop lying about .NET Standard 2.0 support!
But the real issue is when they're used as transitive dependencies. Take the Npgsql package, for example. As we've already seen, this supports...
Read more >
Managing Dependencies in .NET: .csproj, .packages.config ...
As products grow, the management of these external dependencies becomes more and more complex. This post aims to describe some of the artifacts ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found