How can I stop ServiceStack 3.9.71 NuGet package installing ServiceStack.Text 4.0.24?

I have a project that uses ServiceStack; we are running the old 3.9.x codebase instead of upgrading to 4.x since ServiceStack 4 requires a commercial license.

My own API client has a dependency defined in the file .nuspec

like this:

<dependencies>
  <dependency id="DotNetOpenAuth.OAuth2.Client" version="[4.3,5)" />
  <dependency id="log4net" version="[2.0,2.1)" />
  <dependency id="ServiceStack" version="[3.9.71,4)" />
</dependencies>

      

The problem is that the ServiceStack package depends on various other bits of the ServiceStack infrastructure, and installing ServiceStack 3.9.71 installs ServiceStack.Text v4.0.24 into my project.It opens a dialog box asking for the license to be accepted, and that's what warned me about that something weird is going on - but not to manually define my own dependencies for other required ServiceStack components, how can I make sure I'm not going with unlicensed ServiceStack 4.x bits in my project?

+3


source to share


2 answers


Make the ServiceStack.Text dependency explicit in your .nuspec and put it before the ServiceStack dependency.

<dependencies>
  <dependency id="DotNetOpenAuth.OAuth2.Client" version="[4.3,5)" />
  <dependency id="log4net" version="[2.0,2.1)" />
  <dependency id="ServiceStack.Text" version="[3.9.71,4)" />
  <dependency id="ServiceStack" version="[3.9.71,4)" />
</dependencies>

      

This will force NuGet to resolve the ServiceStack.Text using the constraint.



The problem with simply installing ServiceStack using the version range [3.9.71,4) is that NuGet resolves the ServiceStack.Common dependency to the lowest compatible version of ServiceStack.Common it detects is version 3.9.11. ServiceStack.Common 3.9.11 does not specify a dependency range for ServiceStack.Text, so NuGet installs version 4.0. Later versions of ServiceStack.Common have a range for the ServiceStack.Text package, but older versions do not. So, without an explicit dependency or the presence of the ServiceStack.Text NuGet package, so it fits in the range, there is not much you can do when installing the NuGet package.

The only thing you can do is set a limit in the packages.config file to prevent installing a newer version of ServiceStack.

<packages>
    <package id="ServiceStack.Text" version="3.9.71" allowedVersions="[3.9.71,4)" />
</packages>

      

+6


source


I made my own "wrapper" package for this, with no additional files but only dependencies - like this:



<dependencies>
  <dependency id="ServiceStack.Text" version="[3.9.71]" />
  <dependency id="ServiceStack.Common" version="[3.9.71]" />
  <dependency id="ServiceStack.Redis" version="[3.9.71]" />
  <dependency id="ServiceStack.OrmLite.SqlServer" version="[3.9.71]" />
  <dependency id="ServiceStack" version="[3.9.71]" />
</dependencies>

      

0


source







All Articles