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

NuGet package does not work in most configurations #43

Closed
rishavs opened this issue Feb 21, 2020 · 20 comments · Fixed by #51
Closed

NuGet package does not work in most configurations #43

rishavs opened this issue Feb 21, 2020 · 20 comments · Fixed by #51
Assignees
Labels
bug Something isn't working enhancement New feature or request help wanted Extra attention is needed needs testing A bug or a fix to a bug that needs testing nuget Issue with the nuget package

Comments

@rishavs
Copy link

rishavs commented Feb 21, 2020

I am trying to use Raylib-cs with fsharp on dotnet 3.1.

I am able to install the lib on a console app using dotnet add Raylib-cs
But now in my code doing
open Raylib
gives me the error The namespace or module 'Raylib' is not defined.

@chrisdill
Copy link
Owner

chrisdill commented Feb 21, 2020

I have not used fsharp so I cannot help there. There are bindings for fsharp here although I think it would need to be updated.

@rishavs
Copy link
Author

rishavs commented Feb 22, 2020

I quickly testing this in c# and I am getting the same issue.

I started by creating a new C# console app and then added Raylib-cs to it. However in the code, it is not recognising raylib-cs

PS C:\Users\risharan\DevSpace\fsharp\test> dotnet new console                                                                                                                                                                                         The template "Console Application" was created successfully.

Processing post-creation actions...
Running 'dotnet restore' on C:\Users\risharan\DevSpace\fsharp\test\test.csproj...
  Restore completed in 119.24 ms for C:\Users\risharan\DevSpace\fsharp\test\test.csproj.

Restore succeeded.

PS C:\Users\risharan\DevSpace\fsharp\test> dotnet add package Raylib-cs                                                                                                                                                                                 Writing C:\Users\risharan\AppData\Local\Temp\tmpD0D6.tmp
info : Adding PackageReference for package 'Raylib-cs' into project 'C:\Users\risharan\DevSpace\fsharp\test\test.csproj'.
info : Restoring packages for C:\Users\risharan\DevSpace\fsharp\test\test.csproj...
info :   GET https://api.nuget.org/v3-flatcontainer/raylib-cs/index.json
info :   OK https://api.nuget.org/v3-flatcontainer/raylib-cs/index.json 908ms
info : Package 'Raylib-cs' is compatible with all the specified frameworks in project 'C:\Users\risharan\DevSpace\fsharp\test\test.csproj'.
info : PackageReference for package 'Raylib-cs' version '1.4.0' added to file 'C:\Users\risharan\DevSpace\fsharp\test\test.csproj'.
info : Committing restore...
info : Generating MSBuild file C:\Users\risharan\DevSpace\fsharp\test\obj\test.csproj.nuget.g.targets.
info : Writing assets file to disk. Path: C:\Users\risharan\DevSpace\fsharp\test\obj\project.assets.json
log  : Restore completed in 2.55 sec for C:\Users\risharan\DevSpace\fsharp\test\test.csproj.

image

@chrisdill
Copy link
Owner

You should copy the bindings into your project directly instead of adding via the package. The package is unlisted and out of date. I had issues getting it to work. I may revisit it although I have been making breaking changes on the dev branch and it is not a priority at this time.

@rishavs
Copy link
Author

rishavs commented Feb 22, 2020

Thanks. That makes sense.
I have edited the title of the issue so that it refers to updating the lib on dotnet package repo.

@rishavs rishavs changed the title unable to import lib "dotnet add" package is out of date and unlisted Feb 22, 2020
@chrisdill
Copy link
Owner

The point of having it be a package is to make it easy for people to install and use so I would want it to include the native libraries too although I am not sure how it should be done. The dev branch is nearly ready to merge into master so I will work on that and take another look at this after.

@rishavs
Copy link
Author

rishavs commented Apr 9, 2020

Hey Chris, I know you will have 3.0 as a priority but have you a timeline planned for this fix?

@chrisdill
Copy link
Owner

I am not sure. There are different ways I could package it and I have not found a clear guide for nuget packages that use native libraries. I have tried dotnet pack and that produces a package for Raylib-cs.dll but I am stuck on figuring out how to add the native libraries so they are included and also are copied to the output directory based on the platform being used.

@chrisdill
Copy link
Owner

chrisdill commented Apr 9, 2020

Update. Taking another look to see if there was something I missed. Looks like there is a open issue about using native libraries in nuget packages here.

