Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warnings produced when build and packing template #387

Open
abelbraaksma opened this issue Aug 10, 2022 · 3 comments
Open

Warnings produced when build and packing template #387

abelbraaksma opened this issue Aug 10, 2022 · 3 comments

Comments

@abelbraaksma
Copy link
Member

abelbraaksma commented Aug 10, 2022

Description

Following the instructions here: https://fsprojects.github.io/FSharp.TypeProviders.SDK/, a bunch of things go wrong:

  1. It pins the FSharp.Core version to 4.7.2
  2. It tries to resolve a non-existing dependency to NUnit.Extension.TeamCityEventListener 1.0.8 which was unlisted
  3. Opening and then compiling the created project(s) in Visual Studio 2022 fails
  4. Editing the test project in Visual Studio 2022 has a multitude of errors

The good news is that, besides all these issues, using dotnet build or dotnet test, the project does successfully compile and the tests pass.

Repro steps

Do as in the instructions, in an empty directory run:

  • These commands to start:

    dotnet new -i FSharp.TypeProviders.Templates
    dotnet new typeprovider -n LemonadeProvider -lang F#
    
  • Then update Paket and compile:

    cd LemonadeProvider
    dotnet tool restore
    dotnet paket update
    dotnet build -c release
    

Expected behavior

No warnings and an idiomatic F# project that can be opened and edited in Visual Studio. After all, it creates a sln file.

Actual behavior

The first warnings are from Paket:

Resolving dependency graph...
 - FSharp.Core is pinned to 4.7.2
Resolving dependency graph for group Test...
     NUnit.Extension.TeamCityEventListener 1.0.8 was unlisted

Next is, after opening the sln file in VS 2022, after opening a file from MyTypeProvider.Runtime, I get these errors:

Error FS0229: Error opening binary file 'D:\Projects\Test\MyTypeProvider\src\MyTypeProvider.DesignTime\bin\Debug\netstandard2.1\MyTypeProvider.DesignTime.dll': Could not find file 'D:\Projects\Test\MyTypeProvider\src\MyTypeProvider.DesignTime\bin\Debug\netstandard2.1\MyTypeProvider.DesignTime.dll'.
In: D:\Projects\Test\MyTypeProvider\src\MyTypeProvider.Runtime\MyTypeProvider.Runtime.fs

And:

Error FS3160: Problem reading assembly 'D:\Projects\Test\MyTypeProvider\src\MyTypeProvider.DesignTime\bin\Debug\netstandard2.1\MyTypeProvider.DesignTime.dll': The exception has been reported. This internal exception should now be caught at an error recovery point on the stack. Original message: Error opening binary file 'D:\Projects\Test\MyTypeProvider\src\MyTypeProvider.DesignTime\bin\Debug\netstandard2.1\MyTypeProvider.DesignTime.dll': Could not find file 'D:\Projects\Test\MyTypeProvider\src\MyTypeProvider.DesignTime\bin\Debug\netstandard2.1\MyTypeProvider.DesignTime.dll'.)
In: D:\Projects\Test\MyTypeProvider\src\MyTypeProvider.Runtime\MyTypeProvider.Runtime.fs

Finally, trying to build it in Visual Studio (which should, logically, be similar to dotnet build), fails with these messages:

