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

Cannot create a type provider without Paket? #314

Closed Happypig375 closed 2 years ago

Happypig375 commented 5 years ago

So there's this package: https://www.nuget.org/packages/FSharp.TypeProviders.StarterPack but it's been unlisted. Currently, there seems to be no way to create type providers by only using NuGet and not Paket. Why? Type Providers are a F# feature but seems that so much additional components are needed before it can be used.

jkone27 commented 4 years ago

totally agree also paket seems not supported as an extension on VS2019 currently. https://github.com/fsprojects/Paket.VisualStudio/issues/176 this makes the dev experience not so friendly

sergey-tihon commented 4 years ago

If you do not want to use Paket, you can manually copy 2 files from this repo to your TP project: ProvidedTypes.fs and ProvidedTypes.fsi

or even better, create solution from the template

dotnet new -i FSharp.TypeProviders.Templates
dotnet new typeprovider -n LemonadeProvider -lang F#
jkone27 commented 4 years ago

Yes that's what i also did to fix manually yes (adding the 2 files manually), indeed. Though when i create the solution with the template, the fsi and fs files are missing apparently... at least in VS

image

i believe because also these 2 files are referenced by paket

File:ProvidedTypes.fsi
File:ProvidedTypes.fs

FSharp.Core
# put any package references here
# System.Text.Encoding.CodePages framework: netstandard2.0,netcoreapp3.1

i also don't have them in the project folders (projects where generated via template)

sergey-tihon commented 4 years ago

it should work for sure if you build it from command line

dotnet tool restore
dotnet paket update
dotnet build -c release

what happens when you just build from VS? VS does not restore dotnel tool?

mettekou commented 3 years ago

@sergey-tihon Is there no way to create a type provider without using Paket or the template (which also uses Paket)? Is copying ProvidedTypes.fs and ProvidedTypes.fsi into an F# class library project representing the design-time really enough? This does not set up the NuGet package properly, i.e. the type provider does not end up in the NuGet package for the run-time project. How do I manually create the proper .nuspec file?

sergey-tihon commented 3 years ago

@mettekou sorry, no idea. I never tried to do it with .nuspec file, because I relay like the granular control and freedom of packaging with paket.tempate.

You may start from solution created by template, replace .fsi & .fs file references by actual file and then try to hack .nuspec file produce the same folder layout that paket.template do.

Keep in mind that latest template still support both framework, but current master already moved to .NET Standard exclusively. There is a chance that latest SDK is able to pack TP correctly without Paket, but I do not have a sample to share you.

cartermp commented 3 years ago

FWIW the repo is now set up to be able to publish the TPSDK as a standalone package (at least with https://github.com/fsprojects/FSharp.TypeProviders.SDK/pull/339), making paket no longer necessary for any sane creation and maintenance of a custom type provider.

As per @dsyme's comment it appears we just have to follow through: https://github.com/fsprojects/FSharp.TypeProviders.SDK/pull/339#issuecomment-716906435

sergey-tihon commented 3 years ago

@cartermp do we still need to pack all transitive dependencies of design-time component inside TP nuget package in the folder near DT assembly?

cartermp commented 3 years ago

I would expect so, yeah

mettekou commented 3 years ago

@sergey-tihon I got my own type provider working without Paket using the following .nuspec file. Copying the design-time libraries to fsharp41/typeproviders/net50 doesn't work, but copying them to lib/net50 like the run-time libraries does.

dsyme commented 2 years ago

Closing this old discussion

mettekou commented 2 years ago

@dsyme As this discussion is closed, I assume it is now possible to create a type provider without Paket. However, I am struggling to do so for .NET 6, as per https://github.com/mettekou/FSharp.Data.Tdms/issues/9. Adding the design-time assembly to the typeproviders/fsharp41/net6.0 directory within the NuGet package breaks the build for my type provider in Visual Studio 2022, but not the build using the .NET 6 SDK (dotnet build). Alternatively, adding the design-time assembly to the lib/net6.0 directory within the NuGet package breaks the build using the .NET 6 SDK, but the build in Visual Studio 2022 works. Is there an example of a type provider targetting .NET 6 without using Paket?

cartermp commented 2 years ago

@mettekou I suspect the issue lies either in the F# compiler used for the .NET SDK or the F# compiler used in Visual Studio (they are different), and is unrelated to this.