@chrisdill chrisdill mentioned this issue Apr 19, 2020
@chrisdill chrisdill self-assigned this Apr 19, 2020
@chrisdill chrisdill added 3.0 release enhancement New feature or request help wanted Extra attention is needed labels Apr 19, 2020
@9ParsonsB
Copy link
Collaborator

Good news! We have just released a NuGet package targeting netstd2.0 (which should support Framework 4.7.2) & Core 3.1

So far we have tested it with the examples and with Github Actions, but please feel free to open new issues if there are problems with the package.

https://www.nuget.org/packages/Raylib-cs
dotnet add package Raylib-cs

@9ParsonsB 9ParsonsB added nuget Issue with the nuget package and removed help wanted Extra attention is needed labels May 2, 2020
@9ParsonsB
Copy link
Collaborator

9ParsonsB commented May 3, 2020

Seems like the current solution does not work for netfx under certain conditions. Refer to #3 of this NuGet issue and this comment

Current options seem to be:

  1. Add a target file (which means writing a target for each arch & platform we want to support)
  2. Rename the runtime folder to libs - this is documented to cause issues/warnings with MSBuild and I'd rather not do something hacky just for netfx

@9ParsonsB 9ParsonsB reopened this May 3, 2020
@9ParsonsB 9ParsonsB changed the title "dotnet add" package is out of date and unlisted NuGet package is out of date and unlisted May 3, 2020
@chrisdill
Copy link
Owner

@9ParsonsB I say we should look into the target files. I agree that renaming the folder to libs is hacky and sounds like it will cause more problems. The nuget package should be able to be built using dotnet pack with no other steps needed. If netfx can not work with that then we won't be able to support it.

@chrisdill
Copy link
Owner

To make it clear on the runtimes we are currently supporting. The libraries we include for these runtimes are taken from the official raylib release:

  • linux-x64
  • linux-x86
  • osx-x64
  • win-x64
  • win-x86

It is possible that linux-x86 and win-x86 support is dropped in the future as I do not use them myself and there is a extra cost in having to support/test them. Currently they are the least tested part because of this.

@9ParsonsB
Copy link
Collaborator

9ParsonsB commented May 5, 2020

After some more investigations, I have another approach for packaging native libraries after reviewing this: NuGet/Home#8623 (now using Content rather than Reference in the .targets file)

I will push a new package version now (v3.1.3) and hope someone can test it for me. (join us on discord!)

@9ParsonsB 9ParsonsB added bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed labels May 5, 2020
@Shadowblitz16
Copy link

Shadowblitz16 commented May 10, 2020

does the current nuget package use 64 bit binaries? I keep getting this..
image
I downloaded the latest raylib native library and both 32 and 64 bit doesn't seem to work

@chrisdill
Copy link
Owner

@Shadowblitz16 The latest nuget package currently includes the x64 and x86 libraries. Check that you are using the latest nuget release. You should not need to download the latest raylib library yourself to use the nuget package.

@horseyhorsey
Copy link

I get the incorrect format when trying to run win-x86, x64 is fine though.

I was running from fork before but have just started to use the nuget.

@Shadowblitz16
Copy link

@chrisdill it doesn't work
image
this is a blank console app targeted at .net framework 4.7.2

@horseyhorsey
Copy link

Set to x64.

Please set x86 and report that doesn't work.

@Shadowblitz16
Copy link

nope that doesn't work either
image

@9ParsonsB 9ParsonsB changed the title NuGet package is out of date and unlisted NuGet package does not work in most configurations Jul 21, 2020
@9ParsonsB
Copy link
Collaborator

@Shadowblitz16 Are you targeting .Net Framework or .Net Core?

.Net Framework doesn't handle cross-platform native libraries that well - in this case you will need to copy the native raylib dll into your output directory.

In any case, you will probably have better luck by only building x64. I know AnyCPU is broken. not sure about x86.

I am currently testing a fix for this (see pre-release NuGet packages).

@9ParsonsB 9ParsonsB self-assigned this Jul 21, 2020
@chrisdill chrisdill mentioned this issue Jul 21, 2020
@9ParsonsB 9ParsonsB added needs testing A bug or a fix to a bug that needs testing and removed good first issue Good for newcomers labels Jul 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request help wanted Extra attention is needed needs testing A bug or a fix to a bug that needs testing nuget Issue with the nuget package
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants