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

Lock file has incorrect .NET framework lock #462

Closed
isaacabraham opened this issue Dec 21, 2014 · 22 comments
Closed

Lock file has incorrect .NET framework lock #462

isaacabraham opened this issue Dec 21, 2014 · 22 comments
Labels

Comments

@isaacabraham
Copy link
Contributor

Create a paket.dependencies file as follows: -

source https://nuget.org/api/v2
nuget WindowsAzure.Storage

The lock file generated looks like this: -

NUGET
  remote: https://nuget.org/api/v2
  specs:
    Microsoft.Data.Edm (5.6.3)
    Microsoft.Data.OData (5.6.3)
      Microsoft.Data.Edm (5.6.3)
      System.Spatial (5.6.3)
    Microsoft.Data.Services.Client (5.6.3) - net40
      Microsoft.Data.OData (5.6.3)
    Microsoft.WindowsAzure.ConfigurationManager (2.0.3) - net40
    Newtonsoft.Json (6.0.6) - net40
    System.Spatial (5.6.3)
    WindowsAzure.Storage (4.3.0)
      Microsoft.Data.OData (>= 5.6.2)
      Microsoft.Data.OData (>= 5.6.2) - net40
      Microsoft.Data.OData (>= 5.6.2) - winv4.5
      Microsoft.Data.OData (>= 5.6.2) - wpv8.0
      Microsoft.Data.Services.Client (>= 5.6.2) - net40
      Microsoft.WindowsAzure.ConfigurationManager (>= 1.8.0.0) - net40
      Newtonsoft.Json (>= 5.0.8) - net40
      Newtonsoft.Json (>= 5.0.8) - wpv8.0

Notice the net40 restrictions on a number of dependencies. On a brand new FSharp Class Library (using net45), these are not available for consumption within code. For example, for Newtonsoft.Json, the only node in the .fsproj file is: -

  <Choose>
    <When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.0'">
      <ItemGroup>
        <Reference Include="Newtonsoft.Json">
          <HintPath>..\packages\Newtonsoft.Json\lib\net40\Newtonsoft.Json.dll</HintPath>
          <Private>True</Private>
          <Paket>True</Paket>
        </Reference>
      </ItemGroup>
    </When>
  </Choose>

If you remove the net40 from the lock file and then do a paket install --hard, everything works fine. You get multiple When elements in the project file, one for each version made available by the dependency.

@forki
Copy link
Member

forki commented Dec 21, 2014

Mhm the nuspec specifies the net40 restriction. See:

<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
  <metadata>
    <id>WindowsAzure.Storage</id>
    <version>4.3.0</version>
    <title>Windows Azure Storage</title>
    <authors>Microsoft</authors>
    <owners>Microsoft</owners>
    <licenseUrl>http://go.microsoft.com/fwlink/?LinkId=331471</licenseUrl>
    <projectUrl>http://go.microsoft.com/fwlink/?LinkId=235168</projectUrl>
    <iconUrl>http://go.microsoft.com/fwlink/?LinkID=288890</iconUrl>
    <requireLicenseAcceptance>true</requireLicenseAcceptance>
    <description>This client library enables working with the Microsoft Azure storage services which include the blob and file service for storing binary and text data, the table service for storing structured non-relational data, and the queue service for storing messages that may be accessed by a client. 
For this release see notes - https://github.com/Azure/azure-storage-net/blob/master/README.md and https://github.com/Azure/azure-storage-net/blob/master/changelog.txt
Microsoft Azure Storage team's blog - http://blogs.msdn.com/b/windowsazurestorage/</description>
    <summary>A client library for working with Microsoft Azure storage services including blobs, files, tables, and queues.</summary>
    <tags>Microsoft, Azure, Storage, Table, Blob, File, Queue, Scalable, windowsazureofficial</tags>
    <dependencies>
      <group targetFramework=".NETFramework4.0-Client">
        <dependency id="Microsoft.Data.OData" version="5.6.2" />
        <dependency id="Newtonsoft.Json" version="5.0.8" />
        <dependency id="Microsoft.Data.Services.Client" version="5.6.2" />
        <dependency id="Microsoft.WindowsAzure.ConfigurationManager" version="1.8.0.0" />
      </group>
      <group targetFramework="Windows8.0">
        <dependency id="Microsoft.Data.OData" version="5.6.2" />
      </group>
      <group targetFramework="WindowsPhoneApp0.0">
        <dependency id="Microsoft.Data.OData" version="5.6.2" />
      </group>
      <group targetFramework="WindowsPhone8.0">
        <dependency id="Microsoft.Data.OData" version="5.6.2" />
        <dependency id="Newtonsoft.Json" version="5.0.8" />
      </group>
    </dependencies>
    <frameworkAssemblies>
      <frameworkAssembly assemblyName="System.Data" targetFramework=".NETFramework4.0-Client" />
      <frameworkAssembly assemblyName="System.Xml" targetFramework="" />
      <frameworkAssembly assemblyName="System.Xml.Linq" targetFramework="" />
    </frameworkAssemblies>
    <references>
      <reference file="Microsoft.WindowsAzure.Storage.dll" />
    </references>
  </metadata>