Build started...
1>------ Build started: Project: MyTypeProvider.DesignTime, Configuration: Debug Any CPU ------
1>D:\Projects\Test\MyTypeProvider\paket-files\fsprojects\FSharp.TypeProviders.SDK\src\ProvidedTypes.fs(10272,16): warning FS0026: This rule will never be matched
1>MyTypeProvider.DesignTime -> D:\Projects\Test\MyTypeProvider\src\MyTypeProvider.DesignTime\bin\Debug\netstandard2.1\MyTypeProvider.DesignTime.dll
1>Done building project "MyTypeProvider.DesignTime.fsproj".
2>------ Build started: Project: MyTypeProvider.Runtime, Configuration: Debug Any CPU ------
2>FSC : error FS3049: The type provider 'D:\Projects\Test\MyTypeProvider\src\MyTypeProvider.DesignTime\bin\Debug\netstandard2.1\MyTypeProvider.DesignTime.dll' reported an error: The type provider designer assembly 'MyTypeProvider.DesignTime.dll' could not be loaded from folder 'D:\Projects\Test\MyTypeProvider\src\MyTypeProvider.DesignTime\bin\Debug\netstandard2.1'. The exception reported was: System.IO.FileNotFoundException - Could not load file or assembly 'netstandard, Version=2.1.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The system cannot find the file specified.
2>FSC : warning FS3005: Referenced assembly 'D:\Projects\Test\MyTypeProvider\src\MyTypeProvider.DesignTime\bin\Debug\netstandard2.1\MyTypeProvider.DesignTime.dll' has assembly level attribute 'Microsoft.FSharp.Core.CompilerServices.TypeProviderAssemblyAttribute' but no public type provider classes were found
2>Done building project "MyTypeProvider.Runtime.fsproj" -- FAILED.
3>------ Build started: Project: MyTypeProvider.Tests, Configuration: Debug Any CPU ------
3>FSC : error FS0078: Unable to find the file 'D:\Projects\Test\MyTypeProvider\src\MyTypeProvider.Runtime\bin\Debug\netstandard2.1\MyTypeProvider.Runtime.dll' in any of� C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0\ref\net5.0� D:\Projects\Test\MyTypeProvider\tests\MyTypeProvider.Tests� C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\CommonExtensions\Microsoft\FSharp\Tools\
3>Done building project "MyTypeProvider.Tests.fsproj" -- FAILED.

Known workarounds

Not sure. Maybe using VS Code instead, or Rider. Haven't tried that yet.

For getting rid of the old version of FSharp.Core, this turned out to be not so easy, as the Paket.Restore.targets comes with the following lines:

    <DisableImplicitFSharpCoreReference>true</DisableImplicitFSharpCoreReference>
    <DisableImplicitSystemValueTupleReference>true</DisableImplicitSystemValueTupleReference>

Setting these to false only gets them overridden. I did try to override them in the fsproj files, and remove the FSharp.Core references in Paket, which seems to do the trick. But after this it still won't compile.

I also wanted to build in net6.0 but that seemed to be utterly impossible and I wasn't sure what was blocking this, just too many spurious errors.

Looks like quite a few of these errors are due to Paket not dealing well with Nuget packages, as explained here: fsprojects/Paket#3064. For instance, trying to reference NUnit3TestAdapter after updating to net6.0 or net5.0, this didn't work anymore and I received the following error:

Paket failed with
-> Installation Errors :
- d:\Projects\Test\MyTypeProvider\tests\FSharp.ApplicativeRecords.Tests\paket.references uses NuGet package NUnit3TestAdapter, but it was not found in the paket.lock file in group Test.
However, NUnit3TestAdapter was found in group Main.
- d:\Projects\Test\MyTypeProvider\tests\FSharp.ApplicativeRecords.Tests\paket.references uses NuGet package NUnit.Analyzers, but it was not found in the paket.lock file in group Test.

Changing netstandard2.1 to netstandard2.0 seemed to get rid of some errors and for some reason lets me occasionally compile in VS, but then, after I open the fs files themselves, it's mayhem again with red squigglies.

Related information

  • Operating system: Win11 or Win10
  • Branch: current
  • .NET Runtime, CoreCLR or Mono Version: I tried Core, the default by the template

This is probably also related to this Paket issue that still doesn't seem to be able to deal with the implicit FSharp.Core reference: fsprojects/Paket#3972

@abelbraaksma
Copy link
Member Author

abelbraaksma commented Aug 11, 2022

