1

In the examples for Paket dependency groups, there is often a "main" and "test" group:

source https://api.nuget.org/v3/index.json

storage: none
framework: netcoreapp3.1, netstandard2.1

nuget FSharp.Core
nuget FParsec



group test

  source https://api.nuget.org/v3/index.json

  nuget FSharp.Core
  nuget FParsec
  nuget xunit 2.4.1
  nuget FsUnit.xUnit 3.8.0

In order to use a dependency in both the library code and the test code, I can add it to both groups.

But is there a way to say "match the version of nuget FParsec in the test and the main groups"?

sdgfsdh
  • 33,689
  • 26
  • 132
  • 245

2 Answers2

2

I'm not sure - but what if you get rid of nuget FParsec from inside the test group and specify the one from the main group in paket.references?

paket.references

FParsec

group test
    xunit
    FsUnit.xUnit
Daniel
  • 1,432
  • 1
  • 16
  • 31
  • Interesting. So what happens if a dependency is in two groups (directly or transitively) and resolves to different versions? – sdgfsdh Jan 27 '21 at 11:48
0

I recommend you don't use a test group and you put the test libraries in the main group instead. Any packages used in test runs should match versions used by the code being tested so there's no need to resolve dependencies separately. The latest version of the SAFE template follows this approach.

Groups can be useful if you have projects/scripts that really never share the same runtime. That's why the SAFE Template uses a Build group: Those dependencies are used in a FAKE script that don't depend directly on the rest on the app code.

TheQuickBrownFox
  • 10,544
  • 1
  • 22
  • 35
  • How does the test libraries relate to the main group? IMHO it would totally make sense to separate the two things as long as FParsec stays just in the main group. – Daniel Jan 28 '21 at 08:08
  • You can't run two versions of the same library at the same time in .NET. So the test libraries relate to the main group because of the test code which runs both of them together. What advantages to you get from having a separate test group here? – TheQuickBrownFox Jan 28 '21 at 17:47
  • The first I can think of is by not restoring the test packages for a production build. Maybe it doesn't make sense anymore as there exists build optimisation options which handles that already... never mind I was just curious :) – Daniel Jan 28 '21 at 18:38