</package>

Nuget.exe will still install Json.Net.dll - strange.

@forki
Copy link
Member

forki commented Dec 21, 2014

Ok, after rereading #140 (comment) and remembering disucssion with @agross I now think we need to do the same framework inheritance strategy as in the file referencing algorithm.

@forki forki added the bug label Dec 21, 2014
@isaacabraham
Copy link
Contributor Author

Yeah that was my thought - net40 should fall back to any higher FWs as well unless specified elsewhere.

@isaacabraham
Copy link
Contributor Author

I think that this was the root cause of #448 as well.

@forki
Copy link
Member

forki commented Dec 21, 2014

It's actually much more complicated than I thought, but I'm starting to work on it...

@isaacabraham
Copy link
Contributor Author

:-( sorry!

@forki
Copy link
Member

forki commented Dec 21, 2014

/cc @cdrnet

@forki
Copy link
Member

forki commented Dec 22, 2014

the new lockfile looks like that:

NUGET
  remote: http://nuget.org/api/v2
  specs:
    Microsoft.Data.Edm (5.6.3)
    Microsoft.Data.OData (5.6.3) - >= net40, winv4.5, wpv8.0
      Microsoft.Data.Edm (5.6.3)
      System.Spatial (5.6.3)
    Microsoft.Data.Services.Client (5.6.3) - >= net40
      Microsoft.Data.OData (5.6.3)
    Microsoft.WindowsAzure.ConfigurationManager (2.0.3) - >= net40
    Newtonsoft.Json (6.0.6) - >= net40, wpv8.0
    System.Spatial (5.6.3)
    WindowsAzure.Storage (4.3.0)
      Microsoft.Data.OData (>= 5.6.2) - >= net40, winv4.5, wpv8.0
      Microsoft.Data.Services.Client (>= 5.6.2) - >= net40
      Microsoft.WindowsAzure.ConfigurationManager (>= 1.8.0.0) - >= net40
      Newtonsoft.Json (>= 5.0.8) - >= net40, wpv8.0

@forki
Copy link
Member

forki commented Dec 22, 2014

The Lockfile for MathNet.Numerics looks like that:

NUGET
  remote: http://nuget.org/api/v2
  specs:
    MathNet.Numerics (3.3.0)
      TaskParallelLibrary (>= 1.0.2856) - >= net35 < net40
    TaskParallelLibrary (1.0.2856) - >= net35 < net40

@cdrnet
Copy link
Member

cdrnet commented Dec 22, 2014

Great, that looks exactly like what I intended in the MathNet.Numerics nuspec!

@forki
Copy link
Member

forki commented Dec 22, 2014

please test 0.20 alpha - it's a huge change

@isaacabraham
Copy link
Contributor Author

awesome :-) will check shortly :-)

@isaacabraham
Copy link
Contributor Author

Just tried using the latest v20 alpha (6) and it works fine. Great stuff.

@cdrnet
Copy link
Member

cdrnet commented Dec 23, 2014

I've just tried with v20 alpha 7 as well, with a package with even more complicated framework groups: MathNet.Numerics.FSharp-v3.3.0 (sorry! - ah, and yes, the next version will migrate to the new FSharp.Core NuGet package)

    <dependencies>
        <group>
            <dependency id="MathNet.Numerics" version="[3.3.0]" />
            <dependency id="FSharp.Core.Microsoft.Signed" version="3.1.1.1" />
        </group>
        <group targetFramework=".NETFramework3.5">
            <dependency id="MathNet.Numerics" version="[3.3.0]" />
        </group>
        <group targetFramework=".NETFramework4.0">
            <dependency id="MathNet.Numerics" version="[3.3.0]" />
            <dependency id="FSharp.Core.Microsoft.Signed" version="3.1.1.1" />
        </group>
    </dependencies>