I found a workaround to get this to work in VS. Just use the template and then copy all the fs and fsi files over to a new .NET 6 project in Visual Studio. This ditches Paket, which seems to be at the root of this problem (I don't know enough about Paket, but it appears that it just doesn't work well with the new implicit F# library and upgrading to .NET 6, and/or upgrading the SDK version. Even after doing all that by hand, it still keeps giving warnings or errors and I didn't manage to sort NUnit issues at all, after upgrade no tests were found anymore).

The other takeaway here is that I think the design of the sln file containing the test project for the type provider is probably not a good idea, as that forces the type provider dll to be in use, which ruins the build. In fact, the Docs say so much: test the type provider in a different script or VS instance.

If you also face this, ensure that you link the source Runtime fs file in the Design project, above your DesignTime.fs and that you add the IS_DESIGNTIME compiletime constant to your project settings. The files ProvidedType.fsi/fs can either be linked or copied.

Finally, ProvidedTypes.fs contains a compile error on line 10840, which only shows if your run Fantomas (which tries to format this, but can't) or specify DEBUG_INFO:

#if DEBUG_INFO
    member codebuf.EmitSeqPoint cenv (m:ILSourceMarker)  = ()   // unit should not be here
          if cenv.generatePdb then 
              ....

Another, less intrusive error is on line 10272, which is a "catch all" match, but the match already is exhaustive on the DU. You can just delete that line:

| _ -> failwith "EmitType"

@dsyme
Copy link
Contributor

dsyme commented Aug 23, 2022

@abelbraaksma I did a bunch of updates last week and tried this again.

Quite a few warnings are produced but this sequence succeeds and the resulting nuget packages look correct.

You can also switch to using the FSharp.TypeProviders.SDK nuget package if you like by editing src\LemonadeProvider.DesignTime\LemonadeProvider.DesignTime.fsproj and the dependency is added into the nuget package correctly.

dotnet new -i FSharp.TypeProviders.Templates
dotnet new typeprovider -n LemonadeProvider -lang F#
cd LemonadeProvider
dotnet tool restore
dotnet paket update
dotnet build -c release
dotnet test -c release
dotnet pack -c release

These are the warnings I get:

C:\Program Files\dotnet\sdk\5.0.411\Microsoft.Common.CurrentVersion.targets(2203,5): warning MSB3277: Found conflicts between different versions of "FSharp.Core" that could not be resolved. [C:\tmp\LemonadeProvider\src\LemonadeProvider.Runtime\LemonadeProvider.Runtime.fsproj]
C:\Program Files\dotnet\sdk\5.0.411\Microsoft.Common.CurrentVersion.targets(2203,5): warning MSB3277: There was a conflict between "FSharp.Core, Version=4.7.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" and "FSharp.Core, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a". [C:\tmp\LemonadeProvider\src\LemonadeProvider.Runtime\LemonadeProvider.Runtime.fsproj]
C:\Program Files\dotnet\sdk\5.0.411\Microsoft.Common.CurrentVersion.targets(2203,5): warning MSB3277:     "FSharp.Core, Version=4.7.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" was chosen because it was primary and "FSharp.Core, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" was not. [C:\tmp\LemonadeProvider\src\LemonadeProvider.Runtime\LemonadeProvider.Runtime.fsproj]
C:\Program Files\dotnet\sdk\5.0.411\Microsoft.Common.CurrentVersion.targets(2203,5): warning MSB3277:     References which depend on "FSharp.Core, Version=4.7.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" [C:\Users\dsyme\.nuget\packages\fsharp.core\4.7.2\lib\netstandard2.0\FSharp.Core.dll]. [C:\tmp\LemonadeProvider\src\LemonadeProvider.Runtime\LemonadeProvider.Runtime.fsproj]
C:\Program Files\dotnet\sdk\5.0.411\Microsoft.Common.CurrentVersion.targets(2203,5): warning MSB3277:         C:\Users\dsyme\.nuget\packages\fsharp.core\4.7.2\lib\netstandard2.0\FSharp.Core.dll [C:\tmp\LemonadeProvider\src\LemonadeProvider.Runtime\LemonadeProvider.Runtime.fsproj]
C:\Program Files\dotnet\sdk\5.0.411\Microsoft.Common.CurrentVersion.targets(2203,5): warning MSB3277:           Project file item includes which caused reference "C:\Users\dsyme\.nuget\packages\fsharp.core\4.7.2\lib\netstandard2.0\FSharp.Core.dll". [C:\tmp\LemonadeProvider\src\LemonadeProvider.Runtime\LemonadeProvider.Runtime.fsproj]
C:\Program Files\dotnet\sdk\5.0.411\Microsoft.Common.CurrentVersion.targets(2203,5): warning MSB3277:             C:\Users\dsyme\.nuget\packages\fsharp.core\4.7.2\lib\netstandard2.0\FSharp.Core.dll [C:\tmp\LemonadeProvider\src\LemonadeProvider.Runtime\LemonadeProvider.Runtime.fsproj]
C:\Program Files\dotnet\sdk\5.0.411\Microsoft.Common.CurrentVersion.targets(2203,5): warning MSB3277:     References which depend on "FSharp.Core, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" []. [C:\tmp\LemonadeProvider\src\LemonadeProvider.Runtime\LemonadeProvider.Runtime.fsproj]
C:\Program Files\dotnet\sdk\5.0.411\Microsoft.Common.CurrentVersion.targets(2203,5): warning MSB3277:         C:\tmp\LemonadeProvider\src\LemonadeProvider.DesignTime\bin\Release\netstandard2.1\LemonadeProvider.DesignTime.dll [C:\tmp\LemonadeProvider\src\LemonadeProvider.Runtime\LemonadeProvider.Runtime.fsproj]
C:\Program Files\dotnet\sdk\5.0.411\Microsoft.Common.CurrentVersion.targets(2203,5): warning MSB3277:           Project file item includes which caused reference "C:\tmp\LemonadeProvider\src\LemonadeProvider.DesignTime\bin\Release\netstandard2.1\LemonadeProvider.DesignTime.dll". [C:\tmp\LemonadeProvider\src\LemonadeProvider.Runtime\LemonadeProvider.Runtime.fsproj]
C:\Program Files\dotnet\sdk\5.0.411\Microsoft.Common.CurrentVersion.targets(2203,5): warning MSB3277:             C:\tmp\LemonadeProvider\src\LemonadeProvider.DesignTime\bin\Release\netstandard2.1\LemonadeProvider.DesignTime.dll [C:\tmp\LemonadeProvider\src\LemonadeProvider.Runtime\LemonadeProvider.Runtime.fsproj]

There are further warnings from dotnet pack

onadeProvider.Runtime.dll
C:\Program Files\dotnet\sdk\5.0.411\Sdks\NuGet.Build.Tasks.Pack\build\NuGet.Build.Tasks.Pack.targets(221,5): warning NU5118: File 'C:\tmp\LemonadeProvider\src\LemonadeProvider.DesignTime\bin\Release\netstandard2.1\de\FSharp.Core.resources.dll' is not added because the package already contains file 'typeproviders\fsharp41\netstandard2.1\FSharp.Core.resources.dll' [C:\tmp\LemonadeProvider\src\LemonadeProvider.Runtime\LemonadeProvider.Runtime.fsproj]
C:\Program Files\dotnet\sdk\5.0.411\Sdks\NuGet.Build.Tasks.Pack\build\NuGet.Build.Tasks.Pack.targets(221,5): warning NU5118: File 'C:\tmp\LemonadeProvider\src\LemonadeProvider.DesignTime\bin\Release\netstandard2.1\es\FSharp.Core.resources.dll' is not added because the package already contains file 'typeproviders\fsharp41\netstandard2.1\FSharp.Core.resources.dll' [C:\tmp\LemonadeProvider\src\LemonadeProvider.Runtime\LemonadeProvider.Runtime.fsproj]
C:\Program Files\dotnet\sdk\5.0.411\Sdks\NuGet.Build.Tasks.Pack\build\NuGet.Build.Tasks.Pack.targets(221,5): warning NU5118: File 'C:\tmp\LemonadeProvider\src\LemonadeProvider.DesignTime\bin\Release\netstandard2.1\fr\FSharp.Core.resources.dll' is not added because the package already contains file 'typeproviders\fsharp41\netstandard2.1\FSharp.Core.resources.dll' [C:\tmp\LemonadeProvider\src\LemonadeProvider.Runtime\LemonadeProvider.Runtime.fsproj]
C:\Program Files\dotnet\sdk\5.0.411\Sdks\NuGet.Build.Tasks.Pack\build\NuGet.Build.Tasks.Pack.targets(221,5): warning NU5118: File 'C:\tmp\LemonadeProvider\src\LemonadeProvider.DesignTime\bin\Release\netstandard2.1\it\FSharp.Core.resources.dll' is not added because the package already contains file 'typeproviders\fsharp41\netstandard2.1\FSharp.Core.resources.dll' [C:\tmp\LemonadeProvider\src\LemonadeProvider.Runtime\LemonadeProvider.Runtime.fsproj]
C:\Program Files\dotnet\sdk\5.0.411\Sdks\NuGet.Build.Tasks.Pack\build\NuGet.Build.Tasks.Pack.targets(221,5): warning NU5118: File 'C:\tmp\LemonadeProvider\src\LemonadeProvider.DesignTime\bin\Release\netstandard2.1\ja\FSharp.Core.resources.dll' is not added because the package already contains file 'typeproviders\fsharp41\netstandard2.1\FSharp.Core.resources.dll' [C:\tmp\LemonadeProvider\src\LemonadeProvider.Runtime\LemonadeProvider.Runtime.fsproj]
C:\Program Files\dotnet\sdk\5.0.411\Sdks\NuGet.Build.Tasks.Pack\build\NuGet.Build.Tasks.Pack.targets(221,5): warning NU5118: File 'C:\tmp\LemonadeProvider\src\LemonadeProvider.DesignTime\bin\Release\netstandard2.1\ko\FSharp.Core.resources.dll' is not added because the package already contains file 'typeproviders\fsharp41\netstandard2.1\FSharp.Core.resources.dll' [C:\tmp\LemonadeProvider\src\LemonadeProvider.Runtime\LemonadeProvider.Runtime.fsproj]
C:\Program Files\dotnet\sdk\5.0.411\Sdks\NuGet.Build.Tasks.Pack\build\NuGet.Build.Tasks.Pack.targets(221,5): warning NU5118: File 'C:\tmp\LemonadeProvider\src\LemonadeProvider.DesignTime\bin\Release\netstandard2.1\pl\FSharp.Core.resources.dll' is not added because the package already contains file 'typeproviders\fsharp41\netstandard2.1\FSharp.Core.resources.dll' [C:\tmp\LemonadeProvider\src\LemonadeProvider.Runtime\LemonadeProvider.Runtime.fsproj]
C:\Program Files\dotnet\sdk\5.0.411\Sdks\NuGet.Build.Tasks.Pack\build\NuGet.Build.Tasks.Pack.targets(221,5): warning NU5118: File 'C:\tmp\LemonadeProvider\src\LemonadeProvider.DesignTime\bin\Release\netstandard2.1\pt-BR\FSharp.Core.resources.dll' is not added because the package already contains file 'typeproviders\fsharp41\netstandard2.1\FSharp.Core.resources.dll' [C:\tmp\LemonadeProvider\src\LemonadeProvider.Runtime\LemonadeProvider.Runtime.fsproj]
C:\Program Files\dotnet\sdk\5.0.411\Sdks\NuGet.Build.Tasks.Pack\build\NuGet.Build.Tasks.Pack.targets(221,5): warning NU5118: File 'C:\tmp\LemonadeProvider\src\LemonadeProvider.DesignTime\bin\Release\netstandard2.1\ru\FSharp.Core.resources.dll' is not added because the package already contains file 'typeproviders\fsharp41\netstandard2.1\FSharp.Core.resources.dll' [C:\tmp\LemonadeProvider\src\LemonadeProvider.Runtime\LemonadeProvider.Runtime.fsproj]
C:\Program Files\dotnet\sdk\5.0.411\Sdks\NuGet.Build.Tasks.Pack\build\NuGet.Build.Tasks.Pack.targets(221,5): warning NU5118: File 'C:\tmp\LemonadeProvider\src\LemonadeProvider.DesignTime\bin\Release\netstandard2.1\tr\FSharp.Core.resources.dll' is not added because the package already contains file 'typeproviders\fsharp41\netstandard2.1\FSharp.Core.resources.dll' [C:\tmp\LemonadeProvider\src\LemonadeProvider.Runtime\LemonadeProvider.Runtime.fsproj]
C:\Program Files\dotnet\sdk\5.0.411\Sdks\NuGet.Build.Tasks.Pack\build\NuGet.Build.Tasks.Pack.targets(221,5): warning NU5118: File 'C:\tmp\LemonadeProvider\src\LemonadeProvider.DesignTime\bin\Release\netstandard2.1\zh-Hans\FSharp.Core.resources.dll' is not added because the package already contains file 'typeproviders\fsharp41\netstandard2.1\FSharp.Core.resources.dll' [C:\tmp\LemonadeProvider\src\LemonadeProvider.Runtime\LemonadeProvider.Runtime.fsproj]
C:\Program Files\dotnet\sdk\5.0.411\Sdks\NuGet.Build.Tasks.Pack\build\NuGet.Build.Tasks.Pack.targets(221,5): warning NU5118: File 'C:\tmp\LemonadeProvider\src\LemonadeProvider.DesignTime\bin\Release\netstandard2.1\zh-Hant\FSharp.Core.resources.dll' is not added because the package already contains file 'typeproviders\fsharp41\netstandard2.1\FSharp.Core.resources.dll' [C:\tmp\LemonadeProvider\src\LemonadeProvider.Runtime\LemonadeProvider.Runtime.fsproj]
C:\tmp\LemonadeProvider\.paket\Paket.Restore.targets(322,5): warning NU5100: The assembly 'typeproviders\fsharp41\netstandard2.1\FSharp.Core.resources.dll' is not inside the 'lib' folder and hence it won't be added as a reference when the package is installed into a project. Move it into the 'lib' folder if it needs to be referenced. [C:\tmp\LemonadeProvider\src\LemonadeProvider.Runtime\LemonadeProvider.Runtime.fsproj]
C:\tmp\LemonadeProvider\.paket\Paket.Restore.targets(322,5): warning NU5100: The assembly 'typeproviders\fsharp41\netstandard2.1\FSharp.TypeProviders.SDK.dll' is not inside the 'lib' folder and hence it won't be added as a reference when the package is installed into a project. Move it into the 'lib' folder if it needs to be referenced. [C:\tmp\LemonadeProvider\src\LemonadeProvider.Runtime\LemonadeProvider.Runtime.fsproj]
C:\tmp\LemonadeProvider\.paket\Paket.Restore.targets(322,5): warning NU5100: The assembly 'typeproviders\fsharp41\netstandard2.1\LemonadeProvider.DesignTime.dll' is not inside the 'lib' folder and hence it won't be added as a reference when the package is installed into a project. Move it into the 'lib' folder if it needs to be referenced. [C:\tmp\LemonadeProvider\src\LemonadeProvider.Runtime\LemonadeProvider.Runtime.fsproj]

@dsyme dsyme changed the title Out of the box experience is broken, loading, compiling or running tests in VS 2022 is not possible Warnings produced when build and packing template Aug 23, 2022
@dsyme
Copy link
Contributor

dsyme commented Aug 23, 2022

@abelbraaksma I've adjusted the title to reflect current state

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants