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

Restrict LiteDB dependency version to 4.x #49

Merged
merged 1 commit into from
May 2, 2020

Conversation

TeaDrivenDev
Copy link
Contributor

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:

  • Replace NuGet package creation for LiteDB.FSharp via simple dotnet pack with Paket using a template file to allow for specifying dependency version ranges (This is not possible at this time with dotnet pack in a project using Paket for its own dependency management, due to Losing version-range when 'dotnet pack' fsprojects/Paket#2883.)
  • Restrict the version range for the LiteDB dependency to 4.1.4 <= x < 5.0
  • Move the output directory for the Release configuration and the created package to bin in the repository root. This seemed more appropriate when not using the built-in package creation with dotnet pack.
  • Bump the package version to 2.15.1

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.

Restrict LiteDB dependency version to 4.x
@Zaid-Ajaj
Copy link
Owner

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
Copy link
Contributor Author

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 Zaid-Ajaj merged commit 83d67fc into Zaid-Ajaj:master May 2, 2020
@Zaid-Ajaj
Copy link
Owner

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 🙏

@TeaDrivenDev TeaDrivenDev deleted the restrictlitedbversion branch May 5, 2020 16:06
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

Successfully merging this pull request may close these issues.

None yet

2 participants