You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With default settings (-DependencyVersion Lowest), NuGet downloads AngleSharp 1.0.0. This leads to problems in .Net Framework and .Net (Core), becauce AngleSharp.Css requires AngleSharp 1.1.0, not 1.0.0.
With -DependencyVersion Lowest, NuGet downloads AngleSharp 1.2.0-beta.410. This is not problem in .Net (Core), as it seems to automatically use the newer release. On .Net Framework, this leads to the following error: Could not load file or assembly 'AngleSharp, Version=1.1.0.0, Culture=neutral, PublicKeyToken=e83494dcdc6d31ea' or one of its dependencies. The system cannot find the file specified.
Extract all net461 DLLs and place them in the same folder
Import AngleSharp.Css.dll in .Net Framework,not in .Net (Core) System.Reflection.Assembly.LoadFrom("path-to-anglesharp.css.dll") or in PowerShell 5: import-module -Path "path-to-anglesharp.css.dll"
As NuGet download AngleSharp 1.0.0 or 1.2.*, AngleSharp.Css can not load version 1.1.0, resulting in the error: Could not load file or assembly 'AngleSharp, Version=1.1.0.0, Culture=neutral, PublicKeyToken=e83494dcdc6d31ea' or one of its dependencies. The system cannot find the file specified.
Expected Behavior
The NuGet package is configured to download the correct version of the AngleSharp dependency.
Actual Behavior
The NuGet package seems not to be configured to download the correct version of the AngleSharp dependency, and AngleSharp.Css on .Net Framework (not .Net (Core)) is bound to only use AngleSharp 1.1.0.
I don't think this should be the way. I use both together (1.0.0 and 1.0.0 beta). Sure you are not having a bad config (app config that redirects)? There should not be a binary dependency on a specific version.
The NuGet package is configured to download the correct version of the AngleSharp dependency.
This is wrong. It should work as a peer dependency, where in failure / absence nuget decides something - but you can override it by explicitly installing a version in the provided range. The range is intentional and will stay.
Reproducing downloading the wrong AngleSharp.dll version with a C# project:
AngleSharp.Css-test.cs
using System;
using AngleSharp;
using AngleSharp.Css;
using AngleSharp.Css.Dom;
using AngleSharp.Css.Parser;
using AngleSharp.Dom;
using AngleSharp.Html;
using AngleSharp.Html.Dom;
using AngleSharp.Html.Parser;
public class Program
{
public static void Main()
{
var ctx = BrowsingContext.New(Configuration.Default.WithCss());
var htmlParser = ctx.GetService<IHtmlParser>();
var doc = htmlParser.ParseDocument("<html><body><div>Div text <span>sp<em>an te</em>xt</span></div><p>Paragraph<p>Another paragraph</body></html>");
Console.WriteLine(doc.Body.GetInnerText());
}
}
dotnet restore runs without error or warnings, but download AngleSharp 1.0.0 because of the NuGet file. Then, dotnet build fails because AngleSharp.Css references AngleSharp 1.1.0:
CSC : error CS1705: Assembly 'AngleSharp.Css' with identity 'AngleSharp.Css, Version=1.0.0.0, Culture=neutral, PublicKeyToken=
e83494dcdc6d31ea' uses 'AngleSharp, Version=1.1.0.0, Culture=neutral, PublicKeyToken=e83494dcdc6d31ea' which has a higher vers
ion than referenced assembly 'AngleSharp' with identity 'AngleSharp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=e83494dc
dc6d31ea' [C:\dev\AngleSharp.Css-Test\AngleSharp.Css-Test.csproj::TargetFramework=net461]
Let's add <PackageReference Include="AngleSharp" Version="1.1.0" /> to the csproj file:
Build succeeded.
It seems that the lower version bound for AngleSharp in the nuspec file of AngleSharp.Css is set too low (1.0.0 should be 1.1.0)
Prerequisites
AngleSharp.Xml
for Xml support)Description
AngleSharp.Css 1.0.0-beta.139
Nuget downloads the wrong AngleSharp dependency, likely because of the following differing configurations:
<dependency id="AngleSharp" version="[1.0.0, 2.0.0)" />
<PackageReference Include="AngleSharp" Version="1.1.0" />
With default settings (
-DependencyVersion Lowest
), NuGet downloads AngleSharp 1.0.0. This leads to problems in .Net Framework and .Net (Core), becauce AngleSharp.Css requires AngleSharp 1.1.0, not 1.0.0.With
-DependencyVersion Lowest
, NuGet downloads AngleSharp 1.2.0-beta.410. This is not problem in .Net (Core), as it seems to automatically use the newer release. On .Net Framework, this leads to the following error:Could not load file or assembly 'AngleSharp, Version=1.1.0.0, Culture=neutral, PublicKeyToken=e83494dcdc6d31ea' or one of its dependencies. The system cannot find the file specified.
Steps to Reproduce
nuget.exe install AngleSharp.Css -Framework net461 -Version "1.0.0-beta.139" -OutputDirectory ".\AngleSharp.Css_with-deps_net461" -NoHttpCache -DirectDownload -Verbosity quiet -DependencyVersion lowest
or
nuget.exe install AngleSharp.Css -Framework net461 -Version "1.0.0-beta.139" -OutputDirectory ".\AngleSharp.Css_with-deps_net461" -NoHttpCache -DirectDownload -Verbosity quiet -DependencyVersion highest
System.Reflection.Assembly.LoadFrom("path-to-anglesharp.css.dll")
or in PowerShell 5:
import-module -Path "path-to-anglesharp.css.dll"
Could not load file or assembly 'AngleSharp, Version=1.1.0.0, Culture=neutral, PublicKeyToken=e83494dcdc6d31ea' or one of its dependencies. The system cannot find the file specified.
Expected Behavior
The NuGet package is configured to download the correct version of the AngleSharp dependency.
Actual Behavior
The NuGet package seems not to be configured to download the correct version of the AngleSharp dependency, and AngleSharp.Css on .Net Framework (not .Net (Core)) is bound to only use AngleSharp 1.1.0.
Possible Solution / Known Workarounds
Adopt the nuspec file, and maybe also a binding redirect (dotnet/announcements#31).
The text was updated successfully, but these errors were encountered: