Share versions between Paket dependency groups?

234 Views Asked by At

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"?

2

There are 2 best solutions below

3
On

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.

1
On

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