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

dotnet publish doesn't copy proper native/xenko dependencies #331

Closed
xen2 opened this issue Jan 19, 2019 · 11 comments
Closed

dotnet publish doesn't copy proper native/xenko dependencies #331

xen2 opened this issue Jan 19, 2019 · 11 comments
Labels
bug

Comments

@xen2
Copy link
Member

@xen2 xen2 commented Jan 19, 2019

Release Type: GitHub

Version: master

Describe the bug
Running dotnet publish does not properly copy dependencies.
It seems dotnet publish uses slightly different targets than what's done for standard build.
(note: heard it might be unified in .NET Core 3.0)

To Reproduce
Steps to reproduce the behavior:

  1. Create a new game with Linux or macOS
  2. Build Linux or macOS (might be optional)
  3. Run dotnet publish

Expected behavior
Bin\Linux\Debug\linux-x64\publish should contain all the native files (that are pulled by .ssdeps) just like in Bin\Linux\Debug\linux-x64 but it doesnt.

The fix likely needs to be done in https://github.com/xenko3d/xenko/blob/master/sources/core/Xenko.Core/build/Xenko.Core.targets

@xen2 xen2 added the bug label Jan 19, 2019
@xen2

This comment has been minimized.

Copy link
Member Author

@xen2 xen2 commented Jan 19, 2019

I think we need a target with AfterTargets="Publish", but not so sure on that.

@jazzay

This comment has been minimized.

Copy link

@jazzay jazzay commented Jan 19, 2019

@xen2 for the build step (optional) are you doing that via dotnet build? And if so how would you specify for macOS on cmd line?

@xen2

This comment has been minimized.

Copy link
Member Author

@xen2 xen2 commented Jan 19, 2019

I did it with VS.
Didn't try dotnet build, does it work?

@jazzay

This comment has been minimized.

Copy link

@jazzay jazzay commented Jan 19, 2019

Not sure, did not try yet. Probably publish is similar to dotnet build, so discrepancy might be between VS and dotnet?

@xen2

This comment has been minimized.

Copy link
Member Author

@xen2 xen2 commented Jan 19, 2019

I think dotnet build is OK and discrepency is between dotnet build and dotnet publish, but please double check.

@jazzay

This comment has been minimized.

Copy link

@jazzay jazzay commented Jan 19, 2019

Switching a Test Game's Windows project to netcoreapp2.1 has build output problems. You can not even run it from VS2017. Exception file not found for Xenko.Graphics, among others.

I find the Graphics dll for example here:
C:\Users\jazza.nuget\packages\xenko.graphics\3.1.0.1-beta01\runtimes\win-d3d11\lib\netstandard2.0
Which seems correct?

I tried forcing the Game project runtime to this to see if it would pick it up
win-x64

Excerpt from VS output panel:

'TestMacPublishBug.Windows.exe' (CoreCLR: clrhost): Loaded 'C:\Users\jazza\.nuget\packages\runtime.win-x64.microsoft.netcore.app\2.1.6\runtimes\win-x64\lib\netcoreapp2.1\System.Runtime.Extensions.dll'. Cannot find or open the PDB file.
'TestMacPublishBug.Windows.exe' (CoreCLR: clrhost): Loaded 'C:\Users\jazza\.nuget\packages\xenko.engine\3.1.0.1-beta01\runtimes\win\lib\netstandard2.0\Xenko.Engine.dll'. Symbols loaded.
'TestMacPublishBug.Windows.exe' (CoreCLR: clrhost): Loaded 'C:\Users\jazza\.nuget\packages\xenko.shaders\3.1.0.1-beta01\lib\netstandard2.0\Xenko.Shaders.dll'. Symbols loaded.
'TestMacPublishBug.Windows.exe' (CoreCLR: clrhost): Loaded 'C:\Users\jazza\.nuget\packages\xenko\3.1.0.1-beta01\lib\netstandard2.0\Xenko.dll'. Symbols loaded.
'TestMacPublishBug.Windows.exe' (CoreCLR: clrhost): Loaded 'C:\Users\jazza\.nuget\packages\xenko.core.mathematics\3.1.0.1-beta01\lib\netstandard2.0\Xenko.Core.Mathematics.dll'. Symbols loaded.
'TestMacPublishBug.Windows.exe' (CoreCLR: clrhost): Loaded 'C:\Users\jazza\.nuget\packages\xenko.core.serialization\3.1.0.1-beta01\lib\netstandard2.0\Xenko.Core.Serialization.dll'. Symbols loaded.
Exception thrown: 'System.IO.FileNotFoundException' in TestMacPublishBug.Windows.dll
Could not load file or assembly 'Xenko.Graphics, Version=3.1.0.1, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.

Pure NetStandard libaries are found and loaded fine, run time specific not.

Perhaps we should fix these issues with Windows-NetCore prior to attempting publish on any other platform as it's likely a sign of dependency/run time config issues?

@jazzay

This comment has been minimized.

Copy link

@jazzay jazzay commented Jan 19, 2019

Explicitly adding this reference to the Windows project fixes the problems above:

    <PackageReference Include="Xenko" Version="3.1.0.1-beta01" PrivateAssets="contentfiles;analyzers" />

Which makes sense I guess since that Project is where the runtime.json file is. And now I see that the MacOS project contains that already.

@jazzay

This comment has been minimized.

Copy link

@jazzay jazzay commented Jan 19, 2019

If I try to run a Windows published build from cmd line i get this:

D:\dev\gamedev\Xenko.TestProjects\TestMacPublishBug\Bin\Windows\Release\win-x64\publish
λ TestMacPublishBug.Windows.exe

Unhandled Exception: System.TypeInitializationException: The type initializer for '<Module>' threw an exception. ---> System.TypeInitializationException: The type initializer for '<Module>' threw an exception. ---> System.TypeInitializationException: The type initializer for 'Xenko.Rendering.BackgroundCubemapShaderKeys' threw an exception. ---> System.TypeInitializationException: The type initializer for '<Module>' threw an exception. ---> System.TypeInitializationException: The type initializer for '<Module>' threw an exception. ---> System.TypeInitializationException: The type initializer for 'Xenko.Core.Native.NativeInvoke' threw an exception. ---> System.InvalidOperationException: Could not load native library libcore.dll from path [D:\dev\gamedev\Xenko.TestProjects\TestMacPublishBug\Bin\Windows\Release\win-x64\publish\x64\libcore.dll] using CPU architecture x64.
   at Xenko.Core.NativeLibrary.PreloadLibrary(String libraryName, Type owner)
   at Xenko.Core.Native.NativeInvoke..cctor()

Native dependency libcore among others are missing, and there is no child x64 directory.

@jazzay

This comment has been minimized.

Copy link

@jazzay jazzay commented Jan 19, 2019

Adding this fixes the missing native libs as you suggested:

<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>

However when I run the published exe I now get a black screen. Looking inside the data/db child folder there are no actual files located there.

@jazzay

This comment has been minimized.

Copy link

@jazzay jazzay commented Jan 19, 2019

With these same changes applied to the macOS project and manually copying the data folder to publish (for now) I can successfully run a simple test game on my MacBookPro. Note however that it takes forever (7 mins) to launch. Looks like most of that time is compiling shaders.

Now I will see how I can get the data folder to properly publish automatically.

@jazzay

This comment has been minimized.

Copy link

@jazzay jazzay commented Jan 20, 2019

I have a solution for this will submit a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.