Closed cwfitzgerald closed 7 months ago
I am experimenting with Unity on Linux. The build at https://github.com/KhronosGroup/UnityGLTF/releases/download/v1.0.1/UnityGLTF.unitypackage seems to work, at least for importing gltf.
For building, I made minor progress by using the MS dotnet msbuild
available here: https://dotnet.microsoft.com/learn/dotnet/hello-world-tutorial/install
The first issue was a case sensitivity in UnityGLTF-dll.csproj: https://github.com/KhronosGroup/UnityGLTF/blob/master/UnityGLTF/UnityGLTF-dll.csproj#L80
<Import Project="$(MSBuildToolsPath)\Microsoft.CSHARP.Targets" />
needs to read
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
as it is installed by the MS packages with this case.
But secondly, then I get this error:
Microsoft (R) Build Engine version 16.0.450+ga8dc7f1d34 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
/usr/share/dotnet/sdk/2.2.203/Microsoft.Common.CurrentVersion.targets(1183,5): error MSB3644: The reference assemblies for framework ".NETFramework,Version=v4.7.1" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend. [~/Downloads/UnityGLTF-master/UnityGLTF/UnityGLTF-dll.csproj]
and I could not figure how to install the v.4.7.1 reference assemblies, after some googling. nuget does not seem to have them.
Any hints appreciated.
Ok, I found that the latest mono has the assemblies: https://www.mono-project.com/download/stable/ mono needs to be installed from the mono repo because the debian version is too old.
mono comes with its own msbuild which seems to know about the mono installed components.
Since the UWP Tests and the Tests complained and did not seem critical I removed them with:
$ dotnet sln GLTFSerialization.sln remove Tests/GLTFSerializationTests/GLTFSerializationTests.csproj
$ dotnet sln GLTFSerialization.sln remove Tests/GLTFSerializationTests/GLTFSerializationUWPTests.csproj
I had also added explicitly the path to the 4.7.1 assemblies in UnityGLTF-dll.csproj
...
<TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion>
<FrameworkPathOverride>/usr/lib/mono/4.7.1-api</FrameworkPathOverride>
<EnableFrameworkPathOverride>true</EnableFrameworkPathOverride>
but this may not be necessary with the mono msbuild.
Then
$ dotnet msbuild GLTFSerialization.sln
complained about requiring a nuget restore and not finding other assemblies.
I used
$ dotnet restore GLTFSerialization.sln
which took a while.
Then I tried mono msbuild:
$ msbuild GLTFSerialization.sln
and it successfully compiled (!).
I did not test the artefacts, eg. the plugins yet.
https://github.com/dotnet/sdk/issues/335 seems to apply.
I could build a unitypackage from the linux build, using the Unity invocation in the shell script. It worked fine.
recipe:
$ dotnet sln GLTFSerialization.sln remove Tests/GLTFSerializationTests/GLTFSerializationTests.csproj
$ dotnet sln GLTFSerialization.sln remove Tests/GLTFSerializationUWPTests/GLTFSerializationUWPTests.csproj
$ dotnet restore GLTFSerialization.sln
$ sed -i.BAK 's/CSHARP.Targets/CSharp.targets/g' ../UnityGLTF/UnityGLTF-dll.csproj
$ kate GLTFSerialization/GLTFSerialization.csproj
...
<TargetFrameworks>net35;netstandard1.3</TargetFrameworks>
<TargetFrameworks Condition="'$(MSBuildRuntimeType)' != 'Mono'">$(TargetFrameworks);uap10.0.10586</TargetFrameworks>
<!-- point to mono assemblies -->
<FrameworkPathOverride>/usr/lib/mono/4.7.1-api</FrameworkPathOverride>
<EnableFrameworkPathOverride>true</EnableFrameworkPathOverride>
$ dotnet msbuild GLTFSerialization.sln -t:GLTFSerialization -p:TargetFramework=net35
$ cd ../
$ ~/Unity/Hub/Editor/2019.1.0f2/Editor/Unity -batchmode -projectPath UnityGLTF -exportPackage Assets/UnityGLTF ../current-package/UnityGLTF.unitypackage -quit
Linux build result: UnityGLTF.unitypackage.zip GLTFSerialization.sln without tests: GLTFSerialization.sln.zip GLTFSerialization.csproj with explicit Framework assembly path: GLTFSerialization.csproj.zip UnityGLTF-dll.csproj with fixed case in CSharp.targets path: UnityGLTF-dll.csproj.zip
As an aside, on the Linux experimental Unity2017.4 version, I get script errors after loading the package, release or self-built.
Here is a branch in a fork with these changes and a one-stop-shopping build-unity-package shell script in scripts: https://github.com/andreasplesch/UnityGLTF/tree/linux-build
Please update to the latest version and open a new issue if the problem persists. Thanks!
I know that #77 exists but I also want to add that I'm getting build errors on linux that is causing me not be able to build it at all, even with rider (as suggested in that thread).
The following are the errors that I get, compiling on a system with an updated version of mono (from their apt repo for 16.04).