The intention of these groups is to have the MathNet.Numerics dependency in all cases, and the FSharp.Core dependency everywhere except .Net3.5 <= x < .Net 4.0. The group without a target framework acts as fallback where none of the groups is inherited by the current target.

Now, with v20alpha7 the dependencies file

source http://nuget.org/api/v2

# Core Dependencies
nuget FParsec ~> 1.0.1
nuget FSharp.Core.Microsoft.Signed ~> 3.1.1
nuget MathNet.Numerics.FSharp ~> 3.3.0

# Development Dependencies
nuget FsUnit ~> 1.3

# Tools
nuget FAKE ~> 3.5
nuget NUnit.Runners ~> 2.6
nuget FSharp.Formatting !~> 2.4
nuget NuGet.CommandLine

leads to the lock file

NUGET
  remote: http://nuget.org/api/v2
  specs:
    FAKE (3.12.2)
    FParsec (1.0.1)
    FSharp.Compiler.Service (0.0.67)
    FSharp.Core.Microsoft.Signed (3.1.1.1)
    FSharp.Formatting (2.4.36)
      FSharp.Compiler.Service (0.0.67)
      Microsoft.AspNet.Razor (2.0.30506.0)
      RazorEngine (3.3.0)
    FsUnit (1.3.0.1)
      NUnit (>= 2.6.3)
    MathNet.Numerics (3.3.0) - >= net35, >= net40
      TaskParallelLibrary (>= 1.0.2856) - >= net35 < net40
    MathNet.Numerics.FSharp (3.3.0)
      FSharp.Core.Microsoft.Signed (>= 3.1.1.1) - >= net40
      MathNet.Numerics (3.3.0) - >= net35, >= net40
    Microsoft.AspNet.Razor (2.0.30506.0)
    NuGet.CommandLine (2.8.3)
    NUnit (2.6.4)
    NUnit.Runners (2.6.4)
    RazorEngine (3.3.0)
      Microsoft.AspNet.Razor (>= 2.0.30506.0)
    TaskParallelLibrary (1.0.2856) - >= net35 < net40

The lock on TaskParallelLibrary is now perfect, but to my understanding the MathNet.Numerics dependency should not have any framework constraints, or at least the >=net40 one dropped?

@cdrnet
Copy link
Member

cdrnet commented Dec 23, 2014

Hm, maybe I better simplify these constraints instead, they are way too complicated ...

@forki
Copy link
Member

forki commented Dec 23, 2014

Yes I thought about that case. Thanks for giving a test case. Will try to solve that.

@forki
Copy link
Member

forki commented Dec 27, 2014

source http://nuget.org/api/v2

nuget MathNet.Numerics.FSharp ~> 3.3.0

now gives:

NUGET
  remote: http://nuget.org/api/v2
  specs:
    FSharp.Core.Microsoft.Signed (3.1.1.1)
    MathNet.Numerics (3.3.0)
      TaskParallelLibrary (>= 1.0.2856) - >= net35 < net40
    MathNet.Numerics.FSharp (3.3.0)
      FSharp.Core.Microsoft.Signed (>= 3.1.1.1)
      MathNet.Numerics (3.3.0)
    TaskParallelLibrary (1.0.2856) - >= net35 < net40

@forki
Copy link
Member

forki commented Dec 27, 2014

seems there is still an issue with FSharp.Core.Microsoft.Signed!?

@isaacabraham
Copy link
Contributor Author

Also seen that Humanizer isn't working getting referenced on the latest alpha. Looking at the package, it has a single folder in the lib folder: portable-win%2Bnet40%2Bsl50%2Bwp8%2Bwpa81. Yet on a .NET 4.5.1 project, despite there being an entry in the lock and references files, there's no entry in the .fsproj (not even one with a bad When condition).
In fact I can't even reference this dll directly - it looks like the + in the lib folder have been URL encoded. If I manually rename the lib folder to have + instead of %2B, it all works.

@forki
Copy link
Member

forki commented Dec 27, 2014

Isaac, can you please create a repro sample and open a new issue. I tried to reproduce, but Humanizer works fine for me.

@isaacabraham
Copy link
Contributor Author

Sure. Let me remove the package completely and redownload it first.

@isaacabraham
Copy link
Contributor Author

Bizarre. Just redownloaded it and it came down fine without %2B. Sorry.

@forki forki closed this as completed Dec 29, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants