mganss / HtmlSanitizer

Cleans HTML to avoid XSS attacks
MIT License
1.57k stars 199 forks source link

Unable to install nuget, tried to add a framework reference to System.Globalization error #129

Closed dannylgreen closed 7 years ago

dannylgreen commented 7 years ago

Hello,

I am getting the following error when trying to install the nuget package for version 4.0: HtmlSanitizer' tried to add a framework reference to 'System.Globalization' which was not found in the GAC. This is possibly a bug in the package. Please contact the package owners for assistance.

For now I have download the 3.4 version and that seems to have worked.

Thanks!

tiesont commented 7 years ago

I don't see this error when installing the package - what project type are you using?

mganss commented 7 years ago

I can't repro, either. Neither net45, net40, nor netcoreapp2.0. Which framework are you targeting?

dannylgreen commented 7 years ago

Hello,

I am targeting the net45 framework, and it is an Asp.Net MVC type of project. I tried installing AngelSharp first (which installed fine), but that didn't help. I just now tried to install it on a class library project (that is part of the same solution), but with the same result.

Here is the output from Package Manager (this was the class library project) if that helps:

Attempting to gather dependency information for package 'HtmlSanitizer.4.0.179' with respect to project 'Esurety.Core', targeting '.NETFramework,Version=v4.5' GET https://api.nuget.org/v3/registration3-gz/htmlsanitizer/index.json OK https://api.nuget.org/v3/registration3-gz/htmlsanitizer/index.json 53ms GET https://api.nuget.org/v3/registration3-gz/anglesharp/index.json OK https://api.nuget.org/v3/registration3-gz/anglesharp/index.json 121ms GET https://api.nuget.org/v3/registration3-gz/microsoft.bcl.async/index.json GET https://api.nuget.org/v3/registration3-gz/microsoft.bcl/index.json GET https://api.nuget.org/v3/registration3-gz/hyak.common/index.json GET https://api.nuget.org/v3/registration3-gz/microsoft.azure.common.dependencies/index.json GET https://api.nuget.org/v3/registration3-gz/microsoft.net.http/index.json GET https://api.nuget.org/v3/registration3-gz/newtonsoft.json/index.json GET https://api.nuget.org/v3/registration3-gz/microsoft.bcl.build/index.json GET https://api.nuget.org/v3/registration3-gz/microsoft.azure.common/index.json GET https://api.nuget.org/v3/registration3-gz/microsoft.rest.clientruntime/index.json GET https://api.nuget.org/v3/registration3-gz/microsoft.windowsazure.management.scheduler/index.json GET https://api.nuget.org/v3/registration3-gz/windowsazure.storage/index.json GET https://api.nuget.org/v3/registration3-gz/microsoft.data.odata/index.json GET https://api.nuget.org/v3/registration3-gz/microsoft.data.services.client/index.json GET https://api.nuget.org/v3/registration3-gz/microsoft.azure.keyvault.core/index.json GET https://api.nuget.org/v3/registration3-gz/microsoft.rest.clientruntime.azure/index.json GET https://api.nuget.org/v3/registration3-gz/system.spatial/index.json OK https://api.nuget.org/v3/registration3-gz/microsoft.bcl/index.json 124ms OK https://api.nuget.org/v3/registration3-gz/microsoft.bcl.async/index.json 124ms OK https://api.nuget.org/v3/registration3-gz/microsoft.azure.common/index.json 125ms OK https://api.nuget.org/v3/registration3-gz/newtonsoft.json/index.json 126ms GET https://api.nuget.org/v3/registration3-gz/microsoft.data.edm/index.json OK https://api.nuget.org/v3/registration3-gz/microsoft.azure.common.dependencies/index.json 129ms OK https://api.nuget.org/v3/registration3-gz/microsoft.bcl.build/index.json 128ms GET https://api.nuget.org/v3/registration3-gz/microsoft.azure.search/index.json OK https://api.nuget.org/v3/registration3-gz/hyak.common/index.json 134ms GET https://api.nuget.org/v3/registration3-gz/microsoft.spatial/index.json OK https://api.nuget.org/v3/registration3-gz/microsoft.net.http/index.json 138ms GET https://api.nuget.org/v3/registration3-gz/system.net.http/index.json GET https://api.nuget.org/v3/registration3-gz/system.xml.linq/index.json OK https://api.nuget.org/v3/registration3-gz/microsoft.data.odata/index.json 125ms OK https://api.nuget.org/v3/registration3-gz/microsoft.data.services.client/index.json 113ms OK https://api.nuget.org/v3/registration3-gz/microsoft.azure.keyvault.core/index.json 116ms OK https://api.nuget.org/v3/registration3-gz/microsoft.rest.clientruntime/index.json 138ms GET https://api.nuget.org/v3/registration3-gz/system.dynamic.runtime/index.json GET https://api.nuget.org/v3/registration3-gz/system.net.requests/index.json OK https://api.nuget.org/v3/registration3-gz/microsoft.windowsazure.management.scheduler/index.json 148ms OK https://api.nuget.org/v3/registration3-gz/windowsazure.storage/index.json 147ms GET https://api.nuget.org/v3/registration3-gz/system.componentmodel.eventbasedasync/index.json OK https://api.nuget.org/v3/registration3-gz/system.spatial/index.json 123ms GET https://api.nuget.org/v3/registration3-gz/system.linq.queryable/index.json OK https://api.nuget.org/v3/registration3-gz/microsoft.rest.clientruntime.azure/index.json 150ms GET https://api.nuget.org/v3/registration3-gz/system.runtime/index.json GET https://api.nuget.org/v3/registration3-gz/system.linq.expressions/index.json GET https://api.nuget.org/v3/registration3-gz/system.reflection/index.json OK https://api.nuget.org/v3/registration3-gz/microsoft.spatial/index.json 116ms OK https://api.nuget.org/v3/registration3-gz/microsoft.data.edm/index.json 139ms GET https://api.nuget.org/v3/registration3-gz/system.objectmodel/index.json GET https://api.nuget.org/v3/registration3-gz/system.net.webheadercollection/index.json OK https://api.nuget.org/v3/registration3-gz/microsoft.azure.search/index.json 144ms OK https://api.nuget.org/v3/registration3-gz/system.xml.linq/index.json 123ms GET https://api.nuget.org/v3/registration3-gz/system.io/index.json OK https://api.nuget.org/v3/registration3-gz/system.net.http/index.json 144ms GET https://api.nuget.org/v3/registration3-gz/system.threading.tasks/index.json OK https://api.nuget.org/v3/registration3-gz/system.dynamic.runtime/index.json 128ms OK https://api.nuget.org/v3/registration3-gz/system.net.requests/index.json 129ms GET https://api.nuget.org/v3/registration3-gz/system.net.primitives/index.json OK https://api.nuget.org/v3/registration3-gz/system.componentmodel.eventbasedasync/index.json 127ms OK https://api.nuget.org/v3/registration3-gz/system.linq.queryable/index.json 131ms GET https://api.nuget.org/v3/registration3-gz/system.resources.resourcemanager/index.json OK https://api.nuget.org/v3/registration3-gz/system.runtime/index.json 131ms GET https://api.nuget.org/v3/registration3-gz/system.collections/index.json GET https://api.nuget.org/v3/registration3-gz/system.diagnostics.debug/index.json GET https://api.nuget.org/v3/registration3-gz/system.threading/index.json OK https://api.nuget.org/v3/registration3-gz/system.linq.expressions/index.json 132ms OK https://api.nuget.org/v3/registration3-gz/system.reflection/index.json 118ms GET https://api.nuget.org/v3/registration3-gz/system.reflection.primitives/index.json GET https://api.nuget.org/v3/registration3-gz/system.collections.specialized/index.json OK https://api.nuget.org/v3/registration3-gz/system.objectmodel/index.json 120ms GET https://api.nuget.org/v3/registration3-gz/system.collections.nongeneric/index.json OK https://api.nuget.org/v3/registration3-gz/system.net.webheadercollection/index.json 128ms GET https://api.nuget.org/v3/registration3-gz/system.text.encoding/index.json GET https://api.nuget.org/v3/registration3-gz/system.runtime.handles/index.json OK https://api.nuget.org/v3/registration3-gz/system.io/index.json 134ms GET https://api.nuget.org/v3/registration3-gz/system.linq/index.json OK https://api.nuget.org/v3/registration3-gz/system.threading.tasks/index.json 121ms GET https://api.nuget.org/v3/registration3-gz/system.globalization.extensions/index.json GET https://api.nuget.org/v3/registration3-gz/system.runtime.extensions/index.json GET https://api.nuget.org/v3/registration3-gz/system.globalization/index.json OK https://api.nuget.org/v3/registration3-gz/system.net.primitives/index.json 136ms GET https://api.nuget.org/v3/registration3-gz/system.threading.tasks.unofficial/index.json OK https://api.nuget.org/v3/registration3-gz/system.linq/index.json 43ms OK https://api.nuget.org/v3/registration3-gz/system.resources.resourcemanager/index.json 123ms GET https://api.nuget.org/v3/registration3-gz/system.runtime.interopservices/index.json OK https://api.nuget.org/v3/registration3-gz/system.diagnostics.debug/index.json 121ms OK https://api.nuget.org/v3/registration3-gz/system.threading/index.json 116ms OK https://api.nuget.org/v3/registration3-gz/system.collections/index.json 125ms OK https://api.nuget.org/v3/registration3-gz/system.runtime.extensions/index.json 44ms OK https://api.nuget.org/v3/registration3-gz/system.reflection.primitives/index.json 115ms OK https://api.nuget.org/v3/registration3-gz/system.collections.nongeneric/index.json 117ms OK https://api.nuget.org/v3/registration3-gz/system.collections.specialized/index.json 122ms OK https://api.nuget.org/v3/registration3-gz/system.runtime.handles/index.json 112ms OK https://api.nuget.org/v3/registration3-gz/system.text.encoding/index.json 125ms OK https://api.nuget.org/v3/registration3-gz/system.globalization.extensions/index.json 121ms OK https://api.nuget.org/v3/registration3-gz/system.globalization/index.json 113ms OK https://api.nuget.org/v3/registration3-gz/system.threading.tasks.unofficial/index.json 121ms OK https://api.nuget.org/v3/registration3-gz/system.runtime.interopservices/index.json 124ms Total number of results gathered : 193 Gathering dependency information took 884.88 ms Summary of time taken to gather dependencies per source : C:\Esurety6\Debug\Branches\Working\packages - 1.52 sec C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\ - 101.69 ms https://api.nuget.org/v3/index.json - 6.76 sec Attempting to resolve dependencies for package 'HtmlSanitizer.4.0.179' with DependencyBehavior 'Lowest' Resolving dependency information took 0 ms Resolving actions to install package 'HtmlSanitizer.4.0.179' Resolved actions to install package 'HtmlSanitizer.4.0.179' Found package 'AngleSharp 0.9.9' in 'C:\Esurety6\Debug\Branches\Working\packages'. Retrieving package 'HtmlSanitizer 4.0.179' from 'nuget.org'. For adding package 'AngleSharp.0.9.9' to project 'Esurety.Core' that targets 'net45'. For adding package 'AngleSharp.0.9.9' to project 'Esurety.Core' that targets 'net45'. Package 'AngleSharp.0.9.9' already exists in folder 'C:\Esurety6\Debug\Branches\Working\packages' Added reference 'AngleSharp' to project 'Esurety.Core'. Added package 'AngleSharp.0.9.9' to 'packages.config' Successfully installed 'AngleSharp 0.9.9' to Esurety.Core For adding package 'HtmlSanitizer.4.0.179' to project 'Esurety.Core' that targets 'net45'. For adding package 'HtmlSanitizer.4.0.179' to project 'Esurety.Core' that targets 'net45'. Adding package 'HtmlSanitizer.4.0.179' to folder 'C:\Esurety6\Debug\Branches\Working\packages' Added package 'HtmlSanitizer.4.0.179' to folder 'C:\Esurety6\Debug\Branches\Working\packages' Added reference 'HtmlSanitizer' to project 'Esurety.Core'. Install failed. Rolling back... Package 'HtmlSanitizer.4.0.179 : AngleSharp [0.9.9, 0.9.9]' does not exist in project 'Esurety.Core' Removed package 'AngleSharp.0.9.9' from 'packages.config' Removed reference 'AngleSharp.dll' from project 'Esurety.Core' Removing package 'HtmlSanitizer.4.0.179 : AngleSharp [0.9.9, 0.9.9]' from folder 'C:\Esurety6\Debug\Branches\Working\packages' Removed folder 'C:\Esurety6\Debug\Branches\Working\packages\HtmlSanitizer.4.0.179\lib\netstandard1.3'. Removed folder 'C:\Esurety6\Debug\Branches\Working\packages\HtmlSanitizer.4.0.179\lib\net40'. Removed folder 'C:\Esurety6\Debug\Branches\Working\packages\HtmlSanitizer.4.0.179\lib\net45'. Removed folder 'C:\Esurety6\Debug\Branches\Working\packages\HtmlSanitizer.4.0.179\lib'. Removed file 'HtmlSanitizer.4.0.179.nupkg' from folder 'C:\Esurety6\Debug\Branches\Working\packages\HtmlSanitizer.4.0.179'. Removed folder 'C:\Esurety6\Debug\Branches\Working\packages\HtmlSanitizer.4.0.179'. Removed package 'HtmlSanitizer.4.0.179 : AngleSharp [0.9.9, 0.9.9]' from folder 'C:\Esurety6\Debug\Branches\Working\packages' Executing nuget actions took 2.16 sec Failed to add reference. The package 'HtmlSanitizer' tried to add a framework reference to 'System.Globalization' which was not found in the GAC. This is possibly a bug in the package. Please contact the package owners for assistance. ========== Finished ========== Time Elapsed: 00:00:04.8478939

mganss commented 7 years ago

I have a feeling this might be related to NuGet/Home#2193. Which version of Visual Studio and NuGet are you using?

dannylgreen commented 7 years ago

I am using Visual Studio 2015 with Nuget Pacage manager 3.5. When I look at tools/extensions and updates, there doesn't appear to be an update for Nuget, is that the latest version?

mganss commented 7 years ago

Now I can repro. There is NuGet 3.6 for VS 2015 but that didn't help, either.

So I simply removed the references to System.IO, System.Globalization, and System.Runtime for net45. Builds 🆗 There doesn't seem to be an equivalent in csproj to the workaround mentioned in NuGet/Home#2193 ({ "type": "build" }) so I figured removing the references is the way to go 🤷‍♂️

dannylgreen commented 7 years ago

That has done the trick! Thank you.