nreco / lambdaparser

Runtime parser for string expressions (formulas, method calls). Builds dynamic LINQ expression tree and compiles it to lambda delegate.
http://www.nrecosite.com/
MIT License
307 stars 55 forks source link

Failed to add reference. The package 'NReco.LambdaParser' tried to add a framework reference to 'System.Collections' which was not found in the GAC. #20

Closed OPunktSchmidt closed 4 years ago

OPunktSchmidt commented 4 years ago

I get this error when i try to add the latest version of this nuget package to my Xamarin.Forms project.

Failed to add reference. The package 'NReco.LambdaParser' tried to add a framework reference to 'System.Collections' which was not found in the GAC. This is possibly a bug in the package. Please contact the package owners for assistance.

VitaliyMF commented 4 years ago

@OPunktSchmidt I may assume that something is wrong with your Xamarin.Forms environment. Take a look to the "Dependencies" of NReco.LambdaParser: https://www.nuget.org/packages/NReco.LambdaParser/

It has both netstandard2.0 (without dependencies at all) and netstandard1.3 builds. I have no idea how error you reported may be fixed on NReco.LambdaParser side.

p.s. do you use latest version of Visual Studio 2017/19? Also ensure that your project references nuget packages from .csproj file; if you still use packages.config you can migrate to csproj with one click.

OPunktSchmidt commented 4 years ago

Migrate from packages.config to csproj was the solution

MagicAndre1981 commented 4 years ago

I also suffer this issue,

Failed to add reference. The package 'NReco.LambdaParser' tried to add a framework reference to 'System.Collections' which was not found in the GAC.

but can't migrate from packages.config to PackageReferenceInclude due to a VS2017 bug, where ref assemblies are used instead of real implementation dlls.

The frameworkAssembly entries look wrong in the nuspec file. System.Collections is defined in netstandard.dll

VitaliyMF commented 4 years ago

@MagicAndre1981 this is a bug in tooling, I don't know what can be done on NReco.LambdaParser nuget package side.

MagicAndre1981 commented 4 years ago

I build the nugets on my own and the wrong framework entries are not included:

Yours:

<dependencies>
      <group targetFramework=".NETPortable0.0-Profile259" />
      <group targetFramework=".NETPortable0.0-Profile328" />
      <group targetFramework=".NETStandard1.3">
        <dependency id="NETStandard.Library" version="1.6.0" exclude="Build,Analyzers" />
        <dependency id="System.Reflection.TypeExtensions" version="4.1.0" exclude="Build,Analyzers" />
      </group>
      <group targetFramework=".NETStandard2.0" />
    </dependencies>
    <frameworkAssemblies>
      <frameworkAssembly assemblyName="mscorlib" targetFramework=".NETPortable0.0-Profile328" />
      <frameworkAssembly assemblyName="System.Core" targetFramework=".NETPortable0.0-Profile328, .NETPortable0.0-Profile259" />
      <frameworkAssembly assemblyName="System" targetFramework=".NETPortable0.0-Profile328, .NETPortable0.0-Profile259" />
      <frameworkAssembly assemblyName="System.Collections" targetFramework=".NETPortable0.0-Profile259" />
      <frameworkAssembly assemblyName="System.Globalization" targetFramework=".NETPortable0.0-Profile259" />
      <frameworkAssembly assemblyName="System.IO" targetFramework=".NETPortable0.0-Profile259" />
      <frameworkAssembly assemblyName="System.Linq" targetFramework=".NETPortable0.0-Profile259" />
      <frameworkAssembly assemblyName="System.Linq.Expressions" targetFramework=".NETPortable0.0-Profile259" />
      <frameworkAssembly assemblyName="System.Reflection" targetFramework=".NETPortable0.0-Profile259" />
      <frameworkAssembly assemblyName="System.Reflection.Extensions" targetFramework=".NETPortable0.0-Profile259" />
      <frameworkAssembly assemblyName="System.Resources.ResourceManager" targetFramework=".NETPortable0.0-Profile259" />
      <frameworkAssembly assemblyName="System.Runtime" targetFramework=".NETPortable0.0-Profile259" />
      <frameworkAssembly assemblyName="System.Runtime.Extensions" targetFramework=".NETPortable0.0-Profile259" />
      <frameworkAssembly assemblyName="System.Threading" targetFramework=".NETPortable0.0-Profile259" />
    </frameworkAssemblies>
  </metadata>

and this causes the error:

Adding package 'NReco.LambdaParser.1.0.10' to folder 'D:\Foo.App\packages'
Added package 'NReco.LambdaParser.1.0.10' to folder 'D:\Foo.App\packages'
Install failed. Rolling back...
Package 'NReco.LambdaParser.1.0.10' does not exist in project 'Foo.App.Android'
Removing package 'NReco.LambdaParser.1.0.10' from folder 'D:\Foo.App\packages'
Removed package 'NReco.LambdaParser.1.0.10' from folder 'D:\Foo.App\packages'
Executing nuget actions took 22,92 sec
Failed to add reference. The package 'NReco.LambdaParser' tried to add a framework reference to 'System.Collections' which was not found in the GAC. This is possibly a bug in the package. Please contact the package owners for assistance.
  Error HRESULT E_FAIL has been returned from a call to a COM component.

mine:

<dependencies>
      <group targetFramework=".NETStandard1.3">
        <dependency id="NETStandard.Library" version="1.6.0" exclude="Build,Analyzers" />
        <dependency id="System.Reflection.TypeExtensions" version="4.1.0" exclude="Build,Analyzers" />
      </group>
      <group targetFramework=".NETStandard2.0" />
    </dependencies>

See the large diff. Now I can install it fine:

Attempting to gather dependency information for package 'NReco.LambdaParser.1.0.10' with respect to project 'Client\Foo.App.Android', targeting 'MonoAndroid,Version=v9.0'
Gathering dependency information took 516,72 ms
Attempting to resolve dependencies for package 'NReco.LambdaParser.1.0.10' with DependencyBehavior 'Lowest'
Resolving dependency information took 0 ms
Resolving actions to install package 'NReco.LambdaParser.1.0.10'
Resolved actions to install package 'NReco.LambdaParser.1.0.10'
Retrieving package 'NReco.LambdaParser 1.0.10' from 'D:\_NuGet'.
Adding package 'NReco.LambdaParser.1.0.10' to folder 'D:\Foo.App\packages'
Added package 'NReco.LambdaParser.1.0.10' to folder 'D:\Foo.App\packages'
Added package 'NReco.LambdaParser.1.0.10' to 'packages.config'
Successfully installed 'NReco.LambdaParser 1.0.10' to Foo.App.Android
Executing nuget actions took 17,63 sec
VitaliyMF commented 4 years ago

@MagicAndre1981 what is wrong here? Nuget package and .nuspec are generated with official .NET tooling, all targets are valid; there was a bug in old tooling, and solution is switching from packages.config to .csproj.

I agree that old NETPortable targets are legacy, so I may exclude them and add, say, net45 target instead for legacy projects. Could you verify that this really will solve the issue you faced?

MagicAndre1981 commented 4 years ago

my issue is solved with my nugets which has the shorter nuspec. How do you build the nupkg? I used dotnet pack

VitaliyMF commented 4 years ago

that's because portable targets are commented in csproj, only netstandard1.3 and netstandard2.0 are included.

I've just published version 1.0.11 where portable targets are removed (also added net45 target that still might be needed for legacy .NET Framework projects). Hope this helps.

MagicAndre1981 commented 4 years ago

I've just published version 1.0.11 where portable targets are removed (also added net45 target that still might be needed for legacy .NET Framework projects). Hope this helps.

works fine.