cube.pdf icon indicating copy to clipboard operation
cube.pdf copied to clipboard

Unable to install Cube.Native.Pdfium.Lite.117.0.593 in .NET Framework projects

Open frleong opened this issue 2 years ago • 7 comments

Hello,

When I tried to install via nuget, I got an error that it cannot be installed in .NET framework 4.8 project. Could it be fixed? Thanks!

Install-Package : Could not install package 'Cube.Native.Pdfium.Lite 117.0.5938'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.8', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.

frleong avatar Oct 19 '23 02:10 frleong

Cube.Native.Pdfium.Lite is a package for pdfium.dll (an unmanaged DLL), so it is independent of .NET Framework version. This error is often resolved by updating the version of NuGet itself, so please check.

clown avatar Oct 19 '23 06:10 clown

Hi, I think I have already the latest version of NuGet (Package Manager Console Host Version 6.7.0.127). I only get this error for projects targeted for .Net Framework 4.8. If I create a new project that targets .Net 6.0, I get no errors when installing. Thanks!

frleong avatar Oct 19 '23 09:10 frleong

Is there any metadata error in Nuget repository?

frleong avatar Oct 19 '23 09:10 frleong

Thanks for your information. I will investigate the issue.

clown avatar Oct 20 '23 02:10 clown

I tried several things but could not reproduce it here. If you create the lib/net48 folder in the deployed NuGet package (cube.native.pdfium.lite/117.0.5938 folder) and put a dummy file in it, does that fix the error?

clown avatar Nov 07 '23 04:11 clown

Thank you. I am not too sure how to put the lib/net48 folder in the Nuget package. I still can't install cube.native.pdfium.lite via NuGet Package Manager in Visual Studio 2022, when I create a new project that targets .NET framework 4.8. What I have done was to create a dummy .NET 6.0 project, install the package and copied back the contents to the .NET 4.8 framework.

frleong avatar Nov 08 '23 09:11 frleong

I found the cause. This error seems to occur when using the old CSPROJ format.

We will fix the issue in the next release (cube.native.pdfium.lite 120.0), but to avoid the error, please try either of the following

1. Use the new CSPROJ format (recommended)

For example, after creating a .NET 6.0 target project using Visual Studio, open the *.csproj file in a text editor and rewrite the TargetFramework from net6.0-windows to net48. (you may want to add <LangVersion>latest</LangVersion> as well).

2. Add lib/net48 to the extracted NuGet package folder

By default, NuGet packages are deployed in the C:\Users\<YourName>\.nuget\packages folder. Go to the cube.native.pdfium.117.0.593 folder in it, create the lib/net48 folder, and also create a file of whatever you want. (e.g., hack.txt)

Note that if you continue to use the old CSPROJ format in this way, the build will complete successfully, but the unmanaged DLL (pdfium.dll) will not be copied automatically. Therefore, you will need to manually copy the dll from the runtimes/win-x64 or runtimes/win-x86 folder after the build.

clown avatar Nov 10 '23 03:11 clown