FabianFG / CUE4Parse

Apache License 2.0
279 stars 114 forks source link

Native assembly in NuGet /lib folder causing dotnet build warning #156

Open hallipr opened 3 months ago

hallipr commented 3 months ago

This appears to be cuased by a native assembly being in the /lib folder of the CUE4Parse 1.1.1 Nuget package.

see https://learn.microsoft.com/en-us/nuget/create-packages/native-files-in-net-packages#compile-assets and https://stackoverflow.com/a/48123691/596349

Repro steps:

In an empty folder, when I

dotnet new classlib && dotnet build

I get

The template "Class Library" was created successfully.

Processing post-creation actions...
Restoring D:\repos\test\test.csproj:
  Determining projects to restore...
  Restored D:\repos\test\test.csproj (in 62 ms).
Restore succeeded.

  Determining projects to restore...
  All projects are up-to-date for restore.
  test -> D:\repos\test\bin\Debug\net8.0\test.dll

Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:00.90

when I:

dotnet add package CUE4Parse && dotnet build

I get:

  Determining projects to restore...

...

info : Package 'CUE4Parse' is compatible with all the specified frameworks in project 'D:\repos\test\test.csproj'.
info : PackageReference for package 'CUE4Parse' version '1.1.1' added to file 'D:\repos\test\test.csproj'.
info : Writing assets file to disk. Path: D:\repos\test\obj\project.assets.json
log  : Restored D:\repos\test\test.csproj (in 344 ms).
  Determining projects to restore...
  All projects are up-to-date for restore.
C:\Program Files\dotnet\sdk\8.0.304\Microsoft.Common.CurrentVersion.targets(2401,5): warning MSB3246: Resolved file has a bad image, no metadata, or is otherwise inaccessible. PE i
mage does not have metadata. PE image does not have metadata. [D:\repos\test\test.csproj]
  test -> D:\repos\test\bin\Debug\net8.0\test.dll

Build succeeded.

C:\Program Files\dotnet\sdk\8.0.304\Microsoft.Common.CurrentVersion.targets(2401,5): warning MSB3246: Resolved file has a bad image, no metadata, or is otherwise inaccessible. PE i 
mage does not have metadata. PE image does not have metadata. [D:\repos\test\test.csproj]
    1 Warning(s)
    0 Error(s)

Time Elapsed 00:00:01.03
hallipr commented 1 month ago

To be clear, I understand CUE4Parse ships with the native assembly, it's just not in the correct folder in the nuget package. Native assemblies should be in /runtimes/{rid}/native/ not /lib/