Zaid-Ajaj / LiteDB.FSharp

Advanced F# Support for LiteDB, an embedded NoSql database for .NET with type-safe query expression through F# quotations
MIT License
180 stars 22 forks source link

Restrict LiteDB dependency version to 4.x #49

Closed TeaDrivenDev closed 4 years ago

TeaDrivenDev commented 4 years ago

As noted in #45, LiteDB.FSharp is currently incompatible with LiteDB 5.x due to API changes, but it is possible to install them together, as LiteDB.FSharp does not restrict the version range for the LiteDB dependency. The user will only learn about the incompatibility at runtime.

This PR does the following:

Using the Paket template file means that all the package metadata entries have been moved over there. I have not looked into potential ways of having FAKE/Paket transfer the information over from the project file during the build process, as it didn't seem worth the effort. It's still all in one place, just in a different file.

I have tried to keep the resulting .nuspec file in the package as close as possible to the previous one.

This is the .nuspec file currently live on NuGet:

<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
  <metadata>
    <id>LiteDB.FSharp</id>
    <version>2.15.0</version>
    <authors>Zaid Ajaj</authors>
    <owners>Zaid Ajaj</owners>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <licenseUrl>https://github.com/Zaid-Ajaj/LiteDB.FSharp/blob/master/LICENSE</licenseUrl>
    <projectUrl>https://github.com/Zaid-Ajaj/LiteDB.FSharp</projectUrl>
    <description>Advanced F# Support for LiteDB with query construction through quotation expressions</description>
    <releaseNotes>Support deserialization of optional lists and arrays (#44)</releaseNotes>
    <tags>fsharp litedb embedded database document-database</tags>
    <dependencies>
      <group targetFramework=".NETFramework4.5">
        <dependency id="FSharp.Core" version="4.7.0" exclude="Build,Analyzers" />
        <dependency id="LiteDB" version="4.1.4" exclude="Build,Analyzers" />
        <dependency id="Newtonsoft.Json" version="12.0.2" exclude="Build,Analyzers" />
        <dependency id="TypeShape" version="7.1.0" exclude="Build,Analyzers" />
      </group>
      <group targetFramework=".NETFramework4.6.1">
        <dependency id="FSharp.Core" version="4.7.0" exclude="Build,Analyzers" />
        <dependency id="LiteDB" version="4.1.4" exclude="Build,Analyzers" />
        <dependency id="Newtonsoft.Json" version="12.0.2" exclude="Build,Analyzers" />
        <dependency id="TypeShape" version="7.1.0" exclude="Build,Analyzers" />
      </group>
      <group targetFramework=".NETStandard2.0">
        <dependency id="FSharp.Core" version="4.7.0" exclude="Build,Analyzers" />
        <dependency id="LiteDB" version="4.1.4" exclude="Build,Analyzers" />
        <dependency id="Newtonsoft.Json" version="12.0.2" exclude="Build,Analyzers" />
        <dependency id="TypeShape" version="7.1.0" exclude="Build,Analyzers" />
      </group>
    </dependencies>
  </metadata>
</package>

This is what is generated by this PR:

<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
  <metadata>
    <id>LiteDB.FSharp</id>
    <version>2.15.1</version>
    <title>LiteDB.FSharp</title>
    <authors>Zaid Ajaj</authors>
    <owners>Zaid Ajaj</owners>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <licenseUrl>https://github.com/Zaid-Ajaj/LiteDB.FSharp/blob/master/LICENSE</licenseUrl>
    <projectUrl>https://github.com/Zaid-Ajaj/LiteDB.FSharp</projectUrl>
    <description>Advanced F# Support for LiteDB with query construction through quotation expressions</description>
    <releaseNotes>Restrict LiteDB version to 4.x</releaseNotes>
    <tags>fsharp litedb embedded database document-database</tags>
    <dependencies>
      <dependency id="FSharp.Core" version="4.7.0" />
      <dependency id="LiteDB" version="[4.1.4, 5.0.0)" />
      <dependency id="Newtonsoft.Json" version="12.0.2" />
      <dependency id="TypeShape" version="7.1.0" />
    </dependencies>
  </metadata>
</package>

The dependencies are filled automatically by Paket, relying on the information in paket.dependencies and paket.references. This avoids having to maintain them in multiple places, but causes them to be listed only once instead of for each individual platform target. I'm not sure if that might allow installing the package into projects using incompatible platforms, but I think it shouldn't.

The files to include in the package are also determined automatically by Paket and are identical to those currently included.

As before, I have not tested publishing the package.

Zaid-Ajaj commented 4 years ago

Hi there @TeaDrivenDev, thanks a lot for taking a stab at the situation. I am looking at the changes in the code and they look good but it seems that the newly generated nuspec file doesn't allow for multi-targeting, is that the case here?

TeaDrivenDev commented 4 years ago

No, that works fine (package pushed to and consumed from MyGet):

image

The dependencies are only listed once because unlike dotnet pack, Paket doesn't split them up by framework when auto-generating them, as they are identical anyway.

Zaid-Ajaj commented 4 years ago

Hello @TeaDrivenDev, it took me a while but I finally got around to publish the fix within the PR. Now the version constraint should not allow people to install the package with incompatible versions 😄 thanks a lot for this :